o
    Zh>0                     @   sT  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 deZ0e1eZ2e23e! i Z4dd Z5e5dddd e5dddd  e5d!d"d#d$ e5d%d&d'd( e5d)d*d+d, e Z6de6j7_8d-e6j_9d.e6j&_:d/e6j7_;d/e6j7_<d/e6j7_=d0e6j7_>d1e6j7_?e6d2fe4d3< d4d5d6iid7fe4d5< d4d8d6iid9fe4d:< e23e4 e1eZ@e@3e" G d;d< d<eZAG d=d4 d4ee ZBd@d>d?ZCeBjDZEdS )Azp
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                       s,   e Zd ZdZ fddZ fddZ  ZS )IPAppCrashHandlerzDsys.excepthook for IPython itself, leaves a detailed report on disk.c                    s*   t j}t j}d}tt| |||| d S )Nz)https://github.com/ipython/ipython/issues)r   ZauthorZauthor_emailsuperr   __init__)selfappZcontact_nameZcontact_emailZbug_tracker	__class__ M/var/www/html/lang_env/lib/python3.10/site-packages/IPython/terminal/ipapp.pyr    B   s   
zIPAppCrashHandler.__init__c                    sx   | j }tt| |g}|j}z#||d  | jjjd D ]}|| q|d || jjjd  W n   Y d	|S )z*Return a string containing a crash report.zHistory of session input:Z_ihz7
*** Last line of input (may not be in above history):

 )
Zsection_sepr   r   make_reportappendr"   shelluser_nsZ_last_input_linejoin)r!   	tracebackZsec_sepreportZrpt_addliner#   r%   r&   r)   J   s   

zIPAppCrashHandler.make_report)__name__
__module____qualname____doc__r    r)   __classcell__r%   r%   r#   r&   r   ?   s    r   c                  G   s   t t|  S N)frontend_flagsupdater   )argsr%   r%   r&   <lambda>c   s    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_toolkitZ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.ClassicPromptsr(   ZNoColorZPlainz:Gives IPython a similar feel to the classic Python prompt.Z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                   @   s"   e Zd ZdZeddZd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                 C   s"   | j d ur
| j  S t| j d S r6   )subappstartprintipython_dirr!   r%   r%   r&   rB      s   

zLocateIPythonApp.startN)r1   r2   r3   descriptiondictsubcommandsrB   r%   r%   r%   r&   r?      s    r?   c                       s&  e Zd ZdZejZeZe	Z
eZeZe ZeeeddjddZeddd Zed	d
dejfddZedjddZedddjddZeddd ZedddjddZedddjddZeddd Z eddddd Z!edZ"e#d) fdd 	Z$d!d" Z%d#d$ Z&d%d& Z'd'd( Z(  Z)S )*r;   ipythonz\Class to use to instantiate the TerminalInteractiveShell object. Useful for custom Frontends)klassdefault_valuehelpT)configclassesc                 C   s   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   rE   r%   r%   r&   _classes_default   s   z#TerminalIPythonApp._classes_default)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.)r@   ZkernelZlocatehistoryFz>Start IPython quickly by skipping the loading of config files.)rL   r<   c                 C   s   |d rdd | _ d S d S )Nnewc                  _   s   d S r6   r%   )akwr%   r%   r&   r:      s    z3TerminalIPythonApp._quick_changed.<locals>.<lambda>)load_config_filer!   changer%   r%   r&   _quick_changed   s   z!TerminalIPythonApp._quick_changedz2Whether 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.r=   c                 C   s   |d r	d| _ d S d S )NrQ   T)interactrU   r%   r%   r&   _force_interact_changed   s   
z*TerminalIPythonApp._force_interact_changedfile_to_runZcode_to_runZmodule_to_runc                 C   s.   |d }|r	d| _ |r| jsd| _d S d S d S )NrQ   TF)something_to_runr=   rX   )r!   rV   rQ   r%   r%   r&   _file_to_run_changed   s   

z'TerminalIPythonApp._file_to_run_changedNc                    sj   t t| | | jdurdS | jr| js| jd | _|   |   | 	  | 
  |   |   dS )z8Do actions after construct, but before starting the app.Nr   )r   r;   
initializerA   
extra_argsr[   rZ   Z	init_path
init_shellinit_bannerZinit_gui_pylabZinit_extensionsZ	init_code)r!   argvr#   r%   r&   r]   
  s   
zTerminalIPythonApp.initializec                 C   s.   | j j| | j| j| jd| _| jj|  dS )z(initialize the InteractiveShell instance)parentprofile_dirrD   r,   N)interactive_shell_classinstancerc   rD   r,   r+   Zconfigurablesr*   rE   r%   r%   r&   r_     s
   zTerminalIPythonApp.init_shellc                 C   s0   | j r| jr| j  | jtjkrt  dS dS )zoptionally display the bannerN)display_bannerrX   r+   Zshow_banner	log_levelloggingINFOrC   rE   r%   r%   r&   r`   )  s   
zTerminalIPythonApp.init_bannerc                 C   s    |dkrt 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warnZpylab)r!   nameoldrQ   r%   r%   r&   _pylab_changed0  s   

z!TerminalIPythonApp._pylab_changedc                 C   sd   | j d ur
| j  S | jr| jd | j  d S | jd | j  | jjs0t	
d d S d S )NzStarting IPython's mainloop...zIPython not interactive...r   )rA   rB   rX   logdebugr+   ZmainloopZrestore_term_titleZlast_execution_succeededsysexitrE   r%   r%   r&   rB   7  s   


zTerminalIPythonApp.startr6   )*r1   r2   r3   rn   r   Zcl_usagerF   r   Zcrash_handler_class	_examplesZexamplesflagsaliasesr   rN   r   objectr   tagrd   r   rO   rG   r?   rH   r   Zauto_creater<   r   rW   rf   r=   rY   r\   r[   r   r]   r_   r`   rp   rB   r5   r%   r%   r#   r&   r;      sl    




c                 C   s<   | du rt  } tj| d}t }|j| |  |jS )zhLoad the default config file from the default ipython_dir.

    This is useful for embedded shells.
    NZprofile_default)	r   ospathr-   r;   Zconfig_file_pathsr*   rT   rM   )rD   rc   r"   r%   r%   r&   load_default_configD  s   r|   r6   )Fr4   rh   rz   rs   rl   Ztraitlets.config.loaderr   Ztraitlets.config.applicationr   r   ZIPython.corer   r   ZIPython.core.completerr   ZIPython.core.crashhandlerr   IPython.core.formattersr	   ZIPython.core.historyr
   ZIPython.core.applicationr   r   r   r   ZIPython.core.magicr   ZIPython.core.magicsr   r   ZIPython.core.shellappr   r   r   ZIPython.extensions.storemagicr   Zinteractiveshellr   ZIPython.pathsr   Z	traitletsr   r   r   r   r   ru   r   rG   rv   r8   r7   ZaddflagZclassic_configZInteractiveShellZ
cache_sizepprintZprompts_classZseparate_inZseparate_outZseparate_out2colorsZxmoderw   r?   r;   r|   Zlaunch_instanceZlaunch_new_instancer%   r%   r%   r&   <module>   s   	!




 

