o
    tf                     @  s
  d Z ddlmZ ddlZddlZddlmZ ddlZddlm	Z
 ddlmZ ddlmZmZ ddlZddlmZ ddlmZ d	gZd&ddZejejeZedd Zedd Zedd Zedd Zedd Z ejd'dd Z!ejd(d$d%Z"dS ))zpytest fixtures.    )annotationsN)join)Path)AnyCallable)	ServerApp)LabServerAppzpytest_jupyter.jupyter_servertmp_pathr   partsstrreturnc                 G  s"   | j | }| s|jdd |S )zUtil for making a directory.T)parents)joinpathexistsmkdir)r	   r
   path r   h/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyterlab_server/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   )Nschemasr   r   r   r   r   r   #   r   c                 C  r   )N
workspacesr   r   r   r   r   r   $   r   c                 C  r   )Nlabextensions_dirr   r   r   r   r   r   %   r   jp_root_dirjp_template_dirapp_settings_diruser_settings_dirschemas_dirworkspaces_dirr   Callable[..., LabServerApp]c              	     s  d fdd} d}|d ttd	d
d}	ttd}
tj|
r0t	|
 t
|	|
 dD ]T}|d }ttd|}ttd	d
d|}	t|d
d|}
t|
r_t	|
 t
|	|
 tt|dd}t|tddd}t|| W d   n1 sw   Y  q8ttd	dd}	tt d}
tj|
rt|
 t|	|
 ttd	d}t|D ]!}t||}	tt|}
tj|
rt|
 t|	t q|S )z8Return a factory function for a labserver extension app.kwargsr   r   r   c               
     s6   t ttdt ttttgdS )z/Factory function for lab server extension apps.z/lab)Z
static_dirZtemplates_dirZapp_urlr   r   r    r!   Zextra_labextensions_path)r   r   )r#   r   r   r   r   r    r   r!   r   r   _make_labserver_extension_app4   s   zCmake_labserver_extension_app.<locals>._make_labserver_extension_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>
Z	test_datar   z@jupyterlab)zapputils-extensionzcodemirror-extensionz
-federatedzpackage.orig.jsonwT)	extension)nameZ
jupyterlabNzapp-settingszoverrides.jsonr   )r#   r   r   r   )r   
write_textpjoinHEREr   osr   r   shutilrmtreecopytreeospopendictjsondumpremovecopyfilelistdircopy)r   r   r   r   r    r!   r   r%   indexsrcdstr(   target_nametargetfiddataZws_pathitemr   r$   r   make_labserver_extension_app(   sH   
#





rA   jp_serverappr   r   c                 C  s   | }| |  |  |S )zA lab server app.)Z_link_jupyter_server_extensionZ
initialize)rB   rA   Zappr   r   r   labserverapp   s   
rC   )r	   r   r
   r   r   r   )r   r   r   r   r   r   r   r   r    r   r!   r   r   r   r   r"   )rB   r   rA   r"   r   r   )#__doc__
__future__r   r3   r,   Zos.pathr   r0   r-   r   r*   pathlibr   typingr   r   ZpytestZjupyter_server.serverappr   Zjupyterlab_serverr   Zpytest_pluginsr   abspathdirname__file__r+   Zfixturer   r   r    r!   r   rA   rC   r   r   r   r   <module>   s0   
c