ó
æ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 m Z 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 m Z m Z d d l m Z e d e
 f d „  ƒ  Yƒ Z d e f d „  ƒ  YZ d „  Z d S(   s   
An embedded IPython shell.
iÿÿÿÿ(   t   with_statement(   t   print_functionN(   t   ultratbt
   compilerop(   t   Magicst   magics_classt
   line_magic(   t   DummyMod(   t   InteractiveShell(   t   TerminalInteractiveShell(   t   load_default_config(   t   Boolt   CBoolt   Unicode(   t
   ask_yes_not   EmbeddedMagicsc           B€ s   e  Z e d  d „ ƒ Z RS(   t    c         C€ s2   t  d d ƒ } | r. t |  j _ t d ƒ n  d S(   së  %kill_embedded : deactivate for good the current embedded IPython.

        This function (after asking for confirmation) sets an internal flag so
        that an embedded IPython will never activate again.  This is useful to
        permanently disable a shell that is being called inside a loop: once
        you've figured out what you needed from it, you may then kill it and
        the program will then continue to run without the interactive shell
        interfering again.
        sB   Are you sure you want to kill this embedded instance (y/n)? [y/N] t   ns@   This embedded IPython will not reactivate anymore once you exit.N(   R   t   Falset   shellt   embedded_activet   print(   t   selft   parameter_st   kill(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyt   kill_embedded   s
    	(   t   __name__t
   __module__R   R   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyR      s   t   InteractiveShellEmbedc           B€ s¡   e  Z e e ƒ Z e d  ƒ Z e e ƒ Z	 e e ƒ Z
 e e ƒ Z e ƒ  Z d „  Z d „  Z d „  Z d  d d d d d d d „ Z d d d d d d d „ Z RS(	   R   c         K€ so   | j  d d  ƒ d  k	 r+ t j d t ƒ n  t t |  ƒ j |   t j	 d |  j
 d |  j d |  j ƒ t _ d  S(   Nt   user_global_nssi   user_global_ns has been replaced by user_module. The                           parameter will be ignored.t   color_schemet   modet   call_pdb(   t   gett   Nonet   warningst   warnt   DeprecationWarningt   superR   t   __init__R   t   FormattedTBt   colorst   xmodet   pdbt   syst
   excepthook(   R   t   kw(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyR'   =   s    	c         C€ s   d  S(   N(    (   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyt   init_sys_modulesL   s    c         C€ s$   t  t |  ƒ j ƒ  |  j t ƒ d  S(   N(   R&   R   t   init_magicst   register_magicsR   (   R   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyR0   O   s    i   c         C€ sÒ   |  j  s d St |  _ | s1 | d k r5 |  j r5 d S|  j rK |  j ƒ  n  | rx |  j |  _ |  j d | d |  _ n	 d |  _ |  j | | d | d | d | ƒ|  j |  _ |  j	 d k	 rÎ t |  j	 ƒ n  d S(   sæ  Activate the interactive interpreter.

        __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start
        the interpreter shell with the given local and global namespaces, and
        optionally print a header string at startup.

        The shell can be globally activated/deactivated using the
        dummy_mode attribute. This allows you to turn off a shell used
        for debugging globally.

        However, *each* time you call the shell you can override the current
        state of dummy_mode with the optional keyword parameter 'dummy'. For
        example, if you set dummy mode on with IPShell.dummy_mode = True, you
        can still have a specific call work by making it as IPShell(dummy=False).
        Ni    s   
R   t   stack_deptht	   global_nst   compile_flags(   R   R   t   exit_nowt
   dummy_modet   has_readlinet   set_readline_completert   banner2t   old_banner2t   mainloopt   exit_msgR"   R   (   R   t   headert   local_nst   modulet   dummyR2   R3   R4   (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyt   __call__S   s     				i    c         € s  | d k	 r= | d k r= t j d t ƒ t ƒ  } | | _ n  | d k sa | d k sa | d k râ ˆ  j râ t j | ƒ j	 } | d k r” | j
 } n  | d k r½ | j } t j | d } n  | d k râ | j j t j @} qâ n  ˆ  j } ˆ  j }	 ˆ  j j }
 | d k	 r| ˆ  _ n  | d k	 rV‡  f d †  | j ƒ  Dƒ } | ˆ  _ ˆ  j ƒ  n  | d k	 rq| ˆ  j _ n  ˆ  j ƒ  ˆ  j % ˆ  j  ˆ  j d | ƒ Wd QXWd QX| d k	 rà| j ‡  f d †  ˆ  j j ƒ  Dƒ ƒ n  | ˆ  _ |	 ˆ  _ |
 ˆ  j _ d S(   sè  Embeds IPython into a running python program.

        Parameters
        ----------

        local_ns, module
          Working local namespace (a dict) and module (a module or similar
          object). If given as None, they are automatically taken from the scope
          where the shell was called, so that program variables become visible.

        stack_depth : int
          How many levels in the stack to go to looking for namespaces (when
          local_ns or module is None). This allows an intermediate caller to
          make sure that this function gets the namespace from the intended
          level in the stack. By default (0) it will get its locals and globals
          from the immediate caller.

        compile_flags
          A bit field identifying the __future__ features
          that are enabled, as passed to the builtin :func:`compile` function.
          If given as None, they are automatically taken from the scope where
          the shell was called.

        s,   global_ns is deprecated, use module instead.R   c         € s4   i  |  ]* \ } } | ˆ  j  j ƒ  k r | | “ q S(    (   t   user_ns_hiddent   keys(   t   .0t   kt   v(   R   (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pys
   <dictcomp>Ä   s   	 t   display_bannerNc         € s4   i  |  ]* \ } } | ˆ  j  j ƒ  k r | | “ q S(    (   RB   RC   (   RD   RE   RF   (   R   (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pys
   <dictcomp>Õ   s   	 (   R"   R#   R$   R%   R   t   __dict__t   default_user_namespacesR,   t	   _getframet   f_backt   f_localst	   f_globalst   modulest   f_codet   co_flagsR   t	   PyCF_MASKt   user_modulet   user_nst   compilet   flagst   itemst   init_user_nst   set_completer_framet   builtin_trapt   display_trapt   interactt   update(   R   R>   R?   R2   RG   R3   R4   t
   call_framet   orig_user_modulet   orig_user_nst   orig_compile_flagst   reentrant_local_ns(    (   R   sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyR;   …   sF    	$						

 
)		N(   R   R   R   R   R6   R   R<   R   t   Truet   embeddedR   RG   R'   R/   R0   R"   RA   R;   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyR   1   s   				1	c    
      K€ sa  |  j  d ƒ } |  j d d ƒ } |  j d d ƒ } | d k ra t ƒ  } | j | _ | |  d <n  d } d } y t j } t j } Wn t	 k
 r– n Xt
 j } | d k	 rÅ t | ƒ } | j ƒ  n  t j |    } | d | d d d | ƒ t j ƒ  | d k	 r<t | ƒ } | j ƒ  x  | j ƒ  D] }	 | |	 _ q&Wn  | d k	 r]| t _ | t _ n  d S(   sä  Call this to embed IPython at the current point in your program.

    The first invocation of this will create an :class:`InteractiveShellEmbed`
    instance and then call it.  Consecutive calls just call the already
    created instance.

    If you don't want the kernel to initialize the namespace
    from the scope of the surrounding function,
    and/or you want to load full IPython configuration,
    you probably want `IPython.start_ipython()` instead.

    Here is a simple example::

        from IPython import embed
        a = 10
        b = 20
        embed(header='First time')
        c = 30
        d = 40
        embed()

    Full customization can be done by passing a :class:`Config` in as the
    config argument.
    t   configR=   u    R4   R2   i   N(   R!   t   popR"   R
   R	   R   R,   t   ps1t   ps2t   AttributeErrorR   t	   _instancet   typet   clear_instancet   instancet	   _walk_mro(
   t   kwargsRd   R=   R4   Rf   Rg   t   saved_shell_instancet   clsR   t   subclass(    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyt   embedÞ   s:    			

	(   t   __doc__t
   __future__R    R   R,   R#   t   IPython.coreR   R   t   IPython.core.magicR   R   R   t   IPython.core.interactiveshellR   R   t!   IPython.terminal.interactiveshellR	   t   IPython.terminal.ipappR
   t	   traitletsR   R   R   t   IPython.utils.ioR   R   R   Rr   (    (    (    sN   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/terminal/embed.pyt   <module>   s    ­