
    Xh                        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j5                  e       ej5                   e
dddd              ee      Zej5                  e        e ej:                               Z e ej:                               Z G d dee      Z e jB                  xZ"Z#e$dk(  r e"        yy)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.

    Tc                 b    t         t        |   |       | j                  | j                         y N)superr   parse_command_linebuild_kernel_argv
extra_argsselfargv	__class__s     G/var/www/html/myenv/lib/python3.12/site-packages/jupyter_console/app.pyr   z(ZMQTerminalIPythonApp.parse_command_lineb   s%    #T=dCt/    c                 :   t        j                  |        t        j                  t        j                  | j                         t        j                  | | j                  | j                  | j                        | _
        | j                   | j                  _        y )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   sl    $$T*fmmT%7%78099 $ 3 3#11%)%6%6


 %)MM 1

r   c                      y r    r-   s    r   init_gui_pylabz$ZMQTerminalIPythonApp.init_gui_pylabq   s    r   c                     | j                   j                  rC| j                  r| j                  j                          y t	        dt
        j                         y 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   sD    ::  ""##446H ZZ)
 $#r   c                     t         t        |   |       | j                  ry| j	                          | j                          y)z8Do actions after construct, but before starting the app.N)r   r   r#   _dispatchingr.   init_bannerr   s     r   r#   z ZMQTerminalIPythonApp.initialize   s7     	#T5d;r   c                 8    | j                   j                          y)zoptionally display the bannerN)r*   show_bannerr-   s    r   r=   z!ZMQTerminalIPythonApp.init_banner   s    

 r   c                     t         t        |           | j                  j	                  d       | j
                  j                          y )Nz(Starting the jupyter console mainloop...)r   r   startlogdebugr*   mainloop)r   r   s    r   rA   zZMQTerminalIPythonApp.start   s2    #T02A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   s    DG>K H*+.?.G.GGGKE7mG+,(N&KN0	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  @ '	 	Z Y  \@37  |
 { '{'')* ^Y^^%&RJ(9 Rj 3BB B zF r   