B
    è¹`]  ã               @   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:y|jt||f S  tk
r8   Y nX t dt	 
|¡¡|g }xft|ƒr¸dd |¡ }||kršt||ƒrš|js–|j t||f|¡S |S t|ƒdkr¨P |g|dd …< qTW |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   ú\/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/mako/ext/autohandler.pyr   !   s,    
c             C   s>   t  dd|¡}x*| jD ]}tj |d | ¡rdS qW dS 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
   
