
    ;;i0                        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+        e5d,d-d.d/        e       Z6de6jn                  _8        d0e6j$                  _9        d1e6jL                  _:        d2e6jn                  _;        d2e6jn                  _<        d2e6jn                  _=        d3e6jn                  _>        d4e6jn                  _?        e6d5fe4d6<   d7d8d9iid:fe4d8<   d7d;d9iid<fe4d=<   e2jg                  e4        e1e      Z@e@jg                  e"        G d> d?e      ZA G d@ d7ee       ZBdBdAZCeBj                  ZEy)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                 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        S/home/rose/Desktop/poly/venv/lib/python3.12/site-packages/IPython/terminal/ipapp.pyr%   zIPAppCrashHandler.__init__B   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_reportJ   s     "")4<YGH--	G778..u5 6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   c   s    --lD.ABr-   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                   (    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,   rX   zLocateIPythonApp.start   s-    ;;";;$$&&$""#r-   N)r>   r?   r@   descriptiondictsubcommandsrX    r-   r,   rT   rT      s    9K
K
$r-   rT   c                   2    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      j%                  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 ) 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   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.)rU   kernellocatehistoryFz>Start IPython quickly by skipping the loading of config files.)rd   rP   c                      |d   r	d | _         y y )Nnewc                       y rE   r_   )akws     r,   rI   z3TerminalIPythonApp._quick_changed.<locals>.<lambda>   s    Tr-   )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.rQ   c                     |d   rd| _         y y )Nrm   T)interactrr   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 )Nrm   TF)something_to_runrQ   rv   )r&   rs   rm   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$   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     	 $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_dirrZ   r6   N)interactive_shell_classinstancer   rZ   r6   r5   configurablesr4   r[   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_bannerrv   r5   show_banner	log_levelloggingINFOrY   r[   s    r,   r   zTerminalIPythonApp.init_banner1  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oldrm   s       r,   _pylab_changedz!TerminalIPythonApp._pylab_changed8  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   )rW   rX   rv   logdebugr5   mainlooprestore_term_titlelast_execution_succeededsysexitr[   s    r,   rX   zTerminalIPythonApp.start?  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   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      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   rO   config_file_pathsr4   rq   re   )rZ   r   r'   s      r,   load_default_configr   L  sY    
 %''',,{,=>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      sC    	 
  * I    . 2 6 /  -  6 6 ) 	$ B 	Z [ 
B E;< A7;
 517 ?= *	 	)*)	 ;-. -.   *+0 ! ! (-  ' ' 5 /1   +/1   ,02   -)2   &(/   % @y  Wt,-0w  -56s  ^ 
|
 } $- $O/1D Ob )88 r-   