
    oi^                        d dl Z d dlZd dlZd dlmZ ej                  j                  e      Z	ej                  j                  e	d      Zej                  j                  ej                  j                  e	d            xr5 ej                  j                  ej                  j                  e	d            Z	 ddZ	 ddZ	 	 	 	 	 ddZd	 Zd
 Zy)    N)jupyter_pathstaticz../setup.pyz../sharec                 "    t        | |d||      S )NT)include_root_pathsprune	root_dirscollect_paths	app_namestemplate_namer   r   s       S/home/ubuntu/docker-apps/notebooks/venv/lib/python3.12/site-packages/voila/paths.pycollect_template_pathsr      s           c                 $    t        | |d||d      S )NFr   )r   r   r   subdirr	   r   s       r   collect_static_pathsr   $   s#       r   c                    d}g }g }|xs
 t               }t        | ||      }	|	D ]  }|D ]  }
| D ]  }t        j                  j	                  |
|d      }t        j                  j	                  ||      }|r t        j                  j	                  ||      }|r t        j                  j                  |      s|j                  |       d}   |rQ|D ]L  }
|j                  |
       | D ]4  }t        j                  j	                  |
|d      }|j                  |       6 N |s,dj	                  |      }t        dj                  ||            |S )uW  
    Voilà supports custom templates for rendering notebooks.
    For a specified template name, `collect_paths` can be used to collects
        - template paths
        - resources paths (by using the subdir arg)

    by looking in the standard Jupyter data directories:
    $PREFIX/share/jupyter/templates/<app_name>/<template_name>[/subdir]
    with different prefix values (user directory, sys prefix, and then system prefix) which
    allows users to override templates locally.
    The function will recursively load the base templates upon which the specified template
    may be based.
    F	templatesTz
	zJNo template sub-directory with name {!r} found in the following paths:
	{})	_default_root_dirs_find_template_hierarchyospathjoinexistsappend
ValueErrorformat)r   r   r   r   r   r   found_at_least_onepaths
full_pathstemplate_namesroot_dirapp_nameapp_dirr   s                 r   r
   r
   1   sU   * EJ1/1I .i	RN
 ( 	.! 	.H% .'',,x;Gww||G];77<<f5Dt 4LL&)-&.	.	.  ! 	&H LL"% &'',,x;G W%	&		& J'Zaau
 	

 Lr   c                     g } t         rR| j                  t        j                  j	                  t        j                  j                  t        ddd                   t        j                  j                  j                   rq| j                  t        j                  j	                  t        j                  j                  t        j                  j                  j                  dddd                   | j                  t                      | S )Nz..sharejupyter)DEV_MODEr   r   r   abspathr   ROOT	nbconvert	exporterstemplateexporterextendr   )r   s    r   r   r   w   s     IdD'9)UVW++44GGOO''88==
	
 \^$r   c           	         g }||j                  |       i }|D ]  }| D ]  }t        j                  j                  ||d|d      }t        j                  j	                  |      sFt        |      5 }t        j                  |      }	|	j                  |       |	}d d d          d|v r|d   }n
|dk(  rd }nd}||S # 1 sw Y   xY w)Nr   z	conf.jsonbase_templatebase)	r   r   r   r   r   openjsonloadupdate)
r   r   r   r"   confr#   r$   	conf_filefnew_confs
             r   r   r      s    N

#m,! 		(H% (GGLLh]K	 77>>),i (A#'99Q< -'( ((		( d" 1M& $ !'+ 
#, ( (s   0)B>>C)defaultFN)r;   NTFN)r4   r   $nbconvert.exporters.templateexporterr,   jupyter_core.pathsr   r   dirname__file__r+   r   STATIC_ROOTr   r)   r   r   r
   r   r    r   r   <module>rB      s     	 + +	wwx ggll4*77>>"'',,t];< GGLLz"B @D	 @D
 
CL.r   