ó
æNXc           @@ sÇ  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 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 m Z d d l m Z e e g  e D] Z e d k	 rÿ e ^ qÿ ƒ ƒ Z! e e j" j# ƒ  ƒ Z$ e$ j% d d ƒ i  Z& d „  Z' e' d d d d ƒ e' d d d d ƒ e' d d d d ƒ e& j( e) d i  d f ƒ ƒ e' d d d  d! ƒ e' d" d# d$ d% ƒ e' d& d' d( d) ƒ e ƒ  Z* d* e* j+ _, d* e* j+ _- d* e* j+ _. e* d+ f e& d, <i i d d- 6d. 6d/ f e& d- <i i d d0 6d. 6d1 f e& d0 <e) d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA d- dB d0 dC ƒ 
Z/ dD e/ dE <d. e
 f dF „  ƒ  YZ0 d S(G   s‚   
A mixin for :class:`~IPython.core.application.Application` classes that
launch InteractiveShell instances, load extensions, etc.
i    (   t   absolute_import(   t   print_functionN(   t   boolean_flag(   t   Configurable(   t   Config(   t
   pylabtools(   t	   py3compat(   t   preserve_keys(   t   filefind(   t   Unicodet   Instancet   Listt   Boolt   CaselessStrEnum(   t   guist   autoc          G@ s   t  j t |  Œ  ƒ S(   N(   t   shell_flagst   updateR   (   t   args(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt   <lambda>(   s    t
   autoindents   InteractiveShell.autoindents   Turn on autoindenting.s   Turn off autoindenting.t	   automagics   InteractiveShell.automagicso   Turn on the auto calling of magic commands. Type %%magic at the
        IPython  prompt  for  more information.s,   Turn off the auto calling of magic commands.t   pdbs   InteractiveShell.pdbs;   Enable auto calling the pdb debugger after every exception.s<   Disable auto calling the pdb debugger after every exception.t   pydbsh   Use the third party 'pydb' package as debugger, instead of pdb.
        Requires that pydb is installed.t   pprints   PlainTextFormatter.pprints'   Enable auto pretty printing of results.s(   Disable auto pretty printing of results.s
   color-infos   InteractiveShell.color_infos0  IPython can display information about objects via a set of functions,
    and optionally can use colors for this, syntax highlighting
    source code and various other elements. This is on by default, but can cause
    problems with some pagers. If you see such problems, you can disable the
    colours.s-   Disable using colors for info related things.s   deep-reloads   InteractiveShell.deep_reloadsT   **Deprecated** Enable deep (recursive) reloading by default. IPython can use the
    deep_reload module which reloads changes in modules recursively (it
    replaces the reload() function, so you don't need to change anything to
    use it). deep_reload() forces a full reload of modules whose code may
    have changed, which the default reload() function does not.  When
    deep_reload is off, IPython will use the normal reload(), but
    deep_reload will still be available as dreload(). This feature is off
    by default [which means that you have both normal reload() and
    dreload()].s.   Disable deep (recursive) reloading by default.t    s&   Eliminate all spacing between prompts.t   nosept   pylabt   InteractiveShellAppsZ   Pre-load matplotlib and numpy for interactive use with
    the default matplotlib backend.t
   matplotlibsQ   Configure matplotlib for interactive use with
    the default matplotlib backend.t   autocalls   InteractiveShell.autocallt   colorss   InteractiveShell.colorst   logfiles   InteractiveShell.logfilet	   logappends   InteractiveShell.logappendt   cs   InteractiveShellApp.code_to_runt   ms!   InteractiveShellApp.module_to_runt   exts#   InteractiveShellApp.extra_extensiont   guis   InteractiveShellApp.guis   InteractiveShellApp.pylabs   InteractiveShellApp.matplotlibs   InteractiveShell.cache_sizes
   cache-sizec        	   B@ s6  e  Z d  Z e e ƒ  d e d d ƒZ e d d e d d ƒZ e e	 d e d d ƒZ
 e e ƒ  d g d e	 ƒZ e e d e d d ƒZ e e ƒ  d e d d	 ƒZ e e d e d d
 ƒZ e d d e d d ƒZ e e ƒ  d e d d ƒZ e d d e d d ƒZ e d d e d d ƒZ e e d e d e d d j e ƒ ƒZ e e d e d e d d ƒZ e e d e d e d d ƒZ e e d e d d ƒZ e d d e ƒZ e e d d" d e ƒZ d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% d „  Z& e	 d „ Z' d „  Z( d „  Z) d  „  Z* d! „  Z+ RS(#   sÔ  A Mixin for applications that start InteractiveShell instances.
    
    Provides configurables for loading extensions and executing files
    as part of configuring a Shell environment.

    The following methods should be called by the :meth:`initialize` method
    of the subclass:

      - :meth:`init_path`
      - :meth:`init_shell` (to be implemented by the subclass)
      - :meth:`init_gui_pylab`
      - :meth:`init_extensions`
      - :meth:`init_code`
    t   configt   helps<   A list of dotted module names of IPython extensions to load.R   s3   dotted module name of an IPython extension to load.s:   Reraise exceptions encountered loading IPython extensions?u
   storemagicso   Should variables loaded at startup (by startup files, exec_lines, etc.)
        be hidden from tools like %who?s(   List of files to run at IPython startup.s]   Run the file referenced by the PYTHONSTARTUP environment
        variable at IPython startup.s   A file to be runs(   lines of code to run at IPython startup.s!   Execute the given command string.s   Run the module as a script.t
   allow_nones2   Enable GUI event loop integration with any of {0}.sU   Configure matplotlib for interactive use with
        the default matplotlib backend.sƒ   Pre-load matplotlib and numpy for interactive use,
        selecting a particular matplotlib backend and loop integration.
        s   If true, IPython will populate the user namespace with numpy, pylab, etc.
        and an ``import *`` is done from numpy and pylab, when using pylab mode.
        
        When False, pylab mode should not import any names into the user namespace.
        s1   IPython.core.interactiveshell.InteractiveShellABCR   c         C@ s/   |  j  d  k	 r+ | |  j  _ |  j  j ƒ  n  d  S(   N(   t   shellt   Nonet   user_nst   init_user_ns(   t   selft   namet   oldt   new(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt   _user_ns_changedÉ   s    c         C@ s-   t  j d d k r) t  j j d d ƒ n  d S(   s.   Add current working directory, '', to sys.pathi    R   N(   t   syst   patht   insert(   R-   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt	   init_pathÎ   s    c         C@ s   t  d ƒ ‚ d  S(   Ns   Override in subclasses(   t   NotImplementedError(   R-   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt
   init_shellÓ   s    c         @ s^  t  } ˆ j ‰  ˆ j r6 ‡ ‡  f d †  } ˆ j } n< ˆ j rT ˆ  j } ˆ j } n ˆ j rr ˆ  j } ˆ j } n  | s| d Sy | | ƒ } Wn] t k
 r½ ˆ j j	 d ƒ ˆ j j
 ƒ  d St k
 rë ˆ j j	 d ƒ ˆ j j
 ƒ  d SXt | t ƒ rA| d  \ } } ˆ j j d | | ƒ | d k rZt d | ƒ qZn | } ˆ j j d	 | ƒ d S(
   s=   Enable GUI event loop integration, taking pylab into account.c         @ s   ˆ j  |  d ˆ  j ƒS(   Nt
   import_all(   t   enable_pylabt   pylab_import_all(   t   key(   R-   R)   (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyR   Û   s    NsD   Eventloop or matplotlib integration failed. Is matplotlib installed?s-   GUI event loop or pylab initialization failedi   s@   Enabling GUI event loop integration, eventloop=%s, matplotlib=%sR   s   Using matplotlib backend: %ss1   Enabling GUI event loop integration, eventloop=%s(   t   FalseR)   R   R   t   enable_matplotlibR%   t
   enable_guit   ImportErrort   logt   warnt   showtracebackt	   Exceptiont
   isinstancet   tuplet   infot   print(   R-   t   enableR;   t   rR%   t   backend(    (   R)   R-   sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt   init_gui_pylabÖ   s@    						
c         C@ sü   yÉ |  j  j d ƒ |  j |  j } |  j r? | j |  j ƒ n  x† | D]~ } y+ |  j  j d | ƒ |  j j j	 | ƒ WqF |  j
 rŒ ‚  n  d j d | d |  j j ƒ } |  j  j | d t ƒqF XqF WWn, |  j
 rÞ ‚  n  |  j  j d d t ƒn Xd S(	   sÀ   Load all IPython extensions in IPythonApp.extensions.

        This uses the :meth:`ExtensionManager.load_extensions` to load all
        the extensions listed in ``self.extensions``.
        s   Loading IPython extensions...s   Loading IPython extension: %ssG   Error in loading extension: {ext}
Check your config files in {location}R$   t   locationt   exc_infos$   Unknown error in loading extensions:N(   R@   t   debugt   default_extensionst
   extensionst   extra_extensiont   appendRF   R)   t   extension_managert   load_extensiont"   reraise_ipython_extension_failurest   formatt   profile_dirRL   RA   t   True(   R-   RP   R$   t   msg(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt   init_extensionsý   s(    			"	c         C@ su   |  j  ƒ  |  j ƒ  |  j ƒ  |  j rC |  j j j |  j j ƒ n  |  j ƒ  |  j	 ƒ  t
 j j ƒ  t
 j j ƒ  d S(   s1   run the pre-flight code, specified via exec_linesN(   t   _run_startup_filest   _run_exec_linest   _run_exec_filest   hide_initial_nsR)   t   user_ns_hiddenR   R+   t   _run_cmd_line_codet   _run_moduleR2   t   stdoutt   flusht   stderr(   R-   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt	   init_code  s    


	

c         C@ s¹   |  j  s d Sy |  j j d ƒ xj |  j  D]_ } y. |  j j d | ƒ |  j j | d t ƒWq* |  j j d | ƒ |  j j ƒ  q* Xq* WWn$ |  j j d ƒ |  j j ƒ  n Xd S(   sC   Run lines of code in IPythonApp.exec_lines in the user's namespace.Ns*   Running code from IPythonApp.exec_lines...s"   Running code in user namespace: %st   store_historys-   Error in executing line in user namespace: %ss0   Unknown error in handling IPythonApp.exec_lines:(	   t
   exec_linesR@   RN   RF   R)   t   run_cellR<   RA   RB   (   R-   t   line(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyR\   -  s     	c      	   C@ sL  y t  | d |  j g ƒ } Wn( t k
 rF } |  j j d | ƒ d  SXt j } | g |  j d t _ t j	 s› g  t j D] } t j
 | ƒ ^ qz t _ n  z  t j j | ƒ r:|  j j d | ƒ t |  j j d ƒ \ | |  j j d <| j d ƒ r|  j j | d | ƒn |  j j | |  j j d | ƒWd  QXn  Wd  | t _ Xd  S(   Nu   .s   File not found: %ri   s"   Running file in user namespace: %st   __file__s   .ipyt   shell_futures(   R   t   ipython_dirt   IOErrorR@   RA   R2   t   argvt
   extra_argsR   t   PY3t
   cast_bytest   osR3   t   isfileRF   R   R)   R+   t   endswitht   safe_execfile_ipyt   safe_execfile(   R-   t   fnameRk   t   full_filenamet   et	   save_argvt   a(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt
   _exec_file@  s,    		+
c      	   C@ s‚  |  j  j } g  } |  j rÎ t j j d t ƒ rÎ |  j pH |  j pH |  j	 rÎ t j d } |  j
 j d | ƒ z? y |  j | ƒ Wn' |  j
 j d | ƒ |  j j ƒ  n XWd |  j j rÊ |  j j ƒ  n  Xn  | t j t j j | d ƒ ƒ 7} | t j t j j | d ƒ ƒ 7} | sd S|  j
 j d | ƒ y( x! t | ƒ D] } |  j | ƒ q?WWn$ |  j
 j d ƒ |  j j ƒ  n Xd S(	   s(   Run files from profile startup directoryt   PYTHONSTARTUPs    Running PYTHONSTARTUP file %s...s0   Unknown error in handling PYTHONSTARTUP file %s:Ns   *.pys   *.ipys    Running startup files from %s...s(   Unknown error in handling startup files:(   RW   t   startup_dirt   exec_PYTHONSTARTUPRr   t   environt   getR<   t   file_to_runt   code_to_runt   module_to_runR@   RN   R|   RA   R)   RB   t   has_readlinet   set_readline_completert   globR3   t   joint   sorted(   R-   R~   t   startup_filest   python_startupRw   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyR[   `  s2     ""c         C@ sm   |  j  s d S|  j j d ƒ y% x |  j  D] } |  j | ƒ q* WWn$ |  j j d ƒ |  j j ƒ  n Xd S(   s$   Run files from IPythonApp.exec_filesNs)   Running files in IPythonApp.exec_files...s0   Unknown error in handling IPythonApp.exec_files:(   t
   exec_filesR@   RN   R|   RA   R)   RB   (   R-   Rw   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyR]   ‚  s    	c         C@ sÉ   |  j  rn |  j  } y. |  j j d | ƒ |  j j | d t ƒWqÅ |  j j d | ƒ |  j j ƒ  qÅ XnW |  j rÅ |  j } y |  j	 | d t
 ƒWqÅ |  j j d | ƒ |  j j ƒ  qÅ Xn  d S(   s.   Run code or file specified at the command-lines+   Running code given at command line (c=): %sRf   s-   Error in executing line in user namespace: %sRk   s-   Error in executing file in user namespace: %sN(   Rƒ   R@   RF   R)   Rh   R<   RA   RB   R‚   R|   RX   (   R-   Ri   Rw   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyR`     s$    				c         C@ s\   |  j  rX t j } t j g |  j t _ z  |  j j |  j  |  j j ƒ Wd | t _ Xn  d S(   s)   Run module specified at the command-line.N(   R„   R2   Rn   t
   executableRo   R)   t   safe_run_moduleR+   (   R-   Rz   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyRa   ¦  s    		N(,   t   __name__t
   __module__t   __doc__R   R	   RX   RP   RQ   R   R<   RU   RO   R^   RŒ   R   R‚   Rg   Rƒ   R„   R   t   gui_keysRV   R%   t   backend_keysR   R   R:   R
   R)   t   dictR*   R+   R1   R5   R7   RK   RZ   Re   R\   R|   R[   R]   R`   Ra   (    (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyR   y   sb   																			'			 	"		(1   R‘   t
   __future__R    R   R‡   Rr   R2   t   traitlets.config.applicationR   t   traitlets.config.configurableR   t   traitlets.config.loaderR   t   IPython.coreR   t   IPython.utilsR   t   IPython.utils.contextsR   t   IPython.utils.pathR   t	   traitletsR	   R
   R   R   R   t   IPython.lib.inputhookR   RE   R‰   R;   R*   R’   t   backendst   keysR“   R4   R   t   addflagR   R”   t   nosep_configt   InteractiveShellt   separate_int   separate_outt   separate_out2t   shell_aliasesR   (    (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/core/shellapp.pyt   <module>   sz   (1		
								
