%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/mako/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/mako/__pycache__/lookup.cpython-312.pyc

�

���e�0��z�ddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	Gd�d�Z
Gd�de
�Zy)	�N)�
exceptions)�util)�Templatec�*�eZdZdZd�Zdd�Zd�Zd�Zy)�TemplateCollectiona;Represent a collection of :class:`.Template` objects,
    identifiable via URI.

    A :class:`.TemplateCollection` is linked to the usage of
    all template tags that address other templates, such
    as ``<%include>``, ``<%namespace>``, and ``<%inherit>``.
    The ``file`` attribute of each of those tags refers
    to a string URI that is passed to that :class:`.Template`
    object's :class:`.TemplateCollection` for resolution.

    :class:`.TemplateCollection` is an abstract class,
    with the usual default implementation being :class:`.TemplateLookup`.

    c�Z�	|j|�y#tj$rYywxYw)z�Return ``True`` if this :class:`.TemplateLookup` is
        capable of returning a :class:`.Template` object for the
        given ``uri``.

        :param uri: String URI of the template to be resolved.

        TF)�get_templater�TemplateLookupException)�self�uris  �-/usr/lib/python3/dist-packages/mako/lookup.py�has_templatezTemplateCollection.has_template#s0��	����c�"����1�1�	��	�s��*�*Nc��t��)a�Return a :class:`.Template` object corresponding to the given
        ``uri``.

        The default implementation raises
        :class:`.NotImplementedError`. Implementations should
        raise :class:`.TemplateLookupException` if the given ``uri``
        cannot be resolved.

        :param uri: String URI of the template to be resolved.
        :param relativeto: if present, the given ``uri`` is assumed to
         be relative to this URI.

        )�NotImplementedError)rr�
relativetos   r
r	zTemplateCollection.get_template1s
��"�#�#�c��|S�z^Convert the given ``filename`` to a URI relative to
        this :class:`.TemplateCollection`.��rr�filenames   r
�filename_to_uriz"TemplateCollection.filename_to_uriAs	���
rc��|S)a�Adjust the given ``uri`` based on the calling ``filename``.

        When this method is called from the runtime, the
        ``filename`` parameter is taken directly to the ``filename``
        attribute of the calling template. Therefore a custom
        :class:`.TemplateCollection` subclass can place any string
        identifier desired in the ``filename`` parameter of the
        :class:`.Template` objects it constructs and have them come back
        here.

        rrs   r
�
adjust_urizTemplateCollection.adjust_uriGs	���
r)N)�__name__�
__module__�__qualname__�__doc__rr	rrrrr
rrs��
��$� �rrc�|�eZdZdZ																										dd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zy)
�TemplateLookupa�	Represent a collection of templates that locates template source files
    from the local filesystem.

    The primary argument is the ``directories`` argument, the list of
    directories to search:

    .. sourcecode:: python

        lookup = TemplateLookup(["/path/to/templates"])
        some_template = lookup.get_template("/index.html")

    The :class:`.TemplateLookup` can also be given :class:`.Template` objects
    programatically using :meth:`.put_string` or :meth:`.put_template`:

    .. sourcecode:: python

        lookup = TemplateLookup()
        lookup.put_string("base.html", '''
            <html><body>${self.next()}</body></html>
        ''')
        lookup.put_string("hello.html", '''
            <%include file='base.html'/>

            Hello, world !
        ''')


    :param directories: A list of directory names which will be
     searched for a particular template URI. The URI is appended
     to each directory and the filesystem checked.

    :param collection_size: Approximate size of the collection used
     to store templates. If left at its default of ``-1``, the size
     is unbounded, and a plain Python dictionary is used to
     relate URI strings to :class:`.Template` instances.
     Otherwise, a least-recently-used cache object is used which
     will maintain the size of the collection approximately to
     the number given.

    :param filesystem_checks: When at its default value of ``True``,
     each call to :meth:`.TemplateLookup.get_template()` will
     compare the filesystem last modified time to the time in
     which an existing :class:`.Template` object was created.
     This allows the :class:`.TemplateLookup` to regenerate a
     new :class:`.Template` whenever the original source has
     been updated. Set this to ``False`` for a very minor
     performance increase.

    :param modulename_callable: A callable which, when present,
     is passed the path of the source file as well as the
     requested URI, and then returns the full path of the
     generated Python module file. This is used to inject
     alternate schemes for Python module location. If left at
     its default of ``None``, the built in system of generation
     based on ``module_directory`` plus ``uri`` is used.

    All other keyword parameters available for
    :class:`.Template` are mirrored here. When new
    :class:`.Template` objects are created, the keywords
    established with this :class:`.TemplateLookup` are passed on
    to each new :class:`.Template`.

    Nc�~�tj|d�D�cgc]}tj|���c}|_||_||_||_||_|	�i}	|
r|	jd|
�|r|	jd|�|r|	jd|�id|�d|�d|�d|�d	|
�d
|�d|�d|�d
|�d|	�d|�d|�d|�d|�d|�d|�d|�||d��|_
|dk(ri|_i|_n4tj|�|_tj|�|_tj�|_ycc}w)Nr�dir�url�type�format_exceptions�
error_handler�include_error_handler�output_encoding�
cache_impl�encoding_errors�input_encoding�module_directory�
module_writer�
cache_args�
cache_enabled�default_filters�buffer_filters�strict_undefined�imports�future_imports�enable_loop)�preprocessor�	lexer_cls���)r�to_list�	posixpath�normpath�directoriesr,�modulename_callable�filesystem_checks�collection_size�
setdefault�
template_args�_collection�
_uri_cache�LRUCache�	threading�Lock�_mutex)rr<r,r>r?r%r&r(r*r.r)r/�
cache_type�	cache_dir�	cache_urlr=r-r0r1r2r3r4r5r+r6r7r'�ds                            r
�__init__zTemplateLookup.__init__�s���<,0�<�<��R�+H�
�&'�I���q�!�
���!1���#6�� �!2���.������J���!�!�%��3���!�!�%��3���!�!�&�*�5�
��!2�
��]�
�
$�%:�
�
��	
�

�*�
�
��

�
�n�
�
� 0�
�
�]�
�
�*�
�
�]�
�
��
�
�n�
�
� 0�
�
�w�
� 
�n�!
�"
�;�#
�$)�"�'
���,�b� �!�D�� �D�O�#�}�}�_�=�D��"�m�m�O�<�D�O��n�n�&����]
s�D:c�N�	|jr|j||j|�S|j|S#t$r�}t	j
dd|�}|jD]�}|jtjjtj�}tjtj||��}tjj|�s��|j||�ccYd}~St!j"d|z�|�d}~wwxYw)z�Return a :class:`.Template` object corresponding to the given
        ``uri``.

        .. note:: The ``relativeto`` argument is not supported here at
           the moment.

        z^\/+�N� Can't locate template for uri %r)r>�_checkrB�KeyError�re�subr<�replace�os�path�sepr:r;�join�isfile�_loadr�TopLevelLookupException)rr�e�u�dir_�srcfiles      r
r	zTemplateLookup.get_template�s���	��%�%��{�{�3��(8�(8��(=�>�>��'�'��,�,���	����w��C�(�A��(�(�

���|�|�B�G�G�K�K����?��#�,�,�Y�^�^�D�!�-D�E���7�7�>�>�'�*��:�:�g�s�3�3�

�!�8�8�6��<�����	�s,�*<�<�	D$�B&D�,D�?D$�D�D$c��||f}||jvr|j|S|ddk(r|x}|j|<|S|�:tjtj|�|�x}|j|<|Sd|zx}|j|<|S)z9Adjust the given ``uri`` based on the given relative URI.r�/)rCr:rX�dirname)rrr�key�vs     r
rzTemplateLookup.adjust_uris����J����$�/�/�!��?�?�3�'�'��q�6�S�=�'*�*�A�����$���
�
#�'0�~�~��!�!�*�-�s�(�
�A�����$�
��(+�S�y�0�A�����$��rc��	|j|S#t$r%|j|�}||j|<|cYSwxYwr)rCrQ�_relativeize)rr�values   r
rzTemplateLookup.filename_to_urisH��	��?�?�8�,�,���	��%�%�h�/�E�(-�D�O�O�H�%��L�	�s��+?�?c��tj|�}|jD]#}|dt|�|k(s�|t|�dcSy)zhReturn the portion of a filename that is 'relative'
        to the directories in this lookup.

        rN)r:r;r<�len)rrr^s   r
rfzTemplateLookup._relativeizesR���%�%�h�/���$�$�	�D���C��I�&�$�.���D�	��,�,�	�rc� �|jj�		|j||jj�S#t$rYnwxYw	|j
�|j||�}nd}t
d|tj|�||d�|j��x|j|<}||jj�S#|jj|d��xYw#|jj�wxYw)N)rr�lookup�module_filenamer)rG�acquirerB�releaserQr=rr:r;rA�pop)rrrrl�templates     r
rZzTemplateLookup._load*s��������	"�
��'�'��,�.
�K�K���!��-�
��
��
��+�+�7�&*�&>�&>�x��&M�O�&*�O�3;�4��&�/�/��9��$3�	4�
�(�(�4��� � ��%�� �
�K�K���!��
�� � �$�$�S�$�/����K�K���!�s6�A�	A�C1�A�C1�AC�C.�.C1�1D
c��|j�|S	tj|j�}|jj|tj
k\r|S|jj|d�|j|j|�S#t$r:}|jj|d�tjd|z�|�d}~wwxYw)NrO)rrU�stat�module�_modified_time�ST_MTIMErBrorZ�OSErrorrr
)rrrp�
template_statr\s     r
rPzTemplateLookup._checkIs������$��O�
	��G�G�H�$5�$5�6�M����-�-��t�}�}�1M�M������ � ��d�+��:�:�h�/�/��5�5���	���� � ��d�+��4�4�2�S�8���
��	�s�A
B�7B�	C�5C�Cc�P�t|f||d�|j��|j|<y)z�Place a new :class:`.Template` object into this
        :class:`.TemplateLookup`, based on the given string of
        ``text``.

        )rkrN)rrArB)rr�texts   r
�
put_stringzTemplateLookup.put_stringYs4��!)��!
��3�!
�*.�*<�*<�!
�����rc�"�||j|<y)z�Place a new :class:`.Template` object into this
        :class:`.TemplateLookup`, based on the given
        :class:`.Template` object.

        N)rB)rrrps   r
�put_templatezTemplateLookup.put_templatecs��!)�����r)NNTr8FNN�strictN�beakerTNNNNNNrFNNTNNNN)
rrrrrLr	rrrfrZrPrzr|rrr
r r Vs���>�D������� ������� �����������"�7K'�Z�8�"	��"�>� 
�)rr )rUr:rRrrrE�makorr�
mako.templaterrr rrr
�<module>r�s;��
��	�����"�A�A�HS)�'�S)r

Zerion Mini Shell 1.0