o
    tf                     @   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   a/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyterlab/pytest_plugin.pyr      s   
r   c                 C   
   t | dS )NZapp_settingsr   r   r   r   r   <lambda>      
 r   c                 C   r   )NZuser_settingsr   r   r   r   r   r      r   c                 C   r   )NZschemasr   r   r   r   r   r      r   c                 C   r   )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   )r:   r;   r<   r=   r   r9   r   
fetch_longb   s   r>   )urllib.parser2   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$   
=
