o
    û›h>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ƒZ2e2 3e!¡ 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:< e2 3e4¡ 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   ÚauthorZauthor_emailÚsuperr   Ú__init__)ÚselfÚappZcontact_nameZcontact_emailZbug_tracker©Ú	__class__© úLc:\Users\shubh\Videos\agent\nova\Lib\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_exitzÂSet 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_interactz¬If 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 r7   )ÚsubappÚstartÚprintÚipython_dir©r"   r&   r&   r'   rC   ¬   s   

zLocateIPythonApp.startN)r2   r3   r4   ÚdescriptionÚdictÚsubcommandsrC   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   rF   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.)rA   ZkernelZlocateÚhistoryFz>Start IPython quickly by skipping the loading of config files.)rM   r=   c                 C   s   |d rdd„ | _ d S d S )NÚnewc                  _   s   d S r7   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.zšIf 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 )NrR   T)ÚinteractrV   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 )NrR   TF)Úsomething_to_runr>   rY   )r"   rW   rR   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<   Ú
initializerB   Ú
extra_argsr\   r[   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_dirrE   r-   N)Úinteractive_shell_classÚinstancerd   rE   r-   r,   Zconfigurablesr+   rF   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_bannerrY   r,   Zshow_bannerÚ	log_levelÚloggingÚINFOrD   rF   r&   r&   r'   ra   )  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ÚoldrR   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   )rB   rC   rY   ÚlogÚdebugr,   ZmainloopZrestore_term_titleZlast_execution_succeededÚsysÚexitrF   r&   r&   r'   rC   7  s   


ÿzTerminalIPythonApp.startr7   )*r2   r3   r4   ro   r   Zcl_usagerG   r   Zcrash_handler_classÚ	_examplesZexamplesÚflagsÚaliasesr   rO   r   Úobjectr   Útagre   r   rP   rH   r@   rI   r   Zauto_creater=   r   rX   rg   r>   rZ   r]   r\   r   r^   r`   ra   rq   rC   r6   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+   rU   rN   )rE   rd   r#   r&   r&   r'   Úload_default_configD  s   r}   r7   )Fr5   ri   r{   rt   rm   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   rv   r   rH   rw   r9   r8   ZaddflagZclassic_configZInteractiveShellZ
cache_sizeÚpprintZprompts_classZseparate_inZseparate_outZseparate_out2ÚcolorsZxmoderx   r@   r<   r}   Zlaunch_instanceZlaunch_new_instancer&   r&   r&   r'   Ú<module>   s’   	!
þþþüþþ
þ
þ

 

