
    Mhq                    ~   d Z ddlmZ ddlZddlZddlZddl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ZddlmZmZmZmZ dd	lmZ dd
lmZmZmZ ddl 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+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddlEmFZFmGZG ddlHmIZI  eJe          ZKeKL                    dddddd d!d"d#            eJe          ZMeML                    d$d%d&iid'fd$d(d&iid)fd$d*d+iid,fd-d.d/iid0fd1           eKL                    e           eML                    e           eKL                    e$           eML                    e%           d2ZN G d3 d$eee!          ZOeOjP        ZQd4 ZReSd5k    r eR             dS dS )6z%An Application for launching a kernel    )annotationsN)partial)FileIOTextIOWrapper)StreamHandler)Path)BaseIPythonApplicationbase_aliases
base_flagscatch_config_error)
ProfileDir)InteractiveShellAppshell_aliasesshell_flags)ConnectionFileMixin)Sessionsession_aliasessession_flagsjupyter_runtime_dir)ioloop)	AnyBoolDictDottedObjectNameInstanceIntegerTypeUnicodedefault)filefind)import_item)	ZMQStream   )get_connection_infowrite_connection_file)ControlThread)	Heartbeat)IOPubThread)IPythonKernel)ParentPollerUnixParentPollerWindows)ZMQInteractiveShellzIPKernelApp.ipzIPKernelApp.hb_portzIPKernelApp.shell_portzIPKernelApp.iopub_portzIPKernelApp.stdin_portzIPKernelApp.control_portzIPKernelApp.connection_filezIPKernelApp.transport)iphbshelliopubstdincontrolf	transportIPKernelApp	no_stdoutT"redirect stdout to the null device	no_stderr"redirect stderr to the null devicepylabautoz^Pre-load matplotlib and numpy for interactive use with
        the default matplotlib backend.InteractiveShell	trio_loopFzEnable Trio as main event loop.)z	no-stdoutz	no-stderrr;   z	trio-loopa#  NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049

c                      e Zd ZU dZdZ ee          Z ee          Z	e
eeegZ eddd                              d          Z e            Z e            Z eed	          Z e            Zd
ed<    e            Z e            Z e            Z e            Z e            Z e            Z e            Z  e            Z! e            Z"ddiZ# e$            Z% e&d          d             Z'e(d             Z) e*dd                              d          Z+ e*dd                              d          Z, e*dd                              d          Z- e*dd                              d          Z. e/ddd                              d          Z0 e/dd                              d          Z1 e*dd                              d          Z2 e3 e4e5j6        7                    d          pd          d                              d          Z8 e3 e4e5j6        7                    d           pd          d!                              d          Z9d" Z:d# Z;d$ Z<d% Z=d& Z>d' Z?d( Z@d) ZAd* ZBd+ ZCd, ZDd- ZEd. ZFd/ ZGd0 ZHd1 ZId2 ZJd3 ZKd4 ZLd5 ZMd6 ZNd7 ZOd8 ZPd9 ZQd: ZReSd> fd<	            ZTd= ZU xZVS )?r6   z The IPYKernel application class.zipython-kernelz ipykernel.ipkernel.IPythonKernelzipykernel.kernelbase.KernelzThe Kernel subclass to be used.

    This should allow easy reuse of the IPKernelApp entry point
    to configure and launch kernels other than IPython's own.
    )klasshelpT)config)
allow_nonezzmq.Context[t.Any] | Nonecontextinstall)z0ipykernel.kernelspec.InstallIPythonKernelSpecAppzInstall the IPython kernelconnection_dirc                    t                      S Nr   selfs    S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/ipykernel/kernelapp.py_default_connection_dirz#IPKernelApp._default_connection_dir   s    "$$$    c                    t          | j                  j        | j        k    r=| j        r6t	          t          t	          | j                            | j        z            S | j        S rH   )r   connection_filenamerF   strrI   s    rK   abs_connection_filezIPKernelApp.abs_connection_file   sX    $%%*d.BBBtGZBtC 344558LLMMM##rM   Fr8   )rA   r:   zSet main event loop.z(Only send stdout/stderr to output streamzipykernel.iostream.OutStreamz*The importstring for the OutStream factory)rA   rC   z$ipykernel.displayhook.ZMQDisplayHookz,The importstring for the DisplayHook factoryz[Attempt to capture and forward low-level output, e.g. produced by Extension libraries.
    JPY_PARENT_PIDr   zkill this process if its parent dies.  On Windows, the argument
        specifies the HANDLE of the parent process, otherwise it is simply boolean.
        JPY_INTERRUPT_EVENTzYONLY USED ON WINDOWS
        Interrupt this process when the parent is signaled.
        c                (    | j         t          _         dS )zInitialize the crash handler.N)
excepthooksysrI   s    rK   init_crash_handlerzIPKernelApp.init_crash_handler   s    rM   c                J    t          j        |||t          j                   dS )zHandle an exception.fileN)	tracebackprint_exceptionrW   
__stderr__)rJ   etypeevaluetbs       rK   rV   zIPKernelApp.excepthook   s&     	!%#.IIIIIIrM   c                    t           j        dk    r1| j        s| j        r!t	          | j        | j                  | _        dS dS | j        r | j        dk    rt                      | _        dS dS dS )zInitialize the poller.win32r$   N)rW   platform	interruptparent_handler,   pollerr+   rI   s    rK   init_pollerzIPKernelApp.init_poller   s    <7""~ V!3 V1$.$BTUUV V 	-D$6!$;$; +,,DKKK		- 	-$;$;rM   c                   | j          d| j         }| j         dk    r<|dk    r|                    |          }n|                    d| j        |fz             n| j         dk    r|dk    rbd}d| j        |fz  }t	          |                                          r2|dz   }d| j        |fz  }t	          |                                          2nd| j        |fz  }|                    d|z             |S )	Nz://tcpr   ztcp://%s:%iipcr$   z%s-%izipc://%s)r5   r.   bind_to_random_portbindr   exists)rJ   sportifacepaths        rK   _try_bind_socketzIPKernelApp._try_bind_socket   s   >//dg//>U""qyy,,U33}67777^u$$qyy$'404jj'')) 5!8D"dgt_4D 4jj'')) 5 $'40FF:$%%%rM   c                4   	 t           j        }n# t          $ r d }Y nw xY w|rdnd}t          |          D ]a}	 |                     ||          c S # t
          j        $ r5}|j         t           j        k    r|j         |k    r ||dz
  k    r Y d }~Zd }~ww xY wd S )Nr$   d   )errnoWSAEADDRINUSEAttributeErrorrangers   zmqZMQError
EADDRINUSE)rJ   ro   rp   
win_in_usemax_attemptsattemptzes          rK   _bind_socketzIPKernelApp._bind_socket   s    	,JJ 	 	 	JJJ	
 !)qqc\** 	 	G,,Q55555<   8u///BH
4J4JlQ... /....	 ts#    AB +BBc           
        | j         }t          | j        | j        j        | j        | j        | j        | j        | j	        | j
                  }t          |                                          rXt          |d          }t          |t                    sJ t          |fi |}||k    r| j                            d|           dS | j                            d|           t#          |fi | dS )z"write connection info to JSON file)r.   keyr5   
shell_port
stdin_porthb_port
iopub_portcontrol_portT)unpackz:Connection file %s with current information already existsNzWriting connection file: %s)rR   dictr.   sessionr   r5   r   r   r   r   r   r   rn   r%   
isinstancelogdebugr&   )rJ   cfconnection_infoexisting_connection_infos       rK   r&   z!IPKernelApp.write_connection_file  s   %w nL*	
 	
 	
 88?? 		 (;2d'K'K'K$6====="#;OOOOO":::[]_```4b999b44O44444rM   c                    | j         }| j                            d|           	 t          |                                           n# t
          $ r Y nw xY w|                                  dS )zClean up our connection file.zCleaning up connection file: %sN)rR   r   r   r   unlinkOSErrorcleanup_ipc_files)rJ   r   s     rK   cleanup_connection_filez#IPKernelApp.cleanup_connection_file"  sy    %8"===	HHOO 	 	 	D	 	     s   !A 
AAc                <   | j         sdt          j                    z  | _         	 t          | j         d| j        g          | _         ny# t
          $ rl | j                            d| j                    t          | j	                  j
                            ddd           t          j        | j                   Y dS w xY w	 |                                  dS # t           $ r; | j                            d| j         d	           |                     d
           Y dS w xY w)zInitialize our connection file.zkernel-%s.json.zConnection file not found: %si  T)modeexist_okparentsNz"Failed to load connection file: %rexc_infor$   )rO   osgetpidr!   rF   r   r   r   r   rR   parentmkdiratexitregisterr   load_connection_file	ExceptionerrorexitrI   s    rK   init_connection_filez IPKernelApp.init_connection_file-  s6   # 	B#3bikk#AD 	#+D,@3H[B\#]#]D   	 	 	HNN:D<PQQQ)**177UT[_7```OD8999FF		%%''''' 	 	 	HNN4d6JUY     IIaLLLLLL		s%   !A A2B<;B< C ADDc                p   | j                             dt          j                               | j        
J d            t          j                    x| _        }t          j        | j	                   |
                    t
          j                  | _        d| j        _        |                     | j        | j                  | _        | j                             d| j        z             |
                    t
          j                  | _        d| j        _        |                     | j        | j                  | _        | j                             d| j        z             t'          t
          d          rdx| j        _        | j        _        |                     |           |                     |           dS )	z4Create a context, a session, and the kernel sockets.zStarting the kernel at pid: %iNz$init_sockets cannot be called twice!  z shell ROUTER Channel on port: %iz stdin ROUTER Channel on port: %iROUTER_HANDOVERr$   )r   infor   r   rD   rz   Contextr   r   closesocketROUTERshell_socketlingerr   r   r   stdin_socketr   hasattrrouter_handoverinit_control
init_iopubrJ   rD   s     rK   init_socketszIPKernelApp.init_socketsB  sf   6	DDD|##%K###!$.w
####NN3:66#' ++D,=tOO9DOKLLL#NN3:66#' ++D,=tOO9DOKLLL3)** 	V UVUD-0A0Q'"""     rM   c                   |                     t          j                  | _        d| j        _        |                     | j        | j                  | _        | j                            d| j        z             |                     t          j	                  | _
        d| j
        _        |                     t          j                  | _        d| j        _        | j                            t          j                  r<| j                            | j                            t          j                             t#          t          d          rd| j        _        t'          d          | _        dS )zInitialize the control channel.r   z"control ROUTER Channel on port: %ir   r$   T)daemonN)r   rz   r   control_socketr   r   r   r   r   STREAMdebugpy_socketDEALERdebug_shell_socketr   
getsockoptLAST_ENDPOINTconnectr   r   r'   control_threadr   s     rK   r   zIPKernelApp.init_control\  s!   %nnSZ88%)" --d.A4CTUU;d>OOPPP%nnSZ88%)"").."<"<)-&''(9:: 	]#++D,=,H,HIZ,[,[\\\3)** 	4 34D/+4888rM   c                   |                     t          j                  | _        d| j        _        |                     | j        | j                  | _        | j                            d| j        z             | 	                                 t          | j        d          | _        | j                                         | j        j        | _        dS )zInitialize the iopub channel.r   ziopub PUB Channel on port: %iT)pipeN)r   rz   PUBiopub_socketr   r   r   r   r   configure_tornado_loggerr)   iopub_threadstartbackground_socketr   s     rK   r   zIPKernelApp.init_iopubs  s    #NN3733#' ++D,=tOO6HIII%%''''(9EEE!!! -?rM   c                   t          j                    }t          || j        | j        | j        f          | _        | j        j        | _        | j        	                    d| j        z             | j        
                                 dS )zstart the heart beatingz!Heartbeat REP Channel on port: %iN)rz   r   r(   r5   r.   r   	heartbeatrp   r   r   r   )rJ   hb_ctxs     rK   init_heartbeatzIPKernelApp.init_heartbeat  so     "6DNDGT\+RSS~*:T\IJJJrM   c                X   |                                   | j                            d           | j        r8| j                            d           | j        j                                         | j        rL| j                            d           | j                                         | j        	                                 | j
        re| j
                                        rL| j                            d           | j
                                         | j
                                         | j        r%| j        j        s| j        	                                 | j        r%| j        j        s| j        	                                 dD ]N}| j                            d|           t!          | |dz   d          }|r|j        s|	                                 O| j                            d	           | j        r| j                                         | j                            d
           dS )z'Close zmq sockets in an orderly fashionzCleaning up socketszClosing heartbeat channelzClosing iopub channelzClosing control thread)r0   r3   r2   zClosing %s channel_socketNzTerminating zmq contextzTerminated zmq context)reset_ior   r   r   r   rD   termr   stopr   r   is_alivejoinr   closedr   getattr)rJ   channelr   s      rK   r   zIPKernelApp.close  s	    	+,,,> 	*HNN6777N"''))) 	&HNN2333""$$$##%%% 	'4#6#?#?#A#A 	'HNN3444$$&&&$$&&& 	(t':'A 	(%%'''" 	,4+B+I 	,#))+++4 	 	GHNN/999T7Y#6==F fm 0111< 	 L/00000rM   c                B   t          | j                  j        }|| j        k    s/t          t          | j                  j                  | j        k    r|}n| j        }dd|z  g}|D ]}| j                            |           | j        sbt          | j
                  t          j        k     r@t          t          t          j                   |D ]}t          |t          j                   t#          | j        | j        | j        | j        | j                  | _        dS )z(display connection info, and store portsz.To connect another client to this kernel, use:z    --existing %srZ   )r0   r1   r2   r/   r3   N)r   rO   rP   rQ   r   rF   r   r   rf   int	log_levelloggingCRITICALprint_ctrl_c_messagerW   
__stdout__r   r   r   r   r   r   _ports)rJ   basenametaillineslines        rK   log_connection_infozIPKernelApp.log_connection_info  s&   ,--2,,,4,--4559LLL DD'D<$&
  	  	 DHMM$ ! 	1c$.&9&9G<L&L&L/7777 1 1d00000///|%
 
 
rM   c                    | j         s| j        rZt          t          j        d          }| j         r|xt
          _        t
          _        | j        r|xt
          _        t
          _	        dS dS dS )z/redirects stdout/stderr to devnull if necessarywN)
r7   r9   openr   devnullrW   stdoutr   stderrr^   )rJ   	blackholes     rK   init_blackholezIPKernelApp.init_blackhole  sn    > 	8T^ 	8RZ--I~ 8.77
S^~ 8.77
S^^^	8 	88 8rM   c                6   | j         rt          t          | j                             }t          j        t          j                                         | j        rdnt          j        }| j        rdnt          j        }| j	        st          |d          } || j        | j        d|          t          _        t          j        t          j                                          || j        | j        d|          t          _        t          t          j        d          r| j        j        D ]}t#          |t$                    rm|j        j                                        dk    rK| j                            d	           t/          t1          t          j        j        d
                    |_        | j        rMt          t          | j                            } || j        | j                  | _        | j        t          _        |                                  dS )z.Redirect input streams and set a display hook.NF)watchfdr   )echor   _original_stdstream_copy   z9Seeing logger to stderr, rerouting to raw filedescriptor.r   )outstream_classr"   rQ   rW   r   flushquietr   r^   capture_fd_outputr   r   r   r   r   r   handlersr   r   streambufferfilenor   r   r   r   displayhook_classr   displayhookpatch_io)rJ   outstream_factorye_stdoute_stderrhandlerdisplayhook_factorys         rK   init_iozIPKernelApp.init_io  s    	 +C0D,E,E F Fz%
  """#z=tts~H#z=tts~H) N$+,=u$M$M$M!**4<9JH[cdddCJz%
  """**4<9JH[cdddCJsz#=>> 
#x0 	 	G!'=99 w~?T?[?[?]?]ab?b?b'bccc)6" #
 C # * * ! 	/"-c$2H.I.I"J"J224<ARSSD".COrM   c                    t           j        t           _        t           j        t           _        t           j        t           _        dS )zBrestore original io

        restores state after init_io
        N)rW   r   r   r^   r   __displayhook__r   rI   s    rK   r   zIPKernelApp.reset_io  s$    
 ^
^
-rM   c                    	 ddl }|j        t          j        dffd	}||_        t	          |d          r#|j        t          j        ddffd	}||_        dS dS # t          $ r Y dS w xY w)zAPatch important libraries that can't handle sys.stdout forwardingr   NTc                     d| |d|S )N)r[   all_threads r  )r[   r  kwargsfaulthandler_enables      rK   enablez$IPKernelApp.patch_io.<locals>.enable  s"    **X+XXQWXXXrM   r   Fc                     | f|||d|S )N)r[   r  chainr  )signumr[   r  r  r  faulthandler_registers        rK   r   z&IPKernelApp.patch_io.<locals>.register  s4    00%){% SY  rM   )faulthandlerr  rW   r^   r   r   ImportError)rJ   r  r  r   r  r  s       @@rK   r   zIPKernelApp.patch_io  s    	1 #/"5N Y Y Y Y Y Y #)L|Z00 1(4(=%*-.dRW      
 )1%%%1 1  	 	 	DD	s   A 
A+*A+c                X    t          j         t           j        t           j                   dS )zInitialize the signal handler.N)signalSIGINTSIG_IGNrI   s    rK   init_signalzIPKernelApp.init_signal  s    fmV^44444rM   c                   t          | j                  }t          | j        | j        j                  }t          | j        | j        j                  }| j                                         | j        j        } || | j	        ||| j
        || j        | j        | j        | j        | j        | j        | j                                      d | j                                        D                        | _        fd| j        _        dS )zCreate the Kernel object itself)r   r   control_streamdebugpy_streamr   shell_streamr   r   r   r   r   profile_diruser_nsc                     i | ]\  }}|d z   |S )_portr  ).0rP   rp   s      rK   
<dictcomp>z+IPKernelApp.init_kernel.<locals>.<dictcomp>:  s"    XXXjdDTG^TXXXrM   c                      j         S rH   )execution_count)kernels   rK   <lambda>z)IPKernelApp.init_kernel.<locals>.<lambda>>  s
    v7M rM   N)r#   r   r   r   io_loopr   r   kernel_classinstancer   r   r   r   r   r   r  r   record_portsr   itemsr'  r   get_execution_count)rJ   r  r  r  kernel_factoryr'  s        @rK   init_kernelzIPKernelApp.init_kernel#  s    !233"4#68K8STT"4#68K8STT!!###*3L))#6%.***(L
 
 
 	XXDKDUDUDWDWXXXYYY 0N/M/M/M,,,rM   c                    t           j                            d          sdt           j        d<   | j        J j        }	 fd}|_        t          j        |            |_        dS # |_        w xY w)z=Enable GUI event loop integration, taking pylab into account.
MPLBACKENDz)module://matplotlib_inline.backend_inlineNc                    t          dt          j                   J t          j                            |          t          j                   d S )Nz-GUI event loop or pylab initialization failedrZ   )r   rW   r   InteractiveTBstb2text)r_   r`   stbr0   s      rK   print_tbz,IPKernelApp.init_gui_pylab.<locals>.print_tbU  sQ    ECJWWWW(((e)22377cjIIIIIIrM   )r   environgetr0   _showtracebackr   init_gui_pylab)rJ   r:  r7  r0   s      @rK   r;  zIPKernelApp.init_gui_pylab@  s     z~~l++ 	S'RBJ|$ 
   -
	2J J J J J
 $,E .t444#1E   >E 1111s    A, ,	A5c                    t          | j        dd          | _        | j        r!| j        j                            |            dS dS )zInitialize the shell channel.r0   N)r   r'  r0   configurablesappendrI   s    rK   
init_shellzIPKernelApp.init_shell_  sJ    T['488
: 	2J$++D11111	2 	2rM   c                    t          j        d          }t          j                    }t          j        t           j                  }|                    |           |                    |           dS )a5  Configure the tornado logging.Logger.

        Must set up the tornado logger or else tornado will call
        basicConfig for the root logger which makes the root logger
        go to the real sys.stderr instead of the capture streams.
        This function mimics the setup of logging.basicConfig.
        tornadoN)r   	getLoggerr   	FormatterBASIC_FORMATsetFormatter
addHandler)rJ   loggerr  	formatters       rK   r   z$IPKernelApp.configure_tornado_loggere  sc     "9--'))%g&:;;	Y''''"""""rM   c                ,   t           j                            d          rrt           j        dk    rdddl}	 ddlm}m} t          |                                          |u r|	                     |                       dS dS # t          $ r Y dS w xY wdS dS )a  set default asyncio policy to be compatible with tornado

        Tornado 6 (at least) is not compatible with the default
        asyncio implementation on Windows

        Pick the older SelectorEventLoopPolicy on Windows
        if the known-incompatible default policy is in use.

        Support for Proactor via a background thread is available in tornado 6.1,
        but it is still preferable to run the Selector in the main thread
        instead of the background.

        do this as early as possible to make it a low priority and overridable

        ref: https://github.com/tornadoweb/tornado/issues/2608

        FIXME: if/when tornado supports the defaults in asyncio without threads,
               remove and bump tornado requirement for py38.
               Most likely, this will mean a new Python version
               where asyncio.ProactorEventLoop supports add_reader and friends.

        win)      r   N)WindowsProactorEventLoopPolicyWindowsSelectorEventLoopPolicy)rW   rd   
startswithversion_infoasynciorM  rN  typeget_event_loop_policyset_event_loop_policyr  )rJ   rQ  rM  rN  s       rK   _init_asyncio_patchzIPKernelApp._init_asyncio_patchs  s    . <""5)) 	Tc.>&.H.HNNN	Tbbbbbbbb
 557788<ZZZ 112P2P2R2RSSSSS [Z	    	T 	T.H.Hs   B 
BBc                    ddl }ddlm} t          |d          r&|j        |_        |j        |_        |j        |_        dS dS )zReplace pdb with IPython's version that is interruptible.

        With the non-interruptible version, stopping pdb() locks up the kernel in a
        non-recoverable state.
        r   N)debuggerInterruptiblePdb)pdbIPython.corerW  r   rX  Pdb	set_trace)rJ   rY  rW  s      rK   init_pdbzIPKernelApp.init_pdb  s]     	


))))))8/00 	/#4HLlCG$.CMMM		/ 	/rM   Nc                *   |                                   t                                          |           | j        dS |                                  |                                  |                                  |                                  |                                  | 	                                 | 
                                 |                                  |                                  	 |                                  nN# t          $ rA t          | j                  t"          j        k     r| j                            dd           Y nw xY w|                                  |                                  |                                  | j        r<|                                  |                                  |                                  t8          j                                         t8          j                                         dS )zInitialize the application.NzUnable to initialize signal:Tr   ) rU  super
initializesubappr]  r   r   rh   r   r   r&   r   r  r  r   r   r   r   r   r   r   r0  	init_pathr?  r0   r;  init_extensions	init_coderW   r   r   r   )rJ   argv	__class__s     rK   r`  zIPKernelApp.initialize  s    	  """4   ;"F!!###""$$$ 	  """	N 	N 	N 	N 4>""W%555=MMM		N
 	: 	!!!  """NN 	

s   5D
 
AEEc                   | j         | j                                         S | j        | j                                         | j                                         t          j                                        | _        | j        rXddl	m
}  |            }|                    | j        | j                   	 |                                 dS # t          $ r Y dS w xY w	 | j                                         dS # t          $ r Y dS w xY w)zStart the application.Nr   )
TrioRunner)ra  r   rg   r'  r   IOLoopcurrentr)  r>   ipykernel.trio_runnerrh  r`  runKeyboardInterrupt)rJ   rh  trs      rK   r   zIPKernelApp.start  s   ;";$$&&&;"K},,..> 	888888BMM$+t|444$   ""$$$$$$   s$   5C 
CCC8 8
DDrH   )W__name__
__module____qualname____doc__rP   r   kernel_aliasesaliaseskernel_flagsflagsr*   r-   r   r   classesr   tagr*  r   r'  rg   r   r(   r   rD   __annotations__r   r   r   r   r   r   r   r   r   subcommandsr   rF   r    rL   propertyrR   r   r7   r9   r>   r   r   r   r   r   r   r   r   r8  r9  rf   re   rX   rV   rh   rs   r   r&   r   r   r   r   r   r   r   r   r   r  r   r   r  r0  r;  r?  r   rU  r]  r   r`  r   __classcell__)rf  s   @rK   r6   r6   t   s/        **Dd>""GDE1:wGG4*+   
cc  SUUFSUUFt444I),G....355LSUUNSUUN355L355L355LSUUNTVVF 	 
K WYYNW% % % $ $ X$ U!EFFFJJRVJWWIU!EFFFJJRVJWWIU!7888<<D<IIIDFGGGKKSWKXXE&&&9   
cc	 
 )(.5c  	cc     
cc	  GBJNN+,,122  
 
cc  BJNN0116Q77  
 
cc ) ) )J J J
	- 	- 	-  &  (5 5 58	! 	! 	!  *! ! !49 9 9.
@ 
@ 
@  1 1 1@"
 "
 "
H8 8 8! ! !F. . .1 1 1:5 5 5N N N:2 2 2>2 2 2# # ##T #T #TJ/ / /  % % % % % %N      rM   c                     t                                           } |                                  |                                  dS )z!Run an IPKernel as an applicationN)r6   r+  r`  r   )apps    rK   mainr    s4    



 
 CNNIIKKKKKrM   __main__)Trr  
__future__r   r   rv   r   r   r  rW   r\   typingt	functoolsr   ior   r   r   pathlibr   rz   IPython.core.applicationr	   r
   r   r   IPython.core.profiledirr   IPython.core.shellappr   r   r   jupyter_client.connectr   jupyter_client.sessionr   r   r   jupyter_core.pathsr   rA  r   traitlets.traitletsr   r   r   r   r   r   r   r   r    traitlets.utilsr!   traitlets.utils.importstringr"   zmq.eventloop.zmqstreamr#   r   r%   r&   r3   r'   r   r(   iostreamr)   ipkernelr*   parentpollerr+   r,   zmqshellr-   r   rs  updateru  r   r6   launch_instancelaunch_new_instancer  ro  r  rM   rK   <module>r     s]   + + # " " " " "    				  



               $ $ $ $ $ $ $ $ ! ! ! ! ! !       



            / . . . . . Q Q Q Q Q Q Q Q Q Q 6 6 6 6 6 6 J J J J J J J J J J 2 2 2 2 2 2      
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 % $ $ $ $ $ 4 4 4 4 4 4 - - - - - - ? ? ? ? ? ? ? ? # " " " " "             ! ! ! ! ! ! # # # # # # ? ? ? ? ? ? ? ? ) ) ) ) ) ) l##   #)))-*,	 	   tJ   ${D&9:<`a${D&9:<`aWf-.+
  +u!56-
   "   m $ $ $   K         o & & &   M " " "q	 q	 q	 q	 q	(*=?R q	 q	 q	h "1    zDFFFFF rM   