o
    i                     @   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   S/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/jupyterlab/pytest_plugin.pyr      s   
r   c                 C   
   t | dS )Napp_settingsr   r   r   r   r   <lambda>      
 r   c                 C   r   )Nuser_settingsr   r   r   r   r   r      r   c                 C   r   )Nschemasr   r   r   r   r   r      r   c                 C   r   )N
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)app_name
static_dirtemplates_dirapp_urlapp_settings_diruser_settings_dirschemas_dirworkspaces_dirN)
__name__
__module____qualname__base_urlextension_urlr   default_urlr   str
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#   r2   indexr   r,   r   make_lab_app   s   
"r5   c                 C   s   | }| |  |  |S )N)_link_jupyter_server_extension
initialize)jp_serverappr5   r1   r   r   r   labappZ   s   
r9   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   r0   path_url
params_urlurlhttp_server_clientjp_auth_headerjp_base_urlr   r   client_fetchf   s   

z fetch_long.<locals>.client_fetchr   )rI   rJ   rK   rL   r   rH   r   
fetch_longb   s   rM   )urllib.parser@   pytestjupyter_server.utilsr   jupyterlab_serverr   tornado.escaper   	traitletsr   jupyterlab.labappr   r   fixturer    r!   r"   r#   r5   r9   rM   r   r   r   r   <module>   s$   
=
