o
    tf                     @   s  d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	m
Z
 ddlmZmZmZ ddlmZmZmZ ddlmZ dd	lmZ d
ZeeZee ee
dddd eeZee ee Zee ZG dd deeZ e j! Z"Z#e$dkre"  dS dS )z A minimal application using the ZMQ-based terminal IPython frontend.

This is not a complete console app, as subprocess will not be able to receive
input, there is no real readline support, among other limitations.
    )print_functionN)DictAny)catch_config_errorboolean_flag)
JupyterAppbase_aliases
base_flags)JupyterConsoleAppapp_aliases	app_flags)ZMQTerminalInteractiveShell)__version__zs
jupyter console # start the ZMQ-based console
jupyter console --existing # connect to an existing ipython session
zsimple-promptz)ZMQTerminalInteractiveShell.simple_promptz-Force simple minimal prompt using `raw_input`z1Use a rich interactive prompt with prompt_toolkitc                       s   e Zd ZdZeZ	 dZeZe	ge
j ZeeZeeZeeZeeZe ZdZd fdd	Zdd Zd	d
 Zdd Zed fdd	Zdd Z fddZ  ZS )ZMQTerminalIPythonAppzjupyter-consolea  
        The Jupyter terminal-based Console.

        This launches a Console application inside a terminal.

        The Console supports various extra features beyond the traditional
        single-process Terminal IPython shell, such as connecting to an
        existing ipython session, via:

            jupyter console --existing

        where the previous session could have been created by another ipython
        console, an ipython qtconsole, or by opening an ipython notebook.

    TNc                    s    t t| | | | j d S N)superr   parse_command_lineZbuild_kernel_argv
extra_argsselfargv	__class__ \/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyter_console/app.pyr   b   s   z(ZMQTerminalIPythonApp.parse_command_linec                 C   sD   t |  ttj| j tj| | j| j| j	d| _
| j | j
_d S )N)parentmanagerclientconfirm_exit)r
   
initializesignalSIGINThandle_sigintr   instancekernel_managerZkernel_clientr   shellexistingZ
own_kernelr   r   r   r   
init_shellf   s   
z ZMQTerminalIPythonApp.init_shellc                 C   s   d S r   r   r'   r   r   r   init_gui_pylabq   s   z$ZMQTerminalIPythonApp.init_gui_pylabc                 G   s2   | j jr| jr| j  d S tdtjd d S t)Nz0ERROR: Cannot interrupt kernels we didn't start.)file)r%   Z
_executingr$   Zinterrupt_kernelprintsysstderrKeyboardInterrupt)r   argsr   r   r   r"   u   s   
z#ZMQTerminalIPythonApp.handle_sigintc                    s.   t t| | | jrdS |   |   dS )z8Do actions after construct, but before starting the app.N)r   r   r   Z_dispatchingr(   init_bannerr   r   r   r   r      s
   z ZMQTerminalIPythonApp.initializec                 C   s   | j   dS )zoptionally display the bannerN)r%   Zshow_bannerr'   r   r   r   r0      s   z!ZMQTerminalIPythonApp.init_bannerc                    s(   t t|   | jd | j  d S )Nz(Starting the jupyter console mainloop...)r   r   startlogdebugr%   Zmainloopr'   r   r   r   r1      s   zZMQTerminalIPythonApp.startr   )__name__
__module____qualname__namer   versiondescription	_examplesZexamplesr   r
   classesr   flagsaliasesr   frontend_aliasesfrontend_flagssubcommandsZforce_interactr   r(   r)   r"   r   r   r0   r1   __classcell__r   r   r   r   r   B   s*    
r   __main__)%__doc__
__future__r   r    r,   Z	traitletsr   r   Ztraitlets.configr   r   Zjupyter_core.applicationr   r   r	   Zjupyter_client.consoleappr
   r   r   Zjupyter_console.ptshellr   Zjupyter_consoler   r:   dictr<   updater=   setkeysr>   r?   r   Zlaunch_instancemainZlaunch_new_instancer4   r   r   r   r   <module>   s6    	



U
