a
    e	g]                     @   s2   d Z ddlZddlZddlZdddZdd ZdS )a  adds autohandler functionality to Mako templates.

requires that the TemplateLookup class is used with templates.

usage::

    <%!
        from mako.ext.autohandler import autohandler
    %>
    <%inherit file="${autohandler(template, context)}"/>


or with custom autohandler filename::

    <%!
        from mako.ext.autohandler import autohandler
    %>
    <%inherit file="${autohandler(template, context, name='somefilename')}"/>

    Nautohandlerc                 C   s   |j }| jj}|js:z|jt||f W S  ty8   Y n0 tdt	
||g }t|rdd| }||krt||r|js|jt||f|S |S t|dkrq|g|dd < qR|js|jt||fd S d S d S )Nz([^/]+)/   )lookupmodule_template_uriZfilesystem_checksZ
_uri_cacher   KeyErrorrefindall	posixpathdirnamelenjoin_file_exists
setdefault)templatecontextnamer   r   tokenspath r   W/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/mako/ext/autohandler.pyr   !   s0    

c                 C   s8   t dd|}| jD ]}tj|d | r dS qdS )Nz^/ r   TF)r
   subdirectoriesosr   exists)r   r   Zpsubdr   r   r   r   @   s
    
r   )r   )__doc__r   r   r
   r   r   r   r   r   r   <module>   s
   
