
    Mh0                        d Z ddlZddlZddlZddl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 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 ddlm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*m+Z+m,Z,m-Z-m.Z. dZ/ G d de          Z0 e1e          Z2e23                    e!           i Z4d Z5 e5dddd            e5dddd            e5d d!d"d#            e5d$d%d&d'            e5d(d)d*d+            e5d,d-d.d/            e            Z6de6j7        _8        d0e6j        _9        d1e6j&        _:        d2e6j7        _;        d2e6j7        _<        d2e6j7        _=        d3e6j7        _>        d4e6j7        _?        e6d5fe4d6<   d7d8d9iid:fe4d8<   d7d;d9iid<fe4d=<   e23                    e4            e1e          Z@e@3                    e"            G d> d?e          ZA G d@ d7ee           ZBdBdAZCeBjD        ZEdS )Czp
The :class:`~traitlets.config.application.Application` object for the command
line :command:`ipython` program.
    N)Config)boolean_flagcatch_config_error)release)usage)IPCompleter)CrashHandler)PlainTextFormatter)HistoryManager)
ProfileDirBaseIPythonApplication
base_flagsbase_aliases)MagicsManager)ScriptMagicsLoggingMagics)InteractiveShellAppshell_flagsshell_aliases)StoreMagics   )TerminalInteractiveShell)get_ipython_dir)BoolListdefaultobserveTypea  
ipython --matplotlib       # enable matplotlib integration
ipython --matplotlib=qt    # enable matplotlib integration with qt4 backend

ipython --log-level=DEBUG  # set logging to DEBUG
ipython --profile=foo      # start with profile foo

ipython profile create foo # create profile foo w/ default config files
ipython help profile       # show the help for the profile subcmd

ipython locate             # print the path to the IPython directory
ipython locate profile foo # print the path to the directory for profile `foo`
c                   ,     e Zd ZdZ fdZ fdZ xZS )IPAppCrashHandlerzDsys.excepthook for IPython itself, leaves a detailed report on disk.c                     t           j        }t           j        }d}t          t          |                               ||||           d S )Nz)https://github.com/ipython/ipython/issues)r   authorauthor_emailsuperr    __init__)selfappcontact_namecontact_emailbug_tracker	__class__s        V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/terminal/ipapp.pyr%   zIPAppCrashHandler.__init__B   sM    ~,A%%..}k	
 	
 	
 	
 	
    c                 d   | j         }t          t          |                               |          g}|j        }	  ||dz              | j        j        j        d         D ]} ||            |d            || j        j        j        dz              n#  Y nxY wd	                    |          S )z*Return a string containing a crash report.zHistory of session input:_ihz7
*** Last line of input (may not be in above history):

 )
section_sepr$   r    make_reportappendr'   shelluser_ns_last_input_linejoin)r&   	tracebacksec_sepreportrpt_addliner+   s         r,   r3   zIPAppCrashHandler.make_reportJ   s     ")400<<YGGH-	GG77888.u5  GOPPPGDHN3D89999	Dwwvs   AB B)__name__
__module____qualname____doc__r%   r3   __classcell__r+   s   @r,   r    r    ?   sW        NN
 
 
 
 
        r-   r    c                  D    t                               t          |            S N)frontend_flagsupdater   )argss    r,   <lambda>rI   c   s    --lD.ABB r-   zautoedit-syntaxz(TerminalInteractiveShell.autoedit_syntaxz1Turn on auto editing of files with syntax errors.z2Turn off auto editing of files with syntax errors.zsimple-promptz&TerminalInteractiveShell.simple_promptz-Force simple minimal prompt using `raw_input`z1Use a rich interactive prompt with prompt_toolkitbannerz!TerminalIPythonApp.display_bannerz'Display a banner upon starting IPython.z-Don't display a banner upon starting IPython.zconfirm-exitz%TerminalInteractiveShell.confirm_exitzSet to confirm when you try to exit IPython with an EOF (Control-D
    in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
    you can force a direct exit without any confirmation.z#Don't prompt the user when exiting.tipz#TerminalInteractiveShell.enable_tipz Shows a tip when IPython starts.z#Don't show tip when IPython starts.z
term-titlez#TerminalInteractiveShell.term_titlez'Enable auto setting the terminal title.z(Disable auto setting the terminal title.Fz'IPython.terminal.prompts.ClassicPromptsr1   nocolorPlainz:Gives IPython a similar feel to the classic Python prompt.classicTerminalIPythonAppquickTz*Enable quick startup with no config files.force_interactzIf running code from the command line, become interactive afterwards.
    It is often useful to follow this with `--` to treat remaining flags as
    script arguments.
    ic                   0    e Zd ZdZ ed          Zd ZdS )LocateIPythonAppz!print the path to the IPython dir)z%IPython.core.profileapp.ProfileLocatez.print the path to an IPython profile directory)profilec                 n    | j         | j                                         S t          | j                   d S rE   )subappstartprintipython_dirr&   s    r,   rX   zLocateIPythonApp.start   s5    ;";$$&&&$"#####r-   N)r>   r?   r@   descriptiondictsubcommandsrX    r-   r,   rT   rT      sC        9K$
  K
$ $ $ $ $r-   rT   c                       e Zd ZdZej        ZeZe	Z
eZeZ e            Z eeed                              d          Z ed          d             Z edd	d
ej        fd          Z ed                              d          Z edd                              d          Z ed          d             Z edd                              d          Z edd                              d          Z ed          d             Z  eddd          d             Z! ed          Z"e#d  fd	            Z$d Z%d Z&d Z'd Z( xZ)S )!rO   ipythonz\Class to use to instantiate the TerminalInteractiveShell object. Useful for custom Frontends)klassdefault_valuehelpT)configclassesc                     t           | j        t          t          t          t
          t          t          t          t          t          gS )zCThis has to be in a method, for TerminalIPythonApp to be available.)r   r+   r   r   r   r   r
   r   r   r   r   r[   s    r,   _classes_defaultz#TerminalIPythonApp._classes_default   s1      N$
 	
r-   )z"IPython.core.profileapp.ProfileAppz#Create and manage IPython profiles.)zipykernel.kernelapp.IPKernelAppz,Start a kernel without an attached frontend.z'IPython.terminal.ipapp.LocateIPythonApp)z"IPython.core.historyapp.HistoryAppz$Manage the IPython history database.)rU   kernellocatehistoryFz>Start IPython quickly by skipping the loading of config files.)rd   rP   c                 *    |d         r
d | _         d S d S )Nnewc                      d S rE   r_   )akws     r,   rI   z3TerminalIPythonApp._quick_changed.<locals>.<lambda>   s    T r-   )load_config_filer&   changes     r,   _quick_changedz!TerminalIPythonApp._quick_changed   s)    %= 	:$9$9D!!!	: 	:r-   z2Whether to display a banner upon starting IPython.zIf a command or file is given via the command-line,
        e.g. 'ipython foo.py', start an interactive shell after executing the
        file or command.rQ   c                 (    |d         r	d| _         d S d S )Nrm   T)interactrr   s     r,   _force_interact_changedz*TerminalIPythonApp._force_interact_changed  s#    %= 	! DMMM	! 	!r-   file_to_runcode_to_runmodule_to_runc                 P    |d         }|rd| _         |r| j        sd| _        d S d S d S )Nrm   TF)something_to_runrQ   rv   )r&   rs   rm   s      r,   _file_to_run_changedz'TerminalIPythonApp._file_to_run_changed  sL    Um 	)$(D! 	&t* 	& %	& 	& 	& 	&r-   Nc                    t          t          |                               |           | j        dS | j        r| j        s| j        d         | _        |                                  |                                  | 	                                 | 
                                 |                                  |                                  dS )z8Do actions after construct, but before starting the app.Nr   )r$   rO   
initializerW   
extra_argsr|   rx   	init_path
init_shellinit_bannerinit_gui_pylabinit_extensions	init_code)r&   argvr+   s     r,   r   zTerminalIPythonApp.initialize  s     	 $''224888;"F? 	24#8 	2#q1Dr-   c                     | j                             | | j        | j        | j                  | _        | j        j                            |            dS )z(initialize the InteractiveShell instance)parentprofile_dirrZ   r6   N)interactive_shell_classinstancer   rZ   r6   r5   configurablesr4   r[   s    r,   r   zTerminalIPythonApp.init_shell&  sX     1::$$($4$($4dl ; L L
 	
 ''-----r-   c                     | j         r | j        r| j                                         | j        t
          j        k    rt                       dS dS )zoptionally display the bannerN)display_bannerrv   r5   show_banner	log_levelloggingINFOrY   r[   s    r,   r   zTerminalIPythonApp.init_banner1  sK     	%4= 	%J""$$$>W\))577777))r-   c                 L    |dk    rt          j        d           d| _        dS dS )z,Replace --pylab='inline' with --pylab='auto'inlinez>'inline' not available as pylab backend, using 'auto' instead.autoN)warningswarnpylab)r&   nameoldrm   s       r,   _pylab_changedz!TerminalIPythonApp._pylab_changed8  s6    (??M . / / /DJJJ ?r-   c                 h   | j         | j                                         S | j        r5| j                            d           | j                                         d S | j                            d           | j                                         | j        j        st          j
        d           d S d S )NzStarting IPython's mainloop...zIPython not interactive...r   )rW   rX   rv   logdebugr5   mainlooprestore_term_titlelast_execution_succeededsysexitr[   s    r,   rX   zTerminalIPythonApp.start?  s    ;";$$&&&= 	HNN;<<<J!!!!!HNN7888J))+++:6  r-   rE   )*r>   r?   r@   r   r   cl_usager\   r    crash_handler_class	_examplesexamplesflagsaliasesr   rf   r   objectr   tagr   r   rh   r]   rT   r^   r   auto_createrP   r   rt   r   rQ   rw   r}   r|   r   r   r   r   r   rX   rB   rC   s   @r,   rO   rO      su       D.K+HEGdffG"d.k   
cc	  WY
 
 
  $

 :(

  K  $t**...--K DQ  	cc 
 WW: : : T$A  	cc  T%   
cc	 
 W! ! ! W]M?;;& & <;& T%[[     &	. 	. 	.3 3 3           r-   c                     | t                      } t          j                            | d          }t	                      }|j                            |           |                                 |j        S )zhLoad the default config file from the default ipython_dir.

    This is useful for embedded shells.
    Nprofile_default)	r   ospathr8   rO   config_file_pathsr4   rq   re   )rZ   r   r'   s      r,   load_default_configr   L  sg    
 %''',,{,=>>K


C  ---:r-   rE   )FrA   r   r   r   r   traitlets.config.loaderr   traitlets.config.applicationr   r   IPython.corer   r   IPython.core.completerr   IPython.core.crashhandlerr	   IPython.core.formattersr
   IPython.core.historyr   IPython.core.applicationr   r   r   r   IPython.core.magicr   IPython.core.magicsr   r   IPython.core.shellappr   r   r   IPython.extensions.storemagicr   interactiveshellr   IPython.pathsr   	traitletsr   r   r   r   r   r   r    r]   r   rG   rF   addflagclassic_configInteractiveShell
cache_sizepprintprompts_classseparate_inseparate_outseparate_out2colorsxmoder   rT   rO   r   launch_instancelaunch_new_instancer_   r-   r,   <module>r      s     				 



  * * * * * * I I I I I I I I                   . . . . . . 2 2 2 2 2 2 6 6 6 6 6 6 / / / / / /            - , , , , ,                 6 5 5 5 5 5 6 6 6 6 6 6 ) ) ) ) ) )             	$       B 	Z [   
B
B E;<   A7;  
 517   ?= *	   	)*)	   ;-.   -.  *+0 ! (-  ' 5 /1  +/1  ,02  -)2  &(/  % @y  Wt,-0w  -56s  ^   
$|

 }   $ $ $ $ $- $ $ $O O O O O/1D O O Ob    )8   r-   