
    "d                         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j                              Z e ej                              Z G d dee          Z e j!        xZ"Z#e$dk    r e"             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                        e Zd ZdZeZ	 dZeZe	ge
j        z   Z ee          Z ee          Z ee          Z ee          Z e            ZdZd fd	Zd Zd Zd Zed fd		            Zd
 Z fdZ x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                     t          t          |                               |           |                     | j                   d S N)superr   parse_command_linebuild_kernel_argv
extra_argsselfargv	__class__s     3lib/python3.11/site-packages/jupyter_console/app.pyr   z(ZMQTerminalIPythonApp.parse_command_lineb   s>    #T**==dCCCt/////    c                     t          j        |            t          j        t          j        | j                   t          j        | | j        | j        | j	                  | _
        | j         | j
        _        d S )N)parentmanagerclientconfirm_exit)r   
initializesignalSIGINThandle_sigintr   instancekernel_managerkernel_clientr"   shellexisting
own_kernelr   s    r   
init_shellz ZMQTerminalIPythonApp.init_shellf   sn    $T***fmT%788809 $ 3#1%)%6
 
 


 %)M 1
r   c                     d S r    r-   s    r   init_gui_pylabz$ZMQTerminalIPythonApp.init_gui_pylabq   s    r   c                     | j         j        r?| j        r| j                                         d S t	          dt
          j                   d S t          )Nz0ERROR: Cannot interrupt kernels we didn't start.)file)r*   
_executingr(   interrupt_kernelprintsysstderrKeyboardInterrupt)r   argss     r   r&   z#ZMQTerminalIPythonApp.handle_sigintu   sf    :  		$" )#4466666H Z) ) ) ) ) )
 $#r   c                     t          t          |                               |           | j        rdS |                                  |                                  dS )z8Do actions after construct, but before starting the app.N)r   r   r#   _dispatchingr.   init_bannerr   s     r   r#   z ZMQTerminalIPythonApp.initialize   s\     	#T**55d;;; 	Fr   c                 8    | j                                          dS )zoptionally display the bannerN)r*   show_bannerr-   s    r   r=   z!ZMQTerminalIPythonApp.init_banner   s    
     r   c                     t          t          |                                            | j                            d           | j                                         d S )Nz(Starting the jupyter console mainloop...)r   r   startlogdebugr*   mainloop)r   r   s    r   rA   zZMQTerminalIPythonApp.start   sO    #T**00222ABBB
r   r   )__name__
__module____qualname__namer   versiondescription	_examplesexamplesr   r   classesr   flagsaliasesr   frontend_aliasesfrontend_flagssubcommandsforce_interactr   r.   r1   r&   r   r#   r=   rA   __classcell__)r   s   @r   r   r   B   s3       DG>K H*+.?.GGGDKKEd7mmGs+,,S((N$&&KN0 0 0 0 0 0	2 	2 	2  
$ 
$ 
$      ! ! !        r   r   __main__)%__doc__
__future__r   r$   r7   	traitletsr   r   traitlets.configr   r   jupyter_core.applicationr   r	   r
   jupyter_client.consoleappr   r   r   jupyter_console.ptshellr   jupyter_consoler   rK   dictrN   updaterO   setkeysrP   rQ   r   launch_instancemainlaunch_new_instancerE   r0   r   r   <module>re      s    & % % % % %  



        > = = = = = = = I I I I I I I I I I          @ ? ? ? ? ? ' ' ' ' ' '	 	Z Y    \\@37     $|

 {   3'{'))** ^Y^%%&&R R R R RJ(9 R R Rj 3B B zDFFFFF r   