
    fw0                        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      Z2e2jg                  e!       i Z4d Z5 e5dddd        e5dddd        e5d d!d"d#        e5d$d%d&d'        e5d(d)d*d+        e       Z6de6jn                  _8        d,e6j$                  _9        d-e6jL                  _:        d.e6jn                  _;        d.e6jn                  _<        d.e6jn                  _=        d/e6jn                  _>        d0e6jn                  _?        e6d1fe4d2<   d3d4d5iid6fe4d4<   d3d7d5iid8fe4d9<   e2jg                  e4        e1e      Z@e@jg                  e"        G d: d;e      ZA G d< d3ee       ZBd?d=ZCeBj                  ZEeFd>k(  r eE        yy)@zp
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                 v    t         j                  }t         j                  }d}t        t        |   ||||       y )Nz)https://github.com/ipython/ipython/issues)r   authorauthor_emailsuperr    __init__)selfappcontact_namecontact_emailbug_tracker	__class__s        Q/var/www/cvtools/html/venv/lib/python3.12/site-packages/IPython/terminal/ipapp.pyr%   zIPAppCrashHandler.__init__C   s5    ~~,,A.}k	
    c                 f   | j                   }t        t        |   |      g}|j                  }	  ||dz          | j
                  j                  j                  d   D ]
  } ||         |d        || j
                  j                  j                  dz          dj                  |      S #  Y xY w)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_reportK   s     "")4<YGH--	G778..u5 OPDHHNN33D89 wwv	s   A,B, ,B0)__name__
__module____qualname____doc__r%   r3   __classcell__r+   s   @r,   r    r    @   s    N
 r-   r    c                  8    t         j                  t        |        S N)frontend_flagsupdater   )argss    r,   <lambda>rI   d   s    --lD.A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.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                   (    e Zd ZdZ ed      Zd Zy)LocateIPythonAppz!print the path to the IPython dir)z%IPython.core.profileapp.ProfileLocatez.print the path to an IPython profile directory)profilec                 z    | j                   | j                   j                         S t        | j                         y rE   )subappstartprintipython_dirr&   s    r,   rW   zLocateIPythonApp.start   s-    ;;";;$$&&$""#r-   N)r>   r?   r@   descriptiondictsubcommandsrW    r-   r,   rS   rS      s    9K
K
$r-   rS   c                       e Zd ZdZej
                  ZeZe	Z
eZeZ e       Z eeed      j%                  d      Z ed      d        Z edd	d
ej                  fd      Z ed      Z edd      j%                  d      Z ed      d        Z edd      j%                  d      Z edd      j%                  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 ) rN   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   rZ   s    r,   _classes_defaultz#TerminalIPythonApp._classes_default   s3      NN$
 	
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.)rT   kernellocatehistoryFz>Start IPython quickly by skipping the loading of config files.)rc   rO   c                      |d   r	d | _         y y )Nnewc                       y rE   r^   )akws     r,   rI   z3TerminalIPythonApp._quick_changed.<locals>.<lambda>   s    r-   )load_config_filer&   changes     r,   _quick_changedz!TerminalIPythonApp._quick_changed   s    %=$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.rP   c                     |d   rd| _         y y )Nrl   T)interactrq   s     r,   _force_interact_changedz*TerminalIPythonApp._force_interact_changed   s    %= DM r-   file_to_runcode_to_runmodule_to_runc                 N    |d   }|rd| _         |r| j                  sd| _        y y y )Nrl   TF)something_to_runrP   ru   )r&   rr   rl   s      r,   _file_to_run_changedz'TerminalIPythonApp._file_to_run_changed   s/    Um$(D!t** % +3r-   c                 ^   t         t        |   |       | j                  y| j                  r | j
                  s| j                  d   | _        | j                          | j                          | j                          | j                          | j                          | j                          y)z8Do actions after construct, but before starting the app.Nr   )r$   rN   
initializerV   
extra_argsr{   rw   	init_path
init_shellinit_bannerinit_gui_pylabinit_extensions	init_code)r&   argvr+   s     r,   r~   zTerminalIPythonApp.initialize  s     	 $248;;"??4#8#8#q1Dr-   c                     | j                   j                  | | j                  | j                  | j                        | _        | j
                  j                  j                  |        y)z(initialize the InteractiveShell instance)parentprofile_dirrY   r6   N)interactive_shell_classinstancer   rY   r6   r5   configurablesr4   rZ   s    r,   r   zTerminalIPythonApp.init_shell  sV     11::$$($4$4$($4$4dll ; L
 	

  ''-r-   c                     | j                   r&| j                  r| j                  j                          | j                  t
        j                  k  rt                yy)zoptionally display the bannerN)display_bannerru   r5   show_banner	log_levelloggingINFOrX   rZ   s    r,   r   zTerminalIPythonApp.init_banner*  s8    4==JJ""$>>W\\)57)r-   c                 H    |dk(  rt        j                  d       d| _        yy)z,Replace --pylab='inline' with --pylab='auto'inlinez>'inline' not available as pylab backend, using 'auto' instead.autoN)warningswarnpylab)r&   nameoldrl   s       r,   _pylab_changedz!TerminalIPythonApp._pylab_changed1  s&    (?MM . /DJ r-   c                    | j                   | j                   j                         S | j                  r6| j                  j	                  d       | j
                  j                          y | j                  j	                  d       | j
                  j                          | j
                  j                  st        j                  d       y y )NzStarting IPython's mainloop...zIPython not interactive...r   )rV   rW   ru   logdebugr5   mainlooprestore_term_titlelast_execution_succeededsysexitrZ   s    r,   rW   zTerminalIPythonApp.start8  s    ;;";;$$&&==HHNN;<JJ!HHNN78JJ))+::66 7r-   rE   )*r>   r?   r@   r   r   cl_usager[   r    crash_handler_class	_examplesexamplesflagsaliasesr   re   r   objectr   tagr   r   rg   r\   rS   r]   r   auto_createrO   r   rs   r   rP   rv   r|   r{   r   r~   r   r   r   rW   rB   rC   s   @r,   rN   rN      s   D..K+HEGfG".k 
cc	  Y
 
  

 :((

K" T
KQ	cc 
 W: : $A	cc  % 
cc	 
 ! ! ]M?;& <& %[ &	.3 r-   c                     | 
t               } t        j                  j                  | d      }t	               }|j
                  j                  |       |j                          |j                  S )zhLoad the default config file from the default ipython_dir.

    This is useful for embedded shells.
    profile_default)	r   ospathr8   rN   config_file_pathsr4   rp   rd   )rY   r   r'   s      r,   load_default_configr   E  sY    
 %''',,{,=>K

C  -::r-   __main__rE   )GrA   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   rS   rN   r   launch_instancelaunch_new_instancer>   r^   r-   r,   <module>r      s=    	 
  * I    . 2 6 /  -  6 6 ) 	$ B 	Z [ 
B E;< A7;
 517 ?= *	 ;-. -.   *+0 ! ! (6_ ' ' 5.0   +/1   ,02   -)2   &(/   % @y  Wt,-0w  -56s  ^ 
|
 } $- $O/1D Ob )88  z r-   