
    <h$?                        S r SSKrSSKrSSKJrJr  SSKJr  SSKJrJ	r	J
r
  SSKJrJr  SSKJr  SSKJr  SS	KJrJrJr  SS
KJr  SSKJr   " S S\5      r\r\	 " S S\5      5       r " S S5      r " S S\5      rSSS.S jr g)z
An embedded IPython shell.
    N)ultratb
compilerop)magic_arguments)Magicsmagics_class
line_magic)InteractiveShellmake_main_module_type)TerminalInteractiveShell)load_default_config)BoolCBoolUnicode)
ask_yes_no)Setc                       \ rS rSrSrg)KillEmbedded    N)__name__
__module____qualname____firstlineno____static_attributes__r       iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\IPython/terminal/embed.pyr   r      s    dr   r   c                       \ rS rSr\\R
                  " 5       \R                  " SSSSS9\R                  " SSSS	S9\R                  " S
SSSS9SS j5       5       5       5       5       r\SS j5       rSr	g)EmbeddedMagics   z-iz
--instance
store_truez&Kill instance instead of call location)actionhelpz-xz--exitzAlso exit the current sessionz-yz--yeszDo not ask confirmationc                    [         R                  " U R                  U5      n[        U5        UR                  (       aM  UR
                  (       d  [        SS5      nOSnU(       a%  U R                  R                  5         [        S5        OCUR
                  (       d  [        SS5      nOSnU(       a  SU R                  l	        [        S5        UR                  (       a  U R                  R                  5         gg)	a  %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 for the given call
location. 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.

Kill Instance Option:

    If for some reasons you need to kill the location where the instance
    is created and not called, for example if you create a single
    instance in one place and debug in many locations, you can use the
    ``--instance`` option to kill this specific instance. Like for the
    ``call location`` killing an "instance" should work even if it is
    recreated within a loop.

.. note::

    This was the default behavior before IPython 5.2

z<Are you sure you want to kill this embedded instance? [y/N] nTzIThis embedded IPython instance will not reactivate anymore once you exit.zAAre you sure you want to kill this embedded call_location? [y/N] FzOThis embedded IPython  call location will not reactivate anymore once you exit.N)r   parse_argstringkill_embeddedprintinstanceyesr   shell_disable_init_locationembedded_activeexitask_exit)selfparameter_sargskills       r   r&   EmbeddedMagics.kill_embedded"   s    B ..t/A/A;Od==88!RTWY 

113 ' ( 88!WY\^ -2

* ' ( 99 JJ! r   c                 Z    SU R                   l        U R                   R                  5         g)a=  %exit_raise Make the current embedded kernel exit and raise and exception.

This function sets an internal flag so that an embedded IPython will
raise a `IPython.terminal.embed.KillEmbedded` Exception on exit, and then exit the current I. This is
useful to permanently exit a loop that create IPython embed instance.
TN)r*   should_raiser.   )r/   r0   s     r   
exit_raiseEmbeddedMagics.exit_raisea   s      #'



r   r   N) )
r   r   r   r   r   r   argumentr&   r6   r   r   r   r   r   r      s     $$&dL#KMdH\#BDdGL#<>4">DM ' 4"n 	 	r   r   c                        \ rS rSrS rS rSrg)	_Sentineln   c                 >    [        U[        5      (       d   eXl        g N)
isinstancestrrepr)r/   rA   s     r   __init___Sentinel.__init__o   s    $$$$$	r   c                     [         $ r>   rA   r/   s    r   __repr___Sentinel.__repr__s   s    r   rE   N)r   r   r   r   rB   rG   r   r   r   r   r;   r;   n   s    r   r;   c                   B  ^  \ rS rSr% \" S5      r\" S5      r\" S5      r	\" S5      r
\" S5      r\" 5       r\" SSS9R                  SS9r\" 5       r\\   \S'   S	 r\S
 5       r\R,                  S 5       rU 4S jrS rU 4S jr      SS jr    SS jrSrU =r$ )InteractiveShellEmbedw   Fr8   Tz$Automatically set the terminal title)r"   )config_inactive_locationsc                 V    [         R                  R                  U R                  5        g)z.Disable the current Instance creation locationN)rJ   rM   add_init_location_idrF   s    r   r+   ,InteractiveShellEmbed._disable_init_location   s    1155d6L6LMr   c                     U R                   [        R                  ;  =(       a    U R                  [        R                  ;  $ r>   )_call_location_idrJ   rM   rP   rF   s    r   r,   %InteractiveShellEmbed.embedded_active   s8    &&.C.W.WW Z''/D/X/XX	Zr   c                 
   U(       aS  [         R                  R                  U R                  5        [         R                  R                  U R                  5        g [         R                  R                  U R                  5        g r>   )rJ   rM   discardrS   rP   rO   )r/   values     r   r,   rT      s^    !55==&&(!55==&&( "5599&&(r   c                   > SU;  d   S5       e[        U 5      nUR                  c#  UR                  5        H	  nXl        M     Xl        UR                  SS 5      nU(       d=  [        R
                  " S5      nUR                  R                  < SUR                  < 3nX@l	        [        [        U ]2  " S0 UD6  [        R                  " U R                  U R                   U R"                  S9[        l        g )Nuser_global_nszXKey word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0.rP      :)
theme_namemodecall_pdbr   )type	_instance	_walk_mropopsys	_getframef_codeco_filenamef_linenorP   superrJ   rB   r   FormattedTBcolorsxmodepdb
excepthook)r/   kwclssubclassclidframe	__class__s         r   rB   InteractiveShellEmbed.__init__   s    B&	fe	f& 4j== MMO%)" , Mvv)40MM!$E#ll66GD!%#D28R8 !,,{{XX
r   c                     g)zJ
Explicitly overwrite :mod:`IPython.core.interactiveshell` to do nothing.
Nr   rF   s    r   init_sys_modules&InteractiveShellEmbed.init_sys_modules   s     	r   c                 T   > [         [        U ]  5         U R                  [        5        g r>   )rh   rJ   init_magicsregister_magicsr   )r/   rs   s    r   ry   !InteractiveShellEmbed.init_magics   s    #T68^,r   c                    SU l         UR                  SS5      nU(       d=  [        R                  " S5      n	U	R                  R
                  < SU	R                  < 3nXl        U R                  (       d  gSU l	        U(       d  US:w  a  U R                  (       a  gU(       a,  U R                  U l        U R                  S-   U-   S-   U l        OS	U l        U R                  (       a  U R                  5         U R                  X#XVS
9  U R                  U l        U R                   b  [#        U R                   5        U R$                  (       a  ['        S5      eg)a  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).
TrS   NrZ   r[   Fr   
r8   )stack_depthcompile_flagsz2Embedded IPython raising error, as user requested.)keep_runningrb   rc   rd   re   rf   rg   rS   r,   exit_now
dummy_modebanner2old_banner2display_bannershow_bannermainloopexit_msgr'   r5   r   )
r/   headerlocal_nsmoduledummyr~   r   rn   rq   rr   s
             r   __call__InteractiveShellEmbed.__call__   s   6 ! vv)40MM!$E#ll66GD!%##  UaZDOO #||D<<$.7$>DL!D 	+ 	 	
 ''==$$-- STT r   c           	         Ub  Ub  Uc  U R                   (       a  [        R                  " U5      R                  nUc  UR                  nUc#  UR
                  n [        R                  US      nUc'  UR                  R                  [        R                  -  nU R                   nU R"                  nU R$                  R&                  n	Ub  X l        UbY  UR)                  5        V
Vs0 s H&  u  pXR*                  R-                  5       ;  d  M$  X_M(     nn
nXl        U R/                  5         Ub  X@R$                  l        U R1                  5         U R2                     U R4                     U R7                  5         SSS5        SSS5        Ub]  UR9                  U R"                  R)                  5        V
Vs0 s H&  u  pXR*                  R-                  5       ;  d  M$  X_M(     snn
5        Xpl        Xl        XR$                  l        g! [         a=    [        R                  " SUR                  SS5      -  5        [        U5      " 5       n GNf = fs  snn
f ! , (       d  f       N= f! , (       d  f       N= fs  snn
f )am  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.

Nr   zFailed to get module %szunknown module)default_user_namespacesrc   rd   f_backf_locals	f_globalsmodulesKeyErrorwarningswarngetr
   re   co_flagsr   	PyCF_MASKuser_moduleuser_nscompileflagsitemsuser_ns_hiddenkeysinit_user_nsset_completer_framebuiltin_trapdisplay_trapinteractupdate)r/   r   r   r~   r   
call_frame	global_nsorig_user_moduleorig_user_nsorig_compile_flagskvreentrant_local_nss                r   r   InteractiveShellEmbed.mainloop	  s   < =3H,,{3::J%..~&00	@ [[:)>?F $!+!2!2!;!;!+!5!5"6
  ++||!\\//
 % 5=^^5E!m5E6AReReRjRjRlIl$!$5E!m-L $!.LL 	  " 1 1MMO !2 OO0B0B0Dl0DfqQdQdQiQiQkHkTQT0Dlm ,#/c   @MM";!j2BC#D  39=?F	@4 "n !2 1
 msO   H '#III()I:I(5#I9
I9
AII
I%	!I((
I6)rS   rP   r   r   r   r   r   r   )r8   NNNrZ   N)NNr   N)r   r   r   r   r   r   r   r   r   embeddedr5   r   tag
term_titlesetrM   r   r@   __annotations__r+   propertyr,   setterrB   rv   ry   r   r   r   __classcell__)rs   s   @r   rJ   rJ   w   s    eJr{HT{H<L 4[NyH e3	cc  %(ES)N Z Z ( (
6- EUR Y0 Y0r   rJ   r8   )r   r   c                    UR                  S5      nUc  [        5       nUR                  Ul        X2S'   UR                  SS5      nUR	                  SS5      nU(       a  US   R                  SUUUS:g  S.05        SnSn [        R                  n[        R                  n[        R                  nUb  [        U5      n	U	R                  5         [        R                  " S	5      n
[        R                  " SS
U
R                   R"                  < SU
R$                  < 30UD6nU" U SUU
R                   R"                  < SU
R$                  < 3S9  [        R                  5         Ub8  [        U5      n	U	R                  5         U	R'                  5        H	  nXl        M     Ub  U[        l        U[        l        gg! [         a     GN&f = f)a  Call this to embed IPython at the current point in your program.

The first invocation of this will create a :class:`terminal.embed.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()

Parameters
----------

header : str
    Optional header string to print at startup.
compile_flags
    Passed to the `compile_flags` parameter of :py:meth:`terminal.embed.InteractiveShellEmbed.mainloop()`,
    which is called when the :class:`terminal.embed.InteractiveShellEmbed` instance is called.
**kwargs : various, optional
    Any other kwargs will be passed to the :class:`terminal.embed.InteractiveShellEmbed` constructor.
    Full customization can be done by passing a traitlets :class:`Config` in as the
    `config` argument (see :ref:`configure_start_ipython` and :ref:`terminal_options`).
rL   Nusingsyncrj   nocolorr   )loop_runnerrj   	autoawaitrZ   rP   r[      )r   r~   r   rS   r   )r   r   r   rJ   rb   r   rc   ps1ps2AttributeErrorr	   r`   r_   clear_instancerd   r(   re   rf   rg   ra   )r   r   kwargsrL   r   rj   r   r   saved_shell_instancero   rr   r*   rp   s                r   embedr   e  s   F ZZ!F~$&'-'F'F$!xJJw'EZZ),Fx*#($!&&-	
 C
Cgggg ,55''(MM!E!** =  %..>2 =5;=E	Qm%*\\%=%=u~~NP((*''(H!5 (
 '  s    F: :
GG)!__doc__rc   r   IPython.corer   r   r   IPython.core.magicr   r   r   IPython.core.interactiveshellr	   r
   !IPython.terminal.interactiveshellr   IPython.terminal.ipappr   	traitletsr   r   r   IPython.utils.ior   typingr   	Exceptionr   KillEmbededr   r;   rJ   r   r   r   r   <module>r      s      , ( ? ? Q F 6 * * '  "9 "  KV K K\ k04 k0\ d Or   