σ
&9_[c           @@ sj  d  Z  d d l m Z d d l m Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 d d l
 m Z m Z m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z m Z m Z m Z d d l m Z d d l  m! Z! m" Z" m# Z# d d l$ m% Z% d d l& m' Z' d d l( m) Z) d d l* m+ Z+ m, Z, m- Z- m. Z. m/ Z/ m0 Z0 d Z1 d e f d     YZ2 e3 e  Z4 e4 j5 e"  i  Z6 d   Z7 e7 d d d d  e7 d d d d   e7 d! d" d# d$  e7 d% d& d' d(  e7 d) d* d+ d,  e	   Z8 d e8 j9 _: e; e8 j _< d- e8 j' _= d. e8 j9 _> d. e8 j9 _? d. e8 j9 _@ d/ e8 j9 _A d0 e8 j9 _B e8 d1 f e6 d2 <i i eC d3 6d4 6d5 f e6 d3 <i i eC d6 6d4 6d7 f e6 d8 <e4 j5 e6  e3 e  ZD eD j5 e#  d9 e f d:     YZE d4 e e! f d;     YZF d d<  ZH eF jI ZJ eK d= k rfeJ   n  d S(>   sl   
The :class:`~IPython.core.application.Application` object for the command
line :command:`ipython` program.
i    (   t   absolute_import(   t   print_functionN(   t   Config(   t   boolean_flagt   catch_config_errort   Application(   t   release(   t   usage(   t   IPCompleter(   t   CrashHandler(   t   PlainTextFormatter(   t   HistoryManager(   t
   ProfileDirt   BaseIPythonApplicationt
   base_flagst   base_aliases(   t   ScriptMagics(   t   InteractiveShellAppt   shell_flagst   shell_aliases(   t   StoreMagicsi   (   t   TerminalInteractiveShell(   t   get_ipython_dir(   t   Boolt   Listt   Dictt   defaultt   observet   Types  
ipython --matplotlib       # enable matplotlib integration
ipython --matplotlib=qt    # enable matplotlib integration with qt4 backend

ipython --log-level=DEBUG  # set logging to DEBUG
ipython --profile=foo      # start with profile foo

ipython profile create foo # create profile foo w/ default config files
ipython help profile       # show the help for the profile subcmd

ipython locate             # print the path to the IPython directory
ipython locate profile foo # print the path to the directory for profile `foo`
t   IPAppCrashHandlerc           B@ s    e  Z d  Z d   Z d   Z RS(   sD   sys.excepthook for IPython itself, leaves a detailed report on disk.c         C@ s;   t  j } t  j } d } t t |   j | | | |  d  S(   Ns)   https://github.com/ipython/ipython/issues(   R   t   authort   author_emailt   superR   t   __init__(   t   selft   appt   contact_namet   contact_emailt   bug_tracker(    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyR!   B   s
    		c         C@ s   |  j  } t t |   j |  g } | j } y[ | | d  x% |  j j j d D] } | |  qR W| d  | |  j j j d  Wn n Xd j	 |  S(   s*   Return a string containing a crash report.s   History of session input:t   _ihs7   
*** Last line of input (may not be in above history):
s   
t    (
   t   section_sepR    R   t   make_reportt   appendR#   t   shellt   user_nst   _last_input_linet   join(   R"   t	   tracebackt   sec_sept   reportt   rpt_addt   line(    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyR*   J   s    		
(   t   __name__t
   __module__t   __doc__R!   R*   (    (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyR   ?   s   	c          G@ s   t  j t |     S(   N(   t   frontend_flagst   updateR   (   t   args(    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   <lambda>c   s    s   autoedit-syntaxs(   TerminalInteractiveShell.autoedit_syntaxs1   Turn on auto editing of files with syntax errors.s2   Turn off auto editing of files with syntax errors.s   simple-prompts&   TerminalInteractiveShell.simple_prompts-   Force simple minimal prompt using `raw_input`s1   Use a rich interactive prompt with prompt_toolkitt   banners!   TerminalIPythonApp.display_banners'   Display a banner upon starting IPython.s-   Don't display a banner upon starting IPython.s   confirm-exits%   TerminalInteractiveShell.confirm_exitsΒ   Set to confirm when you try to exit IPython with an EOF (Control-D
    in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
    you can force a direct exit without any confirmation.s#   Don't prompt the user when exiting.s
   term-titles#   TerminalInteractiveShell.term_titles'   Enable auto setting the terminal title.s(   Disable auto setting the terminal title.s'   IPython.terminal.prompts.ClassicPromptsR(   t   NoColort   Plains:   Gives IPython a similar feel to the classic Python prompt.t   classict   quickt   TerminalIPythonApps*   Enable quick startup with no config files.t   force_interacts¬   If running code from the command line, become interactive afterwards.
    It is often useful to follow this with `--` to treat remaining flags as
    script arguments.
    t   it   LocateIPythonAppc           B@ s,   e  Z d  Z e e d d   Z d   Z RS(   s!   print the path to the IPython dirt   profiles%   IPython.core.profileapp.ProfileLocates.   print the path to an IPython profile directoryc         C@ s-   |  j  d  k	 r |  j  j   St |  j  d  S(   N(   t   subappt   Nonet   startt   printt   ipython_dir(   R"   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRH   ¬   s    (   s%   IPython.core.profileapp.ProfileLocates.   print the path to an IPython profile directory(   R5   R6   t   descriptionR   t   dictt   subcommandsRH   (    (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRD   ₯   s
   	 c           B@ sη  e  Z d  Z e j Z e Z e Z	 e
 e  Z e
 e  Z e   Z e d e d e d d  j d e  Z e d  d    Z e d d9 d d: d d; d d< d d= d d>  Z e d d? d d@ d  d! e j f d" dA  Z dB e d' <e j e  e e  Z e e d d( j d e  Z e  d)  d*    Z! e e d d+ j d e  Z" e e d d, j d e  Z# e  d-  d.    Z$ e  d/ d0 d1  d2    Z% e e  Z& dC d3  Z( e) dC d4   Z* d5   Z+ d6   Z, d7   Z- d8   Z. RS(D   u   ipythont   klasst   default_valuet   helps\   Class to use to instantiate the TerminalInteractiveShell object. Useful for custom Frontendst   configt   classesc      	   C@ s"   t  |  j t t t t t t t g	 S(   sC   This has to be in a method, for TerminalIPythonApp to be available.(	   R   t	   __class__R   R   R   R
   R   R   R   (   R"   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   _classes_defaultΓ   s    t	   qtconsoles*   qtconsole.qtconsoleapp.JupyterQtConsoleAppsK   DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter Qt Console.t   notebooks    notebook.notebookapp.NotebookAppsU   DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter HTML Notebook Server.t   consoles)   jupyter_console.app.ZMQTerminalIPythonAppsW   DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter terminal-based Console.t	   nbconverts#   nbconvert.nbconvertapp.NbConvertAppsU   DEPRECATED, Will be removed in IPython 6.0 : Convert notebooks to/from other formats.t   trusts   nbformat.sign.TrustNotebookAppso   DEPRECATED, Will be removed in IPython 6.0 : Sign notebooks to trust their potentially unsafe contents at load.t
   kernelspecs*   jupyter_client.kernelspecapp.KernelSpecAppsR   DEPRECATED, Will be removed in IPython 6.0 : Manage Jupyter kernel specifications.RE   s"   IPython.core.profileapp.ProfileApps#   Create and manage IPython profiles.t   kernels   ipykernel.kernelapp.IPKernelApps,   Start a kernel without an attached frontend.t   locates'   IPython.terminal.ipapp.LocateIPythonAppt   historys"   IPython.core.historyapp.HistoryApps$   Manage the IPython history database.s+   notebook.nbextensions.InstallNBExtensionAppsU   DEPRECATED, Will be removed in IPython 6.0 : Install Jupyter notebook extension filess   install-nbextensions>   Start IPython quickly by skipping the loading of config files.R@   c         C@ s   | d r d   |  _  n  d  S(   Nt   newc          _@ s   d  S(   N(   RG   (   t   at   kw(    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyR;     s    (   t   load_config_file(   R"   t   change(    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   _quick_changed   s    
s2   Whether to display a banner upon starting IPython.s   If a command or file is given via the command-line,
        e.g. 'ipython foo.py', start an interactive shell after executing the
        file or command.RB   c         C@ s   | d r t  |  _ n  d  S(   NR^   (   t   Truet   interact(   R"   Rb   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   _force_interact_changed  s    
t   file_to_runt   code_to_runt   module_to_runc         C@ s<   | d } | r t  |  _ n  | r8 |  j r8 t |  _ n  d  S(   NR^   (   Rd   t   something_to_runRB   t   FalseRe   (   R"   Rb   R^   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   _file_to_run_changed  s
    
c         C@ sq   | d k r t j d n | } d | k r[ | } | j d  } t j d  d | | <n  t t |   j |  S(   s<   override to allow old '-pylab' flag with deprecation warningi   s   -pylabs^   `-pylab` flag has been deprecated.
    Use `--matplotlib <backend>` and import pylab manually.s   --pylabN(	   RG   t   syst   argvt   indext   warningst   warnR    RA   t   parse_command_line(   R"   Rn   t   idx(    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRr      s    c         C@ s   t  t |   j |  |  j d k	 r) d S|  j rO |  j rO |  j d |  _ n  |  j   |  j	   |  j
   |  j   |  j   |  j   d S(   s8   Do actions after construct, but before starting the app.Ni    (   R    RA   t
   initializeRF   RG   t
   extra_argsRj   Rg   t	   init_patht
   init_shellt   init_bannert   init_gui_pylabt   init_extensionst	   init_code(   R"   Rn   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRt   0  s    




c      	   C@ sJ   |  j  j d |  d |  j d |  j d |  j  |  _ |  j j j |   d S(   s(   initialize the InteractiveShell instancet   parentt   profile_dirRJ   R-   N(   t   interactive_shell_classt   instanceR}   RJ   R-   R,   t   configurablesR+   (   R"   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRw   D  s    	c         C@ sB   |  j  r" |  j r" |  j j   n  |  j t j k r> t   n  d S(   s   optionally display the bannerN(   t   display_bannerRe   R,   t   show_bannert	   log_levelt   loggingt   INFORI   (   R"   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRx   O  s     c         C@ s)   | d k r% t  j d  d |  _ n  d S(   s,   Replace --pylab='inline' with --pylab='auto't   inlines>   'inline' not available as pylab backend, using 'auto' instead.t   autoN(   Rp   Rq   t   pylab(   R"   t   namet   oldR^   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   _pylab_changedV  s    c         C@ sY   |  j  d  k	 r |  j  j   S|  j rE |  j j d  |  j j   n |  j j d  d  S(   Ns   Starting IPython's mainloop...s   IPython not interactive...(   RF   RG   RH   Re   t   logt   debugR,   t   mainloop(   R"   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRH   ]  s    	(   s*   qtconsole.qtconsoleapp.JupyterQtConsoleAppsK   DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter Qt Console.(   s    notebook.notebookapp.NotebookAppsU   DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter HTML Notebook Server.(   s)   jupyter_console.app.ZMQTerminalIPythonAppsW   DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter terminal-based Console.(   s#   nbconvert.nbconvertapp.NbConvertAppsU   DEPRECATED, Will be removed in IPython 6.0 : Convert notebooks to/from other formats.(   s   nbformat.sign.TrustNotebookAppso   DEPRECATED, Will be removed in IPython 6.0 : Sign notebooks to trust their potentially unsafe contents at load.(   s*   jupyter_client.kernelspecapp.KernelSpecAppsR   DEPRECATED, Will be removed in IPython 6.0 : Manage Jupyter kernel specifications.(   s"   IPython.core.profileapp.ProfileApps#   Create and manage IPython profiles.(   s   ipykernel.kernelapp.IPKernelApps,   Start a kernel without an attached frontend.(   s"   IPython.core.historyapp.HistoryApps$   Manage the IPython history database.(   s+   notebook.nbextensions.InstallNBExtensionAppsU   DEPRECATED, Will be removed in IPython 6.0 : Install Jupyter notebook extension filesN(/   R5   R6   R   R   t   cl_usageRK   R   t   crash_handler_classt	   _examplest   examplesR   t   flagst   aliasesR   RR   R   t   objectR   t   tagRd   R~   R   RT   RL   t   deprecated_subcommandsRD   RM   R9   R   t   auto_createRk   R@   R   Rc   R   RB   Rf   Rl   Rj   RG   Rr   R   Rt   Rw   Rx   R   RH   (    (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyRA   ³   sv   			      	   	 
										c         C@ sW   |  d k r t   }  n  t j j |  d  } t   } | j j |  | j   | j	 S(   sh   Load the default config file from the default ipython_dir.

    This is useful for embedded shells.
    t   profile_defaultN(
   RG   R   t   ost   pathR/   RA   t   config_file_pathsR+   Ra   RQ   (   RJ   R}   R#   (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   load_default_configg  s    	
t   __main__(L   R7   t
   __future__R    R   R   R   Rm   Rp   t   traitlets.config.loaderR   t   traitlets.config.applicationR   R   R   t   IPython.coreR   R   t   IPython.core.completerR   t   IPython.core.crashhandlerR	   t   IPython.core.formattersR
   t   IPython.core.historyR   t   IPython.core.applicationR   R   R   R   t   IPython.core.magicsR   t   IPython.core.shellappR   R   R   t   IPython.extensions.storemagicR   t   interactiveshellR   t   IPython.pathsR   t	   traitletsR   R   R   R   R   R   R   R   RL   R   R9   R8   t   addflagt   classic_configt   InteractiveShellt
   cache_sizeRk   t   pprintt   prompts_classt   separate_int   separate_outt   separate_out2t   colorst   xmodeRd   R   RD   RA   RG   R   t   launch_instancet   launch_new_instanceR5   (    (    (    s5   lib/python2.7/site-packages/IPython/terminal/ipapp.pyt   <module>   s   ".!								΄	