wL i$?dZddlZddlZddlmZmZddlmZddlmZm Z m Z ddl m Z m Z ddlmZddlmZdd lmZmZmZdd lmZdd lmZGd d eZeZe GddeZGddZGddeZddddZ y)z An embedded IPython shell. N)ultratb compilerop)magic_arguments)Magics magics_class line_magic)InteractiveShellmake_main_module_type)TerminalInteractiveShell)load_default_config)BoolCBoolUnicode) ask_yes_no)Setc eZdZy) KillEmbeddedN)__name__ __module__ __qualname__\/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/IPython/terminal/embed.pyrrsrrc eZdZeejej ddddej ddddej d d dd dd Zedd Zy)EmbeddedMagicsz-iz --instance store_truez&Kill instance instead of call location)actionhelpz-xz--exitzAlso exit the current sessionz-yz--yeszDo not ask confirmationctj|j|}t||jrC|j s t dd}nd}|r_|jjtdn9|j s t dd}nd}|rd|j_ td|jr|jjyy) 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 z4">DM'4"n  rrceZdZdZdZy) _Sentinelc6t|tsJ||_yN) isinstancestrrepr)r+r:s r__init__z_Sentinel.__init__os$$$$ rctSr7)r:r+s r__repr__z_Sentinel.__repr__ss rN)rrrr;r>rrrr5r5ns rr5c>eZdZUedZedZedZedZ edZ eZeddjdZ e Zeeed<dZed Zej*d Zfd Zd Zfd Z ddZ ddZxZS)InteractiveShellEmbedFr2Tz$Automatically set the terminal title)r)config_inactive_locationscVtjj|jy)z.Disable the current Instance creation locationN)r@rBadd_init_location_idr=s rr'z,InteractiveShellEmbed._disable_init_locations1155d6L6LMrcv|jtjvxr|jtjvSr7)_call_location_idr@rBrEr=s rr(z%InteractiveShellEmbed.embedded_actives8&&.C.W.WWZ''/D/X/XX Zrc|rStjj|jtjj|jytjj |jyr7)r@rBdiscardrGrErD)r+values rr(z%InteractiveShellEmbed.embedded_actives^  ! 5 5 = =&& ( ! 5 5 = =&& ( " 5 5 9 9&& (rc d|vsJdt|}|j#|jD] }||_ ||_|jdd}|s:t j d}|j jd|j}||_ tt|2di|tj|j|j |j"t_y)Nuser_global_nszXKey word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0.rE:) theme_namemodecall_pdbr)type _instance _walk_mropopsys _getframef_code co_filenamef_linenorEsuperr@r;r FormattedTBcolorsxmodepdb excepthook)r+kwclssubclassclidframe __class__s rr;zInteractiveShellEmbed.__init__s B & f e f &4j == MMO *%)" * CMvv)40MM!$E#ll66GD!% #D28R8!,,{{XX rcy)zZ Explicitly overwrite :mod:`IPython.core.interactiveshell` to do nothing. Nrr=s rinit_sys_modulesz&InteractiveShellEmbed.init_sys_moduless rcTtt| |jtyr7)r[r@ init_magicsregister_magicsr)r+rfs rrjz!InteractiveShellEmbed.init_magicss #T68 ^,rc jd|_|jdd}|s:tjd} | jj d| j }||_|jsyd|_ |s|dk7r |jry|r,|j|_ |jdz|zdz|_ nd |_ |jr|j|j|||| |j|_ |j t#|j |j$r t'd y) aActivate 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). TrGNrMrNFr r2) stack_depth compile_flagsz2Embedded IPython raising error, as user requested.) keep_runningrUrVrWrXrYrZrGr(exit_now dummy_modebanner2 old_banner2display_banner show_bannermainloopexit_msgr#r0r) r+headerlocal_nsmoduledummyrnrorardres r__call__zInteractiveShellEmbed.__call__s6!vv)40MM!$E#ll66GD!%##   UaZDOO  #||D <<$.7$>DL!D         f+]  '' == $ $--   ST T rc ||||jr{tj|j}| |j}|#|j } tj |d}|'|jjtjz}|j }|j"}|j$j&} |||_|W|j)D cic]%\} } | |j*j-vs#| | '} } } | |_|j/|||j$_|j1|j25|j45|j7dddddd|Z|j9|j"j)D cic]%\} } | |j*j-vs#| | 'c} } ||_||_| |j$_y#t$r<tjd|jddzt|}YwxYwcc} } w#1swYxYw#1swYxYwcc} } w)aEmbeds 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. NrzFailed to get module %szunknown module)default_user_namespacesrVrWf_backf_locals f_globalsmodulesKeyErrorwarningswarngetr rXco_flagsr PyCF_MASK user_moduleuser_nscompileflagsitemsuser_ns_hiddenkeys init_user_nsset_completer_frame builtin_trap display_trapinteractupdate) r+rzr{rnro call_frame global_nsorig_user_module orig_user_nsorig_compile_flagskvreentrant_local_nss rrwzInteractiveShellEmbed.mainloop s?< =3H,,{3::J%..~&00 @ [[:)>?F $!+!2!2!;!;!+!5!5"6  ++|| !\\//  %D   5=^^5E!m6AqRVReReRjRjRlIl!Q$!m !m-DL      $!.DLL    "     1 1  MMO     OO 0B0B0Dlfq!QUQdQdQiQiQkHkQTl m,# / c @MM";! j2BC#D>29=?F @4"n     msOG7$H??H? II+I%$I I 7AH<;H<I II)r2NNNrMN)NNrN)rrrr rrrrxrembeddedr0rutag term_titlesetrBrr9__annotations__r'propertyr(setterr;rhrjr}rw __classcell__)rfs@rr@r@wseJr{HT{H2 =5; =E Qm%*\\%=%=u~~NP((*''(   6H!5H  6 '    s< F.. F;:F;)!__doc__rVr IPython.corerrrIPython.core.magicrrrIPython.core.interactiveshellr r !IPython.terminal.interactiveshellr IPython.terminal.ipappr traitletsr rrIPython.utils.iortypingr Exceptionr KillEmbededrr5r@rrrrrs ,(??QF6**'"9" KVKK\k04k0\dOr