U
    -ew0                     @   sd  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 ZBdAd>d?ZCeBjDZEeFd@kr`eE  dS )Bzp
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   authorauthor_emailsuperr   __init__)selfappZcontact_namecontact_emailZbug_tracker	__class__ W/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/IPython/terminal/ipapp.pyr"   C   s    
   zIPAppCrashHandler.__init__c                    s|   | j }tt| |g}|j}zF||d  | jjjd D ]}|| q:|d || jjjd  W n   Y nX 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,   K   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>d       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 k	r| j  S t| j d S r9   )subappstartprintipython_dirr#   r(   r(   r)   rF      s    

zLocateIPythonApp.startN)r4   r5   r6   descriptiondictsubcommandsrF   r(   r(   r(   r)   rC      s
   rC   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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   rI   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.)rD   ZkernelZlocatehistoryFz>Start IPython quickly by skipping the loading of config files.)rP   r@   c                 C   s   |d rdd | _ d S )Nnewc                  _   s   d S r9   r(   )akwr(   r(   r)   r=      r>   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.rA   c                 C   s   |d rd| _ d S )NrU   T)interactrY   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 )NrU   TF)something_to_runrA   r\   )r#   rZ   rU   r(   r(   r)   _file_to_run_changed   s
    
z'TerminalIPythonApp._file_to_run_changedNc                    sj   t t| | | jdk	rdS | jr6| js6| jd | _|   |   | 	  | 
  |   |   dS )z8Do actions after construct, but before starting the app.Nr   )r!   r?   
initializerE   
extra_argsr_   r^   Z	init_path
init_shellinit_bannerZinit_gui_pylabZinit_extensionsZ	init_code)r#   argvr&   r(   r)   ra     s    
zTerminalIPythonApp.initializec                 C   s.   | j j| | j| j| jd| _| jj|  dS )z(initialize the InteractiveShell instance)parentprofile_dirrH   r/   N)interactive_shell_classinstancerg   rH   r/   r.   Zconfigurablesr-   rI   r(   r(   r)   rc     s     zTerminalIPythonApp.init_shellc                 C   s,   | j r| jr| j  | jtjkr(t  dS )zoptionally display the bannerN)display_bannerr\   r.   Zshow_banner	log_levelloggingINFOrG   rI   r(   r(   r)   rd   *  s    
 zTerminalIPythonApp.init_bannerc                 C   s   |dkrt d d| _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oldrU   r(   r(   r)   _pylab_changed1  s    
z!TerminalIPythonApp._pylab_changedc                 C   s^   | j d k	r| j  S | jr2| jd | j  n(| jd | j  | jjsZt	
d d S )NzStarting IPython's mainloop...zIPython not interactive...r   )rE   rF   r\   logdebugr.   ZmainloopZrestore_term_titleZlast_execution_succeededsysexitrI   r(   r(   r)   rF   8  s    


zTerminalIPythonApp.start)N)*r4   r5   r6   rr   r   Zcl_usagerJ   r   Zcrash_handler_class	_examplesZexamplesflagsaliasesr   rR   r   objectr   tagrh   r   rS   rK   rC   rL   r   Zauto_creater@   r   r[   rj   rA   r]   r`   r_   r   ra   rc   rd   rt   rF   r8   r(   r(   r&   r)   r?      sj   




c                 C   s<   | dk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pathr0   r?   Zconfig_file_pathsr-   rX   rQ   )rH   rg   r$   r(   r(   r)   load_default_configE  s    r   __main__)N)Gr7   rl   r~   rw   rp   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   ry   r   rK   rz   r;   r:   ZaddflagZclassic_configZInteractiveShellZ
cache_sizepprintZprompts_classZseparate_inZseparate_outZseparate_out2colorsZxmoder{   rC   r?   r   Zlaunch_instanceZlaunch_new_instancer4   r(   r(   r(   r)   <module>   s   	!




 

