%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/jinja2/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/jinja2/__pycache__/loaders.cpython-312.pyc

�

��jb�Z���dZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZej,rddlmZddlmZd
edej6efd�ZGd�d�ZGd�de�ZGd�de�ZGd�de�Z Gd�de�Z!Gd�de�Z"Gd�de�Z#Gd�de�Z$Gd �d!e�Z%y)"zKAPI and implementations for loading templates from different data
sources.
�N)�abc)�sha1)�
import_module)�
ModuleType�)�TemplateNotFound)�internalcode)�open_if_exists)�Environment)�Template�template�returnc�^�g}|jd�D]�}tjj|vsStjjrtjj|vs|tjj
k(rt
|��|s��|dk7s��|j|���|S)z�Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    �/�.)�split�os�path�sep�altsep�pardirr�append)r
�pieces�pieces   �0/usr/lib/python3/dist-packages/jinja2/loaders.py�split_template_pathrs����F�����$�!���G�G�K�K�5� ������2�7�7�>�>�U�#:�������&�"�8�,�,�
�u��|��M�M�%� �!��M�c�2�eZdZdZdZdddedejeejeejejge
fffd�Zdejefd�Z
e	dddd
edejejeej fddfd
��Zy	)�
BaseLoadera�Baseclass for all loaders.  Subclass this and override `get_source` to
    implement a custom loading mechanism.  The environment provides a
    `get_template` method that calls the loader's `load` method to get the
    :class:`Template` object.

    A very basic example for a loader that looks up templates on the file
    system could look like this::

        from jinja2 import BaseLoader, TemplateNotFound
        from os.path import join, exists, getmtime

        class MyLoader(BaseLoader):

            def __init__(self, path):
                self.path = path

            def get_source(self, environment, template):
                path = join(self.path, template)
                if not exists(path):
                    raise TemplateNotFound(template)
                mtime = getmtime(path)
                with open(path) as f:
                    source = f.read()
                return source, path, lambda: mtime == getmtime(path)
    T�environmentrr
rc�r�|js!tt|�j�d���t	|��)a�Get the template source, filename and reload helper for a template.
        It's passed the environment and template name and has to return a
        tuple in the form ``(source, filename, uptodate)`` or raise a
        `TemplateNotFound` error if it can't locate the template.

        The source part of the returned tuple must be the source of the
        template as a string. The filename should be the name of the
        file on the filesystem if it was loaded from there, otherwise
        ``None``. The filename is used by Python for the tracebacks
        if no loader extension is used.

        The last item in the tuple is the `uptodate` function.  If auto
        reloading is enabled it's always called to check if the template
        changed.  No arguments are passed so the function must store the
        old state somewhere (for example in a closure).  If it returns `False`
        the template will be reloaded.
        z$ cannot provide access to the source)�has_source_access�RuntimeError�type�__name__r)�selfr r
s   r�
get_sourcezBaseLoader.get_sourceKs=��(�%�%����:�&�&�'�'K�L��
��x�(�(rc��td��)z�Iterates over all templates.  If the loader does not support that
        it should raise a :exc:`TypeError` which is the default behavior.
        z-this loader cannot iterate over all templates)�	TypeError�r&s r�list_templateszBaseLoader.list_templateses���G�H�HrN�name�globalsrc�H�d}|�i}|j||�\}}}|j}|� |j||||�}	|	j}|�|j	|||�}|�$	j�||	_|j|	�|jj||||�S)acLoads a template.  This method looks up the template in the cache
        or loads one by calling :meth:`get_source`.  Subclasses should not
        override this method as loaders working on collections of other
        loaders (such as :class:`PrefixLoader` or :class:`ChoiceLoader`)
        will not call this method but `get_source` directly.
        N)r'�bytecode_cache�
get_bucket�code�compile�
set_bucket�template_class�	from_code)
r&r r,r-r1�source�filename�uptodate�bcc�buckets
          r�loadzBaseLoader.loadks������?��G�&*�_�_�[�$�%G�"���(��(�(���?��^�^�K��x��H�F��;�;�D��<��&�&�v�t�X�>�D�
�?�v�{�{�2��F�K��N�N�6�"��)�)�3�3���w��
�	
r�N)r%�
__module__�__qualname__�__doc__r"�str�t�Tuple�Optional�Callable�boolr'�Listr+r	�MutableMapping�Anyr;�rrrr*s����<��)�(�)�47�)�	
����a�j�j��o�q�z�z�!�*�*�R��X�2F�'G�G�	H�)�4I����s��I��
=A�	)
�"�)
��)
����A�,�,�S�!�%�%�Z�8�9�	)
�

�)
��)
rrc�&�eZdZdZ		d
dej
eejejej
eejffdede
ddfd�Zdd	d
edejeeejge
fffd�Zdejefd�Zy)�FileSystemLoaderaLoad templates from a directory in the file system.

    The path can be relative or absolute. Relative paths are relative to
    the current working directory.

    .. code-block:: python

        loader = FileSystemLoader("templates")

    A list of paths can be given. The directories will be searched in
    order, stopping at the first matching template.

    .. code-block:: python

        loader = FileSystemLoader(["/override/templates", "/default/templates"])

    :param searchpath: A path, or list of paths, to the directory that
        contains the templates.
    :param encoding: Use this encoding to read the text from template
        files.
    :param followlinks: Follow symbolic links in the path.

    .. versionchanged:: 2.8
        Added the ``followlinks`` parameter.
    �
searchpath�encoding�followlinksrNc���t|tj�rt|t�r|g}|D�cgc]}t	j
|���c}|_||_||_ycc}wr<)	�
isinstancer�Iterabler@r�fspathrLrMrN)r&rLrMrN�ps     r�__init__zFileSystemLoader.__init__�sP���*�c�l�l�3�z�*�c�7R�$��J�1;�<�A�2�9�9�Q�<�<��� ��
�&����=s�A%r rr
c����	�t|�}|jD]�}tj|g|����t	��}|��'	|j�j
|j�}|j�tjj���	dtf��	fd�}|tjj��|fcSt|��#|j�wxYw)Nrc�h��	tjj���k(S#t$rYywxYw)NF)rr�getmtime�OSError)r7�mtimes��rr8z-FileSystemLoader.get_source.<locals>.uptodate�s4���!��7�7�+�+�H�5��>�>���!� �!�s�!%�	1�1)rrL�	posixpath�joinr
�read�decoderM�closerrrWrE�normpathr)
r&r r
rrL�f�contentsr8r7rYs
        @@rr'zFileSystemLoader.get_source�s����%�X�.���/�/�	B�J�!�~�~�j�:�6�:�H��x�(�A��y��
��6�6�8�?�?�4�=�=�9�����	��G�G�$�$�X�.�E�
!�d�
!��R�W�W�-�-�h�7��A�A�+	B�,�x�(�(�����	�s�)C�C)c���t�}|jD]�}tj||j��}|D]�\}}}|D]�}tj
j
||�t|�djtj
j�jtj
jd�}|dddk(r|dd}||vs��|j|�������t|�S)N)rNr�z./)
�setrLr�walkrNrr[�len�stripr�replace�add�sorted)	r&�foundrL�walk_dir�dirpath�_�	filenamesr7r
s	         rr+zFileSystemLoader.list_templates�s�������/�/�	,�J��w�w�z�t�7G�7G�H�H�)1�

,�%���I� )�	,�H������W�h�7��J��8I�J���r�w�w�{�{�+� �������c�2��
 ���|�t�+�#+�A�B�<���u�,��	�	�(�+�	,�

,�	,��e�}�r)�utf-8F)r%r=r>r?rA�Unionr@r�PathLike�SequencerErTrBrDr'rFr+rIrrrKrK�s����: �!�	'��G�G�C����a�j�j�����b�k�k�AQ�9R�.S�S�T�'��'��	'�

�'�)�(�)�47�)�	
����c�1�:�:�b�$�h�/�/�	0�)�8����s��rrKc��eZdZdZ		ddedddeddfd�Zd	d
dedejeeejejge
fffd�Zdejefd
�Z
y)�
PackageLoaderalLoad templates from a directory in a Python package.

    :param package_name: Import name of the package that contains the
        template directory.
    :param package_path: Directory within the imported package that
        contains the templates.
    :param encoding: Encoding of template files.

    The following example looks up templates in the ``pages`` directory
    within the ``project.ui`` package.

    .. code-block:: python

        loader = PackageLoader("project.ui", "pages")

    Only packages installed as directories (standard pip behavior) or
    zip/egg files (less common) are supported. The Python API for
    introspecting data in packages is too limited to support other
    installation methods the way this loader requires.

    There is limited support for :pep:`420` namespace packages. The
    template directory is assumed to only be in one namespace
    contributor. Zip files contributing to a namespace are not
    supported.

    .. versionchanged:: 3.0
        No longer uses ``setuptools`` as a dependency.

    .. versionchanged:: 3.0
        Limited PEP 420 namespace package support.
    �package_name�package_pathr@rMrNc���tjj|�jtjj�}|tjj
k(rd}n@|ddtjj
tjjzk(r|dd}||_||_||_t|�tjj|�}|�Jd��|j}|�Jd��||_d|_d}t!|t"j$�rw|j&|_t)t+|j,��}tjj/||�jtjj�}n�g}|j,r|j1|j,�nD|j2�8|j5tjj7|j2��|D]E}	tjj/|	|�}	tjj9|	�s�C|	}n|�t;d|�d���||_y)N�rcz-An import spec was not found for the package.z'A loader was not found for the package.zThe zC package was not installed in a way that PackageLoader understands.)rrr_�rstripr�curdirrwrvrMr�	importlib�util�	find_spec�loader�_loader�_archiverP�	zipimport�zipimporter�archive�next�iter�submodule_search_locationsr[�extend�originr�dirname�isdir�
ValueError�_template_root)
r&rvrwrM�specr�
template_root�pkgdir�roots�roots
          rrTzPackageLoader.__init__s����w�w�'�'��5�<�<�R�W�W�[�[�I���2�7�7�>�>�)��L�
�"�1�
������"�'�'�+�+�!=�
=�'���+�L�(���(��� ��
�	�l�#��~�~�'�'��5����P�!P�P�������!�L�#L�L�!������
��
��f�i�3�3�4�"�N�N�D�M��$�t�>�>�?�@�F��G�G�L�L���>�E�E�b�g�g�k�k�R�M�!#�E��.�.����T�<�<�=����(����R�W�W�_�_�T�[�[�9�:��
���w�w�|�|�D�,�7���7�7�=�=��&�$(�M��
�� ���|�&�'7�7��
�
,��rr rr
c�l���tjjtj|j
gt
|������|j�|tjj��st|��t�d�5}|j�}ddd�tjj���dtf��fd�}n	|jj��}d}j#|j$��|fS#1swY�rxYw#t $r}t|�|�d}~wwxYw)N�rbrc���tjj��xr"tjj���k(Sr<)rr�isfilerW)rYrSs��r�
up_to_datez,PackageLoader.get_source.<locals>.up_to_date_s/����w�w�~�~�a�(�I�R�W�W�-=�-=�a�-@�E�-I�Ir)rrr_rZr[r�rr�r�r�openr\rWrEr��get_datarXr]rM)	r&r r
r`r6r��erYrSs	       @@rr'zPackageLoader.get_sourceJs���
�G�G����N�N�4�.�.�O�1D�X�1N�O�
��
�=�=� ��7�7�>�>�!�$�&�x�0�0��a���
"�!������
"��G�G�$�$�Q�'�E�
J��
J�

8����.�.�q�1���J��}�}�T�]�]�+�Q�
�:�:�)
"�
"���
8�&�x�0�a�7��
8�s$�D
�D�
D�	D3�"D.�.D3c���g}|j��t|j�}tj|j�D]L\�}}�|djtjj��|j�fd�|D���N�n(t|jd�std��|jt|j�djtjj�tjjz}t|�}|jjj�D]q}|j|�s�|dtjjk7s�6|j||dj!tjjd���s|j#�|S)Nc3��K�|]L}tjj�|�jtjjd����Ny�w)rN)rrr[rhr)�.0r,rms  �r�	<genexpr>z/PackageLoader.list_templates.<locals>.<genexpr>ys=��������G�G�L�L��$�/�7�7������S�I��s�AA�_fileszFThis zip import does not have the required metadata to list templates.���r)r�rfr�rre�lstriprrr��hasattrr�r)r��keys�
startswithrrh�sort)r&�results�offsetrnro�prefixr,rms       @rr+zPackageLoader.list_templatespsj���!���=�=� ���,�,�-�F�)+����1D�1D�)E�
�%���I�!�&�'�*�1�1�"�'�'�+�+�>������ )���
��4�<�<��2��3����#�#�C��
�
�$6�$8�9�@�@������M��'�'�+�+��
���[�F����+�+�0�0�2�
L���?�?�6�*�t�B�x�2�7�7�;�;�/F��N�N�4���=�#8�#8������c�#J�K�
L�
	�����r)�	templatesrp)r%r=r>r?r@rTrArBrCrDrEr'rFr+rIrrruru�s����F*��	9,��9,��9,��	9,�

�9,�v$;�(�$;�47�$;�	
����c�1�:�:�a�j�j��T��&:�;�;�	<�$;�L!����s��!rruc��eZdZdZdej
eefddfd�Zdddedejedejge
fffd	�Zdejefd
�Z
y)�
DictLoaderaLoads a template from a Python dict mapping template names to
    template source.  This loader is useful for unittesting:

    >>> loader = DictLoader({'index.html': 'source here'})

    Because auto reloading is rarely useful this is disabled per default.
    �mappingrNc��||_yr<)r�)r&r�s  rrTzDictLoader.__init__��	����rr rr
c�l������jvr�j���d���fd�fSt���)Nc�@����jj��k(Sr<)r��get)r&r6r
s���r�<lambda>z'DictLoader.get_source.<locals>.<lambda>�s����4�<�<�3C�3C�H�3M�)M�r)r�r)r&r r
r6s` `@rr'zDictLoader.get_source�s8����t�|�|�#��\�\�(�+�F��4�!M�M�M��x�(�(rc�,�t|j�Sr<)rjr�r*s rr+zDictLoader.list_templates�s���d�l�l�#�#r)r%r=r>r?rA�Mappingr@rTrBrDrEr'rFr+rIrrr�r��su�����	�	�#�s�(� 3����)�(�)�47�)�	
����d�A�J�J�r�4�x�0�0�	1�)�$����s��$rr�c
�p�eZdZdZdej
egejejeejeejeejej
ge
ffffddfd�Zdddedejeejeejej
ge
fffd	�Zy)
�FunctionLoadera�A loader that is passed a function which does the loading.  The
    function receives the name of the template and has to return either
    a string with the template source, a tuple in the form ``(source,
    filename, uptodatefunc)`` or `None` if the template does not exist.

    >>> def load_template(name):
    ...     if name == 'index.html':
    ...         return '...'
    ...
    >>> loader = FunctionLoader(load_template)

    The `uptodatefunc` is a function that is called if autoreload is enabled
    and has to return `True` if the template is still up to date.  For more
    details have a look at :meth:`BaseLoader.get_source` which has the same
    return value.
    �	load_funcrNc��||_yr<)r�)r&r�s  rrTzFunctionLoader.__init__�s��#��rr rr
c�l�|j|�}|�t|��t|t�r|ddfS|Sr<)r�rrPr@)r&r r
�rvs    rr'zFunctionLoader.get_source�s=���^�^�H�
%��
�:�"�8�,�,��b�#���t�T�>�!��	r)
r%r=r>r?rArDr@rCrqrBrErTr'rIrrr�r��s����"#��:�:�
�E�
�J�J���������a�j�j��o�q�z�z�!�*�*�R�QU�X�BV�7W�!W�X�X��
�
�
�#�
�#��(��47��	
����a�j�j��o�q�z�z�!�*�*�R��X�2F�'G�G�	H�rr�c��eZdZdZ	ddej
eefdeddfd�Zdedejeeffd�Z
d	d
dedejeejeejejge
fffd�Ze	dd	d
ded
ejej eej"fddfd��Zdej&efd�Zy)�PrefixLoaderaA loader that is passed a dict of loaders where each loader is bound
    to a prefix.  The prefix is delimited from the template by a slash per
    default, which can be changed by setting the `delimiter` argument to
    something else::

        loader = PrefixLoader({
            'app1':     PackageLoader('mypackage.app1'),
            'app2':     PackageLoader('mypackage.app2')
        })

    By loading ``'app1/index.html'`` the file from the app1 package is loaded,
    by loading ``'app2/index.html'`` the file from the second.
    r��	delimiterrNc� �||_||_yr<)r�r�)r&r�r�s   rrTzPrefixLoader.__init__�s�����"��rr
c��	|j|jd�\}}|j|}||fS#ttf$r}t|�|�d}~wwxYw)Nr)rr�r�r��KeyErrorr)r&r
r�r,rr�s      r�
get_loaderzPrefixLoader.get_loader�s]��	4�#�>�>�$�.�.�!�<�L�F�D��\�\�&�)�F��t�|����H�%�	4�"�8�,�!�3��	4�s�.4�A�A�Ar rc��|j|�\}}	|j||�S#t$r}t|�|�d}~wwxYwr<)r�r'r)r&r r
rr,r�s      rr'zPrefixLoader.get_source�sM�����x�0����	4��$�$�[�$�7�7���	4�#�8�,�!�3��	4�s�(�	A�=�Ar,r-rc��|j|�\}}	|j|||�S#t$r}t|�|�d}~wwxYwr<)r�r;r)r&r r,r-r�
local_namer�s       rr;zPrefixLoader.loadsN��"�_�_�T�2���
�	0��;�;�{�J��@�@���	0�#�4�(�a�/��	0�s�)�	A�>�Ac��g}|jj�D];\}}|j�D]#}|j||jz|z��%�=|Sr<)r��itemsr+rr�)r&�resultr�rr
s     rr+zPrefixLoader.list_templatessd����"�l�l�0�0�2�	B�N�F�F�"�1�1�3�
B���
�
�f�t�~�~�5��@�A�
B�	B��
r)rr<)r%r=r>r?rAr�r@rrTrBr�rCrDrEr'r	rGrHr;rFr+rIrrr�r��s���EH�#��y�y��j��1�#�>A�#�	
�#��3��1�7�7�:�s�?�+C��	4�(�	4�47�	4�	
����a�j�j��o�q�z�z�!�*�*�R��X�2F�'G�G�	H�	4��
=A�	0�"�0��0����A�,�,�S�!�%�%�Z�8�9�	0�

�0��0�����s��rr�c�X�eZdZdZdej
eddfd�Zdddedejeejeejejgefffd	�Z
e	dddd
edejejeej fddfd
��Zdej$efd�Zy)�ChoiceLoadera�This loader works like the `PrefixLoader` just that no prefix is
    specified.  If a template could not be found by one loader the next one
    is tried.

    >>> loader = ChoiceLoader([
    ...     FileSystemLoader('/path/to/user/templates'),
    ...     FileSystemLoader('/path/to/system/templates')
    ... ])

    This is useful if you want to allow users to override builtin templates
    from a different location.
    �loadersrNc��||_yr<)r�)r&r�s  rrTzChoiceLoader.__init__&r�rr rr
c��|jD]}	|j||�cSt|��#t$rY�/wxYwr<)r�r'r)r&r r
rs    rr'zChoiceLoader.get_source)sP���l�l�	�F�
��(�(��h�?�?�	�
�x�(�(��$�
��
�s�1�	=�=r,r-rc��|jD]}	|j|||�cSt|��#t$rY�0wxYwr<)r�r;r)r&r r,r-rs     rr;zChoiceLoader.load3sP���l�l�	�F�
��{�{�;��g�>�>�	�
�t�$�$��$�
��
�s�2�	>�>c��t�}|jD]!}|j|j���#t	|�Sr<)rdr��updater+rj)r&rkrs   rr+zChoiceLoader.list_templatesAs;������l�l�	2�F��L�L��.�.�0�1�	2��e�}�rr<)r%r=r>r?rArsrrTr@rBrCrDrEr'r	rGrHr;rFr+rIrrr�r�s������
�
�:� 6��4��)�(�)�47�)�	
����a�j�j��o�q�z�z�!�*�*�R��X�2F�'G�G�	H�)��
=A�	%�"�%��%����A�,�,�S�!�%�%�Z�8�9�	%�

�%��%�����s��rr�c��eZdZdZy)�_TemplateModulez9Like a normal module but with support for weak referencesN)r%r=r>r?rIrrr�r�Hs��Crr�c�J�eZdZdZdZdejeejejejeejffddfd�Zededefd��Z
ededefd	��Ze	dd
ddedej ej"eej$fdd
fd��Zy)�ModuleLoadera6This loader loads templates from precompiled templates.

    Example usage:

    >>> loader = ChoiceLoader([
    ...     ModuleLoader('/path/to/compiled/templates'),
    ...     FileSystemLoader('/path/to/templates')
    ... ])

    Templates can be precompiled with :meth:`Environment.compile_templates`.
    FrrNc�^��dt|�d���t��}t|tj�rt|t
�r|g}|D�cgc]}t
j|���c}|_tj|�fd��tj�<||_
�|_ycc}w)N�_jinja2_module_templates_�xc�D��tjj�d�Sr<)�sys�modules�pop)r�rvs �rr�z'ModuleLoader.__init__.<locals>.<lambda>js���3�;�;�?�?�<��>�r)�idr�rPrrQr@rrR�__path__�weakref�proxyr�r��modulerv)r&r�modrSrvs    @rrTzModuleLoader.__init__[s����3�2�d�8�A�,�?���l�+���$����-��D�#�1F��6�D�.2�3���	�	�!��3���$+�M�M��>�%
����L�!����(����4s�
B*r,c�X�dt|jd��j�zS)N�tmpl_rp)r�encode�	hexdigest�r,s r�get_template_keyzModuleLoader.get_template_keyss$����d�k�k�'�2�3�=�=�?�?�?rc�2�tj|�dzS)Nz.py)r�r�r�s r�get_module_filenamez ModuleLoader.get_module_filenamews���,�,�T�2�U�:�:rr rr-rc�h�|j|�}|j�d|��}t|j|d�}|�0	t	|dddg�}tjj|d�|�i}|jj||j|�S#t
$r}t
|�|�d}~wwxYw)Nrr�)
r�rv�getattrr��
__import__�ImportErrorrr�r�r�r4�from_module_dict�__dict__)r&r r,r-�keyr�r�r�s        rr;zModuleLoader.load{s����#�#�D�)���%�%�&�a��u�-���d�k�k�6�4�0���;�
4� ���t�f�X�>��
�K�K�O�O�F�D�)��?��G��)�)�:�:�����w�
�	
���
4�&�t�,�!�3��
4�s�B�	B1� B,�,B1r<)r%r=r>r?r"rArqr@rrrrsrT�staticmethodr�r�r	rCrGrHr;rIrrr�r�Ls���
���)��G�G�C����a�j�j�����b�k�k�AQ�9R�.S�S�T�)�	
�)�0�@�s�@�s�@��@��;�#�;�#�;��;��
=A�	
�"�
��
����A�,�,�S�!�%�%�Z�8�9�	
�

�
��
rr�)&r?�importlib.utilr|rrZr��typingrAr�r��collectionsr�hashlibrr�typesr�
exceptionsr�utilsr	r
�
TYPE_CHECKINGr rrr@rFrrrKrur�r�r�r�r�r�rIrr�<module>r�s�����	��
������#��(��!��?�?�(�%��#��!�&�&��+��"k
�k
�\S�z�S�lc�J�c�L$��$�0*�Z�*�Z<�:�<�~-�:�-�`D�j�D�I
�:�I
r

Zerion Mini Shell 1.0