Ë
    :vžj  ã                  ó¬   — 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ZddlmZ e	rddlmZ ddd„Zd	„ Z	 d	 	 	 	 	 dd
„Z	 d	 	 	 	 	 dd„Zg d¢Zy)z0Connection file-related utilities for the kernelé    )ÚannotationsN)ÚPIPEÚPopen)ÚTYPE_CHECKINGÚAny)Úwrite_connection_file©ÚIPKernelAppc                óº   — ddl m} | €5ddlm}  |j                  «       sd}t        |«      ‚ |j                  «       }  || j                  d| j                  g«      S )z½Return the path to the connection file of an app

    Parameters
    ----------
    app : IPKernelApp instance [optional]
        If unspecified, the currently running app will be used
    r   )Úfilefindr	   z.app not specified, and not in a running KernelÚ.)	Útraitlets.utilsr   Úipykernel.kernelappr
   ÚinitializedÚRuntimeErrorÚinstanceÚconnection_fileÚconnection_dir)Úappr   r
   Úmsgs       úb/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/ipykernel/connect.pyÚget_connection_filer      s[   € õ )à
€{Ý3à&ˆ{×&Ñ&Ô(ØBˆCÜ˜sÓ#Ð#à"ˆk×"Ñ"Ó$ˆÙ�C×'Ñ'¨#¨s×/AÑ/AÐ)BÓCÐCó    c                óD   — | €
t        «       S t        j                  | «      S )z²Return the absolute path for a connection file

    - If nothing specified, return current Kernel's connection file
    - Otherwise, call jupyter_client.find_connection_file
    )r   Újupyter_clientÚfind_connection_file)r   s    r   Ú_find_connection_filer   (   s$   € ð Ðä"Ó$Ð$Ü×.Ñ.¨Ó?Ð?r   c                óô   — t        | «      }t        |«      5 }|j                  «       }ddd«       |r:t        j                  «      }|j                  dd«      j                  «       |d<   |S S # 1 sw Y   ŒGxY w)a»  Return the connection information for the current Kernel.

    Parameters
    ----------
    connection_file : str [optional]
        The connection file to be used. Can be given by absolute path, or
        IPython will search in the security directory.
        If run from IPython,

        If unspecified, the connection file for the currently running
        IPython Kernel will be used, which is only allowed from inside a kernel.

    unpack : bool [default: False]
        if True, return the unpacked dict, otherwise just the string contents
        of the file.

    Returns
    -------
    The connection dictionary of the current kernel, as string or dict,
    depending on `unpack`.
    NÚkeyÚ )r   ÚopenÚreadÚjsonÚloadsÚgetÚencode)r   ÚunpackÚcfÚfÚinfo_strÚinfos         r   Úget_connection_infor,   4   si   € ô0 
˜Ó	/€Bä	ˆbŒ�QØ—6‘6“8ˆ÷ 
ñ Ü�z‰z˜(Ó#ˆà—h‘h˜u bÓ)×0Ñ0Ó2ˆˆU‰Øˆà€O÷ 
ˆús   —A.Á.A7c                óÔ   — |€g n|}t        | «      }dj                  ddg«      }i }d|d<   t        t        j                  d|d|g|¢ft
        t
        t        j                  dk7  d	œ|¤ŽS )
a·  Connect a qtconsole to the current kernel.

    This is useful for connecting a second qtconsole to a kernel, or to a
    local notebook.

    Parameters
    ----------
    connection_file : str [optional]
        The connection file to be used. Can be given by absolute path, or
        IPython will search in the security directory.
        If run from IPython,

        If unspecified, the connection file for the currently running
        IPython Kernel will be used, which is only allowed from inside a kernel.

    argv : list [optional]
        Any extra args to be passed to the console.

    Returns
    -------
    :class:`subprocess.Popen` instance running the qtconsole frontend
    Ú;z"from qtconsole import qtconsoleappzqtconsoleapp.main()TÚstart_new_sessionz-cz
--existingÚwin32)ÚstdoutÚstderrÚ	close_fds)r   Újoinr   ÚsysÚ
executabler   Úplatform)r   Úargvr(   ÚcmdÚkwargss        r   Úconnect_qtconsoler;   Z   s…   € ð2 �‰2 4€Dä	˜Ó	/€Bà
�(‰(Ð8Ð:OÐPÓ
Q€Cà€Fð #'€FÐÑäÜ	�‰˜˜s L°"Ð<°tÐ<ðäÜÜ—<‘< 7Ñ*ñ	ð
 ñð r   )r;   r   r,   r   )N)r   zIPKernelApp | NoneÚreturnÚstr)NF)r   ú
str | Noner'   Úboolr<   zstr | dict[str, Any])NN)r   r>   r8   zlist[str] | Noner<   z
Popen[Any])Ú__doc__Ú
__future__r   r#   r5   Ú
subprocessr   r   Útypingr   r   r   r   r   r
   r   r   r,   r;   Ú__all__© r   r   Ú<module>rF      s€   ðÙ 6õ #ã Û 
ß "ß %ã Ý 0áÝ/ôDò*	@ð 8=ð#Øð#Ø04ð#àó#ðN BFð*Øð*Ø.>ð*àó*òZ�r   