U
    \g%i]  ã                   @   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k
r:   Y nX t dt	 
|¡¡|g }t|ƒr¸dd |¡ }||kršt||ƒrš|js–|j t||f|¡S |S t|ƒdkr¨q¸|g|dd …< qT|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   úS/var/www/html/api-medvista/venv/lib/python3.8/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   ZpsubÚdr   r   r   r   @   s
    
r   )r   )Ú__doc__r   r   r
   r   r   r   r   r   r   Ú<module>   s
   
