
    MhkK                        d Z ddl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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mZmZmZ ddlmZ  e  e!ej"                   e!ej#                  z             Z$i Z%d Z& e&dddd            e&dddd            e&dddd            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'<   d(d)d*iid+fe%d)<   d(d,d*iid-fe%d,<    e,d.d/d/d0d1d2d3d4d5d6d78          Z-d9e-d:<    G d; d<e          Z. G d= d(e          Z/dS )>z
A mixin for :class:`~IPython.core.application.Application` classes that
launch InteractiveShell instances, load extensions, etc.
    N)chain)boolean_flag)Configurable)Config)SYSTEM_CONFIG_DIRSENV_CONFIG_DIRS)preserve_keys)filefind)UnicodeInstanceListBoolCaselessStrEnumobserveDottedObjectName	Undefined)pt_inputhooksc                  D    t                               t          |            S N)shell_flagsupdater   )argss    U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/core/shellapp.py<lambda>r   *   s    **<+>??     
autoindentzInteractiveShell.autoindentzTurn on autoindenting.zTurn off autoindenting.	automagiczInteractiveShell.automagiczoTurn on the auto calling of magic commands. Type %%magic at the
        IPython  prompt  for  more information.z,Turn off the auto calling of magic commands.pdbzInteractiveShell.pdbz;Enable auto calling the pdb debugger after every exception.z<Disable auto calling the pdb debugger after every exception.pprintzPlainTextFormatter.pprintz'Enable auto pretty printing of results.z(Disable auto pretty printing of results.z
color-infozInteractiveShell.color_infoa0  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.z-Disable using colors for info related things.z
ignore-cwdzInteractiveShellApp.ignore_cwdz3Exclude the current working directory from sys.pathz1Include the current working directory in sys.path z&Eliminate all spacing between prompts.nosepInteractiveShellApppylabautozPre-load matplotlib and numpy for interactive use with
    the default matplotlib backend. The exact options available
    depend on what Matplotlib provides at runtime.
matplotlibzConfigure matplotlib for interactive use with
    the default matplotlib backend. The exact options available
    depend on what Matplotlib provides at runtime.zInteractiveShell.autocallzInteractiveShell.colorszInteractiveShell.logfilezInteractiveShell.logappendzInteractiveShellApp.code_to_runz!InteractiveShellApp.module_to_runz$InteractiveShellApp.extra_extensionszInteractiveShellApp.guizInteractiveShellApp.pylabzInteractiveShellApp.matplotlib)autocallcolorsthemelogfile	logappendcmextguir#   r%   zInteractiveShell.cache_sizez
cache-sizec            	       h     e Zd ZdZefdeej                 dej        dej        ddf fdZd Z	 xZ
S )	 MatplotlibBackendCaselessStrEnumaT  An enum of Matplotlib backend strings where the case should be ignored.

    Prior to Matplotlib 3.9.0 the list of valid backends is hardcoded in
    pylabtools.backends. After that, Matplotlib manages backends.

    The list of valid backends is determined when it is first needed to avoid
    wasting unnecessary initialisation time.
    selfdefault_valuekwargsreturnNc                 >     t                      j        dd|i| d S )Nr2   r   )super__init__)r1   r2   r3   	__class__s      r   r7   z)MatplotlibBackendCaselessStrEnum.__init__   s-    
 	EE]EfEEEEEr   c                     |dk    r0t                               | |          ddlm}  |            | _        t                               | |          S )Nvaluesr   )'_list_matplotlib_backends_and_gui_loops)object__getattribute__IPython.core.pylabtoolsr;   r:   )r1   namer;   s      r   r=   z1MatplotlibBackendCaselessStrEnum.__getattribute__   sZ    8 7 7d C C KWWWWWWAACCDK&&tT222r   )__name__
__module____qualname____doc__r   r   tAnyr7   r=   __classcell__)r8   s   @r   r0   r0   u   s           )F Fae$FuF %F 
	F F F F F F3 3 3 3 3 3 3r   r0   c                   b   e Zd ZdZ e e            d                              d          Z e e            d                              d          Z	 e
dd                              d          Z e e            d	g                              d          Z e
dd
                              d          Z e e            d                              d          Z e
dd                              d          Z edd                              d          Z e e            d                              d          Z edd                              d          Z edd                              d          Z eedd                    e                                        d          Z edd                              d          Z edd                              d          Z e
dd                              d          Z e
dd                              d          Z edd          Z e
d          Z ee dd          Z! e"d          d             Z#d Z$d Z%d  Z&d! Z'd" Z(d# Z)d)d$Z*d% Z+d& Z,d' Z-d( Z.dS )*r"   a  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`
    z<A list of dotted module names of IPython extensions to load.)helpT)configz
        Dotted module name(s) of one or more IPython extensions to load.

        For specifying extra extensions to load on the command-line.

        .. versionadded:: 7.10
        Fz:Reraise exceptions encountered loading IPython extensions?
storemagiczoShould variables loaded at startup (by startup files, exec_lines, etc.)
        be hidden from tools like %who?z(List of files to run at IPython startup.z]Run the file referenced by the PYTHONSTARTUP environment
        variable at IPython startup.r    zA file to be runz(lines of code to run at IPython startup.z!Execute the given command string.zRun the module as a script.z2Enable GUI event loop integration with any of {0}.)
allow_nonerH   zConfigure matplotlib for interactive use with
        the default matplotlib backend. The exact options available
        depend on what Matplotlib provides at runtime.zPre-load matplotlib and numpy for interactive use,
        selecting a particular matplotlib backend and loop integration.
        The exact options available depend on what Matplotlib provides at runtime.
        zIf 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.
        zIf True, IPython will not add the current working directory to sys.path.
        When False, the current working directory is added to sys.path, allowing imports
        of modules defined in the current directory.z1IPython.core.interactiveshell.InteractiveShellABC)rK   N)r   rK   user_nsc                 n    | j         -|d         | j         _        | j                                          d S d S )Nnew)shellrL   init_user_ns)r1   changes     r   _user_ns_changedz$InteractiveShellApp._user_ns_changed   s:    :!!'DJJ##%%%%% "!r   c                    dt           j        v s| j        rdS t          t           j                  D ]-\  }}t          j                            |          \  }}|dv r n.d}t           j                            |d           dS )a  Add current working directory, '', to sys.path

        Unlike Python's default, we insert before the first `site-packages`
        or `dist-packages` directory,
        so that it is after the standard library.

        .. versionchanged:: 7.2
            Try to insert after the standard library, instead of first.
        .. versionchanged:: 8.0
            Allow optionally not including the current directory in sys.path
        r    N>   dist-packagessite-packagesr   )syspath
ignore_cwd	enumerateossplitinsert)r1   idxrW   parent	last_parts        r   	init_pathzInteractiveShellApp.init_path   s     >>T_>F"38,, 	 	IC "d 3 3FI>>> ?
 CR     r   c                      t          d          )NzOverride in subclasses)NotImplementedErrorr1   s    r   
init_shellzInteractiveShellApp.init_shell  s    !":;;;r   c                     d} j          j        r fd} j        }n+ j        rj        } j        }n j        rj        } j        }|sdS 	  ||          }n# t          $ r7  j                            d            j         	                                 Y dS t          $ r7  j                            d            j         	                                 Y dS w xY wt          |t                    rE|dd         \  }} j                            d||           |dk    rt          d	|z             dS dS |} j                            d
|           dS )z=Enable GUI event loop integration, taking pylab into account.Fc                 <                         | j                  S )N)
import_all)enable_pylabpylab_import_all)keyr1   rO   s    r   r   z4InteractiveShellApp.init_gui_pylab.<locals>.<lambda>  s    !3!3CDDY!3!Z!Z r   NzDEventloop or matplotlib integration failed. Is matplotlib installed?z-GUI event loop or pylab initialization failed   z@Enabling GUI event loop integration, eventloop=%s, matplotlib=%sr$   zUsing matplotlib backend: %sz1Enabling GUI event loop integration, eventloop=%s)rO   r#   r%   enable_matplotlibr.   
enable_guiImportErrorlogwarningshowtraceback	Exception
isinstancetupleinfoprint)r1   enablerj   rr.   backendrO   s   `     @r   init_gui_pylabz"InteractiveShellApp.init_gui_pylab  s   
: 	ZZZZZF*CC_ 	,F/CCX 	%F(C 	F		sAA 	 	 	HcdddJ$$&&&FF 	 	 	HLMMMJ$$&&&FF	
 a 		+RaR5LCHMM 458'C C Cf}}4w>????? } CHMM %&)+ + + + +s   A =C<CCc                    	 | j                             d           | j        | j        z   | j        z   }|D ]}	 | j                             d|           | j        j                            |           >#  | j	        r d
                    || j        j                  }| j                             |d           Y xY wdS #  | j	        r | j                             dd           Y dS xY w)	zLoad all IPython extensions in IPythonApp.extensions.

        This uses the :meth:`ExtensionManager.load_extensions` to load all
        the extensions listed in ``self.extensions``.
        zLoading IPython extensions...zLoading IPython extension: %szGError in loading extension: {ext}
Check your config files in {location})r-   locationT)exc_infoz$Unknown error in loading extensions:N)ro   debugdefault_extensions
extensionsextra_extensionsru   rO   extension_managerload_extension"reraise_ipython_extension_failuresformatprofile_dirr|   rp   )r1   r   r-   msgs       r   init_extensionsz#InteractiveShellApp.init_extensions9  s0   	THNN:;;;'$/9D<QQ  " 9 99HMM"A3GGGJ0??DDDD9> CCI6#&(,(8(A DJ D D 
 H$$S4$888889 9	T6 HCdSSSSSSs#   5C :A32C 3AB<:C &C*c                    |                                   |                                  |                                  | j        r)| j        j                            | j        j                   |                                  | 	                                 t          j                                         t          j                                         t          t          j                                                  | j        _        dS )z1run the pre-flight code, specified via exec_linesN)_run_startup_files_run_exec_lines_run_exec_fileshide_initial_nsrO   user_ns_hiddenr   rL   _run_cmd_line_code_run_modulerV   stdoutflushstderrsetmoduleskeys_sys_modules_keysrc   s    r   	init_codezInteractiveShellApp.init_codeV  s    !!!  	AJ%,,TZ-?@@@ 	!!! 	

'*3;+;+;+=+='>'>
$$$r   c                    | j         sdS 	 | j                            d           | j         D ]y}	 | j                            d|z             | j                            |d           =#  | j                            d|z             | j                                         Y wxY wdS #  | j                            d           | j                                         Y dS xY w)zCRun lines of code in IPythonApp.exec_lines in the user's namespace.Nz*Running code from IPythonApp.exec_lines...z"Running code in user namespace: %sFstore_history-Error in executing line in user namespace: %sz0Unknown error in handling IPythonApp.exec_lines:)
exec_linesro   r~   ru   rO   run_cellrp   rq   )r1   lines     r   r   z#InteractiveShellApp._run_exec_linesj  s    	F	'HNNGHHH / //HMM"F"&#' ( ( (J''E'BBBB/H$$ &248&9 : : :J,,...../ /	'HOPPPJ$$&&&&&&s"   #B( 9A)(B( )8B#!B( (5C c                    	 t          |d| j        g          }n.# t          $ r! | j                            d|z             Y d S w xY wt
          j        }|g| j        dd          z   t
          _        	 t          j	        
                    |          r| j                            d|z             t          | j        j        d          5  || j        j        d<   |                    d          s|                    d          r| j                            ||           n(| j                            || j        j        |d	
           d d d            n# 1 swxY w Y   |t
          _        d S # |t
          _        w xY w)N.zFile not found: %r   z"Running file in user namespace: %s__file__z.ipyz.ipynbshell_futuresT)r   raise_exceptions)r
   ipython_dirIOErrorro   rp   rV   argv
extra_argsrZ   rW   isfileru   r	   rO   rL   endswithsafe_execfile_ipysafe_execfile)r1   fnamer   full_filename	save_argvs        r   
_exec_filezInteractiveShellApp._exec_file}  s   	$UT43C,DEEMM 	 	 	H1%7888FF	
 H	!?T_QRR%88	!w~~m,, HB+, - - - #4:#5zBB 
H 
H5:DJ&z2$--f55 H9O9OPX9Y9Y H
44]CP 5 R R R R 
00151C?LBF 1 H H H
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H 
H !CHHHyCH    sA    'AA2AE, A?EE, EE, EE, ,E:c                    | j         j        gd t          t          t                    D             z   }g }| j        rt          j                            dd          r| j	        s| j
        s| j        st          j        d         }| j                            d|           	 |                     |           n;#  | j                            d|           | j                                         Y nxY w|ddd         D ]l}|t%          j        t          j                            |d                    z  }|t%          j        t          j                            |d	                    z  }m|sdS | j                            d
|           	 t+          |          D ]}|                     |           dS #  | j                            d           | j                                         Y dS xY w)z(Run files from profile startup directoryc                 N    g | ]"}t           j                            |d           #S )startup)rZ   rW   join).0ps     r   
<listcomp>z:InteractiveShellApp._run_startup_files.<locals>.<listcomp>  s5     9
 9
 9
+,BGLLI&&9
 9
 9
r   PYTHONSTARTUPFz Running PYTHONSTARTUP file %s...z0Unknown error in handling PYTHONSTARTUP file %s:Nz*.pyz*.ipyz Running startup files from %s...z(Unknown error in handling startup files:)r   startup_dirr   r   r   exec_PYTHONSTARTUPrZ   environgetfile_to_runcode_to_runmodule_to_runro   r~   r   rp   rO   rq   globrW   r   sorted)r1   startup_dirsstartup_filespython_startupr   r   s         r   r   z&InteractiveShellApp._run_startup_files  s   (45 9
 9
05oGY0Z0Z9
 9
 9
 
 " 	+rz~~ou'M'M 	+%	+)-)9	+=A=O	+Z8NHNN=~NNN+////+  !SUcddd
((*****'"- 	K 	KKTYrw||K'H'HIIIMTYrw||K'I'IJJJMM 	F9;GGG	'.. ' '&&&&' '	'HGHHHJ$$&&&&&&s   B5 56C-'F1 15G)c                    | j         sdS | j                            d           	 | j         D ]}|                     |           dS #  | j                            d           | j                                         Y dS xY w)z$Run files from IPythonApp.exec_filesNz)Running files in IPythonApp.exec_files...z0Unknown error in handling IPythonApp.exec_files:)
exec_filesro   r~   r   rp   rO   rq   )r1   r   s     r   r   z#InteractiveShellApp._run_exec_files  s     	FBCCC	' ' '&&&&' '	'HOPPPJ$$&&&&&&s   A 5A>c                 R   | j         r| j         }	 | j                            d|z             | j                            |d           dS #  | j                            d|z             | j                                         | j        s|                     d           Y dS Y dS xY w| j	        r| j	        }t          j                            |          r t          j                            |d          }t          j                            |          s7| j                            d|           | j        s|                     d           	 |                     |d	
           dS #  | j                            d           | j        s|                     d           Y dS Y dS xY wdS )z.Run code or file specified at the command-linez+Running code given at command line (c=): %sFr   r   r   z__main__.pyzFile '%s' doesn't existrk   Tr      )	tb_offsetN)r   ro   ru   rO   r   rp   rq   interactexitr   rZ   rW   isdirr   existsr   )r1   r   r   s      r   r   z&InteractiveShellApp._run_cmd_line_code  s    	!#D	!K"# $ $ $
##D#>>>>>!  !P""# $ $ $
((***} !IIaLLLLLL! ! !  	!$Ew}}U## ;UM::7>>%(( !  !:EBBB} !IIaLLL!T:::::!
((1(555} !IIaLLLLLL! ! !	! 	!s   9A AB%E% %9F$c                     | j         rut          j        }t          j        g| j        z   t          _        	 | j                            | j         | j        j                   |t          _        dS # |t          _        w xY wdS )z)Run module specified at the command-line.N)r   rV   r   
executabler   rO   safe_run_modulerL   )r1   r   s     r   r   zInteractiveShellApp._run_module  s     		% I'$/9CH%
**4+=+/:+=? ? ? %9$$$$		% 		%s   *A, ,A:)F)/r@   rA   rB   rC   r   r   tagr   r   r   r   r   r   r   r   r   r   r   r   r   r   gui_keysr   r.   r0   r%   r#   ri   rX   r   rO   r   dictrL   r   rR   r`   rd   rz   r   r   r   r   r   r   r   r    r   r   r"   r"      s`         ggiiK  	cc  t	 	 	 
cc  *.eI* * *	cc '
 ggii-99==U=KKd4+   
cc 
 ggii;  	cc  d(   
cc  '"#% % %%(SS%5%5  ggii;  	cc  '"#FGGGKKSWKXXKGB%BCCCGGtGTTM
/AHHRR   
cc	 
 21:  
 
cc  -,   
cc 
 t   
cc  8  
 
cc  HH $& & &E tDzzHht$4888GWY& & &
! ! !0< < <%+ %+ %+NT T T:? ? ?(' ' '&! ! ! !<' ' '<' ' '! ! !>% % % % %r   )0rC   r   	itertoolsr   rZ   rV   typingrD   traitlets.config.applicationr   traitlets.config.configurabler   traitlets.config.loaderr   IPython.core.applicationr   r   IPython.utils.contextsr	   IPython.utils.pathr
   	traitletsr   r   r   r   r   r   r   r   IPython.terminalr   rt   r   backendsaliasesr   r   addflagnosep_configInteractiveShellseparate_inseparate_outseparate_out2r   shell_aliasesr0   r"   r   r   r   <module>r      sf           				 



     5 5 5 5 5 5 6 6 6 6 6 6 * * * * * * H H H H H H H H 0 0 0 0 0 0 ' ' ' ' ' '	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 + * * * * * 5.//&&9N2O2OOPP
?
? !	    36   %AB   --.   3
 4   6=;   vxx,.  )-/  *.0  +"$LMG g/06G  lV456L  ($
#&*').!
%/   <l 3 3 3 3 3 3 3 3:^% ^% ^% ^% ^%, ^% ^% ^% ^% ^%r   