a
    ø£Be  ã                   @   sº   d dl Zd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ dd„ Ze d	d
„ ¡Ze dd
„ ¡Ze dd
„ ¡Ze dd
„ ¡Zejdd„ ƒZejdd„ ƒZejdd„ ƒZdS )é    N)Úurl_path_join)Ú	LabConfig)Ú
url_escape)ÚUnicode©ÚLabAppc                 G   s"   | j |Ž }| ¡ s|jdd� |S )NT)Úparents)ÚjoinpathÚexistsÚmkdir)Útmp_pathÚpartsÚpath© r   ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/jupyterlab/pytest_plugin.pyr      s    
r   c                 C   s
   t | dƒS )NZapp_settings©r   ©r   r   r   r   Ú<lambda>   ó    r   c                 C   s
   t | dƒS )NZuser_settingsr   r   r   r   r   r      r   c                 C   s
   t | dƒS )NZschemasr   r   r   r   r   r      r   c                 C   s
   t | dƒS )NZ
workspacesr   r   r   r   r   r      r   c                    s.   ‡ ‡‡‡‡‡fdd„}ˆ  d¡}| d¡ |S )Nc                     s(   G ‡ ‡‡‡‡‡fdd„dt ƒ}|ƒ }|S )Nc                
       sP   e Zd ZdZdZeddd�Zede”ƒe”ƒde” ƒe”ƒe”ƒe”ƒd�Z	dS )z7make_lab_app.<locals>._make_lab_app.<locals>.TestLabAppz/labú/z'The default URL to redirect to from `/`)ÚhelpzJupyterLab Test App)Zapp_nameZ
static_dirZtemplates_dirZapp_urlÚapp_settings_dirÚuser_settings_dirÚschemas_dirÚworkspaces_dirN)
Ú__name__Ú
__module__Ú__qualname__Úbase_urlZextension_urlr   Zdefault_urlr   ÚstrZ
lab_configr   ©r   Újp_root_dirÚjp_template_dirr   r   r   r   r   Ú
TestLabApp!   s   ør#   r   )Úkwargsr#   Úappr    r   r   Ú_make_lab_app    s    z#make_lab_app.<locals>._make_lab_appz
index.htmla“  
<!DOCTYPE html>
<html>
<head>
  <title>{{page_config['appName'] | e}}</title>
</head>
<body>
    {# Copy so we do not modify the page_config with updates. #}
    {% set page_config_full = page_config.copy() %}

    {# Set a dummy variable - we just want the side effect of the update. #}
    {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %}

      <script id="jupyter-config-data" type="application/json">
        {{ page_config_full | tojson }}
      </script>
  <script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>

  <script type="text/javascript">
    /* Remove token from URL. */
    (function () {
      var parsedUrl = new URL(window.location.href);
      if (parsedUrl.searchParams.get('token')) {
        parsedUrl.searchParams.delete('token');
        window.history.replaceState({ }, '', parsedUrl.href);
      }
    })();
  </script>
</body>
</html>
)r	   Ú
write_text)r!   r"   r   r   r   r   r&   Úindexr   r    r   Úmake_lab_app   s    
ÿ"r)   c                 C   s   |ƒ }|  | ¡ | ¡  |S )N)Z_link_jupyter_server_extensionZ
initialize)Zjp_serverappr)   r%   r   r   r   ÚlabappZ   s    
r*   c                    s   dddœ‡ ‡‡fdd„
}|S )z3fetch fixture that handles auth, base_url, and pathN)ÚheadersÚparamsc                    s`   t t|Ž dd�}tˆ|ƒ}tj |p&i ¡}|d | }| p<i } |  ˆ¡ ˆ j|f| ddœ|¤ŽS )NF)Úplusú?éú   )r+   Úrequest_timeout)r   r   ÚurllibÚparseÚ	urlencodeÚupdateÚfetch)r+   r,   r   r$   Úpath_urlZ
params_urlÚurl©Úhttp_server_clientÚjp_auth_headerÚjp_base_urlr   r   Úclient_fetchf   s    

z fetch_long.<locals>.client_fetchr   )r9   r:   r;   r<   r   r8   r   Ú
fetch_longb   s    r=   )Úurllib.parser1   ZpytestZjupyter_server.utilsr   Zjupyterlab_serverr   Ztornado.escaper   Z	traitletsr   Zjupyterlab.labappr   r   Zfixturer   r   r   r   r)   r*   r=   r   r   r   r   Ú<module>   s"   
=
