o
    èÇh]  ã                   @   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y   Y nw t dt	 
|¡¡|g }t|ƒr^dd |¡ }||krLt||ƒrL|jsJ|j t||f|¡S |S t|ƒdkrSn|g|dd …< t|ƒs-|jsk|j t||fd ¡S d S )Nz([^/]+)ú/é   éþÿÿÿ)ÚlookupÚmoduleÚ_template_uriÚfilesystem_checksÚ
_uri_cacher   ÚKeyErrorÚreÚfindallÚ	posixpathÚdirnameÚlenÚjoinÚ_file_existsÚ
setdefault)ÚtemplateÚcontextÚnamer   r   ÚtokensÚpath© r   úh/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/mako/ext/autohandler.pyr   !   s4   ÿ
ÿõ
ÿ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   ÚpsubÚdr   r   r   r   @   s   
ÿr   )r   )Ú__doc__r   r   r   r   r   r   r   r   r   Ú<module>   s   
