AlkantarClanX12

Your IP : 3.140.186.189


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__/environment.cpython-311.pyc

�

l��f����n�dZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%dd lm&Z&dd!lm'Z'dd"lm(Z(dd#l)m*Z*dd$l)m+Z+dd%l)m,Z,dd&l)m-Z-dd'l)m.Z.dd(l/m0Z0dd)l/m1Z1dd*l
m2Z2dd+l3m4Z4dd,l5m6Z6dd-l5m7Z7dd.l5m8Z8dd/l9m:Z:dd0l9m;Z;dd1l9m<Z<dd2l9m=Z=dd3l9m>Z>dd4l9m?Z?dd5l9m@Z@e?d6��ZAd7�ZBd8�ZCd9�ZDd:�ZEd;�ZFd<�ZGGd=�d>eH��ZIGd?�d@eH��ZJeGdA�dBeH����ZKGdC�dDeH��ZLe
GdE�dFeH����ZMeJeI_NdS)GzKClasses for managing templates and their runtime and compile time
options.
�N)�partial)�reduce)�Markup�)�nodes)�encode_filename)�implements_iterator)�implements_to_string)�	iteritems)�PY2)�PYPY)�reraise)�string_types)�	text_type)�
CodeGenerator)�generate)�BLOCK_END_STRING)�BLOCK_START_STRING)�COMMENT_END_STRING)�COMMENT_START_STRING)�DEFAULT_FILTERS)�DEFAULT_NAMESPACE)�DEFAULT_POLICIES)�
DEFAULT_TESTS)�KEEP_TRAILING_NEWLINE)�LINE_COMMENT_PREFIX)�LINE_STATEMENT_PREFIX)�
LSTRIP_BLOCKS)�NEWLINE_SEQUENCE)�TRIM_BLOCKS)�VARIABLE_END_STRING)�VARIABLE_START_STRING)�TemplateNotFound)�TemplateRuntimeError)�TemplatesNotFound)�TemplateSyntaxError)�UndefinedError)�	get_lexer)�TokenStream)�EvalContext)�Parser)�Context)�new_context)�	Undefined)�concat)�consume)�have_async_gen)�
import_string)�internalcode��LRUCache)�missing�
c�v�||f}	t|S#t$r||�xt|<}d|_|cYSwxYw)aReturn a new spontaneous environment. A spontaneous environment
    is used for templates created directly rather than through an
    existing environment.

    :param cls: Environment class to create.
    :param args: Positional arguments passed to environment.
    T)�_spontaneous_environments�KeyError�shared)�cls�args�key�envs    �r/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/environment.py�get_spontaneous_environmentrAAs^����+�C��(��-�-������/2�s�D�z�9�!�#�&����
��
�
�
����s��"8�8c�@�|dkrdS|dkriSt|��S)z*Return the cache class for the given size.rNr4)�sizes r@�create_cacherDSs*���q�y�y��t��a�x�x��	��D�>�>��c�b�|�dSt|��turiSt|j��S)z(Create an empty copy of the given cache.N)�type�dictr5�capacity)�caches r@�
copy_cacherK\s2���}��t�	
�e����	�	��	��E�N�#�#�#rEc��i}|D]9}t|t��rt|��}||��||j<�:|S)zwLoad the extensions from the list and bind it to the environment.
    Returns a dict of instantiated environments.
    )�
isinstancerr2�
identifier)�environment�
extensions�result�	extensions    r@�load_extensionsrSesV���F��>�>�	��i��.�.�	1�%�i�0�0�I�'0�y��'=�'=��y�#�$�$��MrEc��||z}t|t��r5	|���n#t$r}|�d|�d�}Yd}~nd}~wwxYwt	|���)Nz (z-; did you forget to quote the callable name?))rMr.�_fail_with_undefined_error�	Exceptionr$)�string�name�msg�es    r@�fail_for_missing_callabler[qs���
�4�-�C��$�	�"�"�S�	S��+�+�-�-�-�-���	S�	S�	S�KN�3�3�PQ�PQ�PQ�R�C�C�C�C�C�C�����	S����
�s�
#�
#�#s�1�
A
�A�A
c���t|jt��s
Jd���|j|jcxkr|jksnJd���|jdvs
Jd���|S)z*Perform a sanity check on the environment.zGundefined must be a subclass of undefined because filters depend on it.z;block, variable and comment start strings must be different)�
z
�
z3newline_sequence set to unknown line ending string.)�
issubclass�	undefinedr.�block_start_string�variable_start_string�comment_start_string�newline_sequence)rOs r@�_environment_sanity_checkre{s������y���Q�Q�P�Q�Q��	�&��,�	,�	,�	,�	,��+�	,�	,�	,�	,�	,�E�	,�	,�	,��'�,����=�	���
�rEc���eZdZdZdZdZdZdZeZ	e
Zee
eeeeeeeeeeddedddddddfd�Zd�Zd	�Zeeeeeeeeeeeeeeeeeeefd
�Zeed���Z d
�Z!d�Z"d�Z#	d&d�Z$d'd�Z%e&d'd���Z'd�Z(d'd�Z)d'd�Z*d'd�Z+d(d�Z,d�Z-e&d)d���Z.d*d�Z/						d+d�Z0d'd�Z1d,d�Z2d�Z3e&d ���Z4e&d'd!���Z5e&d'd"���Z6e&d'd#���Z7d'd$�Z8d%�Z9dS)-�Environmenta�The core component of Jinja is the `Environment`.  It contains
    important shared variables like configuration, filters, tests,
    globals and others.  Instances of this class may be modified if
    they are not shared and if no template was loaded so far.
    Modifications on environments after the first template was loaded
    will lead to surprising effects and undefined behavior.

    Here are the possible initialization parameters:

        `block_start_string`
            The string marking the beginning of a block.  Defaults to ``'{%'``.

        `block_end_string`
            The string marking the end of a block.  Defaults to ``'%}'``.

        `variable_start_string`
            The string marking the beginning of a print statement.
            Defaults to ``'{{'``.

        `variable_end_string`
            The string marking the end of a print statement.  Defaults to
            ``'}}'``.

        `comment_start_string`
            The string marking the beginning of a comment.  Defaults to ``'{#'``.

        `comment_end_string`
            The string marking the end of a comment.  Defaults to ``'#}'``.

        `line_statement_prefix`
            If given and a string, this will be used as prefix for line based
            statements.  See also :ref:`line-statements`.

        `line_comment_prefix`
            If given and a string, this will be used as prefix for line based
            comments.  See also :ref:`line-statements`.

            .. versionadded:: 2.2

        `trim_blocks`
            If this is set to ``True`` the first newline after a block is
            removed (block, not variable tag!).  Defaults to `False`.

        `lstrip_blocks`
            If this is set to ``True`` leading spaces and tabs are stripped
            from the start of a line to a block.  Defaults to `False`.

        `newline_sequence`
            The sequence that starts a newline.  Must be one of ``'\r'``,
            ``'\n'`` or ``'\r\n'``.  The default is ``'\n'`` which is a
            useful default for Linux and OS X systems as well as web
            applications.

        `keep_trailing_newline`
            Preserve the trailing newline when rendering templates.
            The default is ``False``, which causes a single newline,
            if present, to be stripped from the end of the template.

            .. versionadded:: 2.7

        `extensions`
            List of Jinja extensions to use.  This can either be import paths
            as strings or extension classes.  For more information have a
            look at :ref:`the extensions documentation <jinja-extensions>`.

        `optimized`
            should the optimizer be enabled?  Default is ``True``.

        `undefined`
            :class:`Undefined` or a subclass of it that is used to represent
            undefined values in the template.

        `finalize`
            A callable that can be used to process the result of a variable
            expression before it is output.  For example one can convert
            ``None`` implicitly into an empty string here.

        `autoescape`
            If set to ``True`` the XML/HTML autoescaping feature is enabled by
            default.  For more details about autoescaping see
            :class:`~markupsafe.Markup`.  As of Jinja 2.4 this can also
            be a callable that is passed the template name and has to
            return ``True`` or ``False`` depending on autoescape should be
            enabled by default.

            .. versionchanged:: 2.4
               `autoescape` can now be a function

        `loader`
            The template loader for this environment.

        `cache_size`
            The size of the cache.  Per default this is ``400`` which means
            that if more than 400 templates are loaded the loader will clean
            out the least recently used template.  If the cache size is set to
            ``0`` templates are recompiled all the time, if the cache size is
            ``-1`` the cache will not be cleaned.

            .. versionchanged:: 2.8
               The cache size was increased to 400 from a low 50.

        `auto_reload`
            Some loaders load templates from locations where the template
            sources may change (ie: file system or database).  If
            ``auto_reload`` is set to ``True`` (default) every time a template is
            requested the loader checks if the source changed and if yes, it
            will reload the template.  For higher performance it's possible to
            disable that.

        `bytecode_cache`
            If set to a bytecode cache object, this object will provide a
            cache for the internal Jinja bytecode so that templates don't
            have to be parsed if they were not changed.

            See :ref:`bytecode-cache` for more information.

        `enable_async`
            If set to true this enables async template execution which allows
            you to take advantage of newer Python features.  This requires
            Python 3.6 or later.
    FN�Ti�c��||_||_||_||_||_||_||_||_|	|_|
|_	||_
||_||_||_
||_||_t!j��|_t'j��|_t+j��|_||_t1|��|_||_||_t9j��|_t=||
��|_||_ |j otB|_"|j"rddl#m$}tK|��dS)Nr)�asyncsupport)&ra�block_end_stringrb�variable_end_stringrc�comment_end_string�line_statement_prefix�line_comment_prefix�trim_blocks�
lstrip_blocksrd�keep_trailing_newliner`�	optimized�finalize�
autoescaper�copy�filtersr�testsr�globals�loaderrDrJ�bytecode_cache�auto_reloadr�policiesrSrP�enable_asyncr1�is_async�rjre)�selfrarkrbrlrcrmrnrorprqrdrrrPrsr`rtrurz�
cache_sizer|r{r~rjs                        r@�__init__zEnvironment.__init__ sI��J#5��� 0���%:��"�#6�� �$8��!�"4���%:��"�#6�� �&���*��� 0���%:��"�#���"��� ��
�$���'�+�-�-���"�'�)�)��
�(�-�/�/������!�*�-�-��
�,���&���)�-�/�/��
�*�$�
�;�;���(����)�<�n��
��=�	'�&�&�&�&�&�&�!�$�'�'�'�'�'rEc�X�|j�t||g����dS)z\Adds an extension after the environment was created.

        .. versionadded:: 2.5
        N)rP�updaterS)r�rRs  r@�
add_extensionzEnvironment.add_extensionqs,��
	
�����t�i�[�A�A�B�B�B�B�BrEc�r�t|��D]&\}}t||��st|||���'dS)z�Add the items to the instance of the environment if they do not exist
        yet.  This is used by :ref:`extensions <writing-extensions>` to register
        callbacks and configuration values without breaking inheritance.
        N)r�hasattr�setattr)r��
attributesr>�values    r@�extendzEnvironment.extendxsN��
$�J�/�/�	*�	*�J�C���4��%�%�
*���c�5�)�)�)��	*�	*rEc��tt����}|d=|d=|d=t�|j��}|j�|j��d|_||_t|��D]\}}|turt|||��� |turt|��|_
nt|j
��|_
i|_t|j��D]"\}}|�|��|j|<�#|tur(|j�t#||����t%|��S)agCreate a new overlay environment that shares all the data with the
        current environment except for cache and the overridden attributes.
        Extensions cannot be removed for an overlayed environment.  An overlayed
        environment automatically gets all the extensions of the environment it
        is linked to plus optional extra extensions.

        Creating overlays should happen after the initial environment was set
        up completely.  Not all attributes are truly linked, some are just
        copied over so modifications on the original environment may not shine
        through.
        r�r�rPT)rH�locals�object�__new__�	__class__�__dict__r��	overlayed�	linked_torr6r�rDrJrKrP�bindrSre)r�rarkrbrlrcrmrnrorprqrPrsr`rtrurzr�r|r{r=�rvr>r�s                        r@�overlayzEnvironment.overlay�s<��B�F�H�H�~�~����L�$�|�,�d�<�.@�
�^�^�D�N�
+�
+��
����4�=�)�)�)�������#�D�/�/�	(�	(�J�C���G�#�#���C��'�'�'���W�$�$�#�J�/�/�B�H�H�!�$�*�-�-�B�H���
�#�D�O�4�4�	0�	0�J�C��!&���B���B�M�#����W�$�$��M� � ���Z�!@�!@�A�A�A�(��,�,�,rEzThe lexer for this environment.)�docc�n�tt|j���d������S)z)Iterates over the extensions by priority.c��|jS�N)�priority��xs r@�<lambda>z-Environment.iter_extensions.<locals>.<lambda>�s��1�:�rE)r>)�iter�sortedrP�values�r�s r@�iter_extensionszEnvironment.iter_extensions�s/���F�4�?�1�1�3�3�9M�9M�N�N�N�O�O�OrEc�,�	||S#tttf$rrt|t��rC	t|��}	t
||��cYS#t$rYnwxYw#t$rYnwxYw|�||���cYSwxYw)z:Get an item or attribute of an object but prefer the item.��objrX)	�AttributeError�	TypeError�LookupErrorrMr�str�getattrrVr`)r�r��argument�attrs    r@�getitemzEnvironment.getitem�s���
	:��x�=� ���	�;�7�	:�	:�	:��(�L�1�1�	
���x�=�=�D��&�s�D�1�1�1�1�1��)�����������!�����D������>�>�c��>�9�9�9�9�9�	:���sP�
�,B�A)�A�B�
A&�#B�%A&�&B�)
A6�3B�5A6�6B�Bc��	t||��S#t$rYnwxYw	||S#tttf$r|�||���cYSwxYw)z�Get an item or attribute of an object but prefer the attribute.
        Unlike :meth:`getitem` the attribute *must* be a bytestring.
        r�)r�r�r�r�r`)r�r��	attributes   r@r�zEnvironment.getattr�s���	��3�	�*�*�*���	�	�	��D�	����	;��y�>�!���;��7�	;�	;�	;��>�>�c�	�>�:�:�:�:�:�	;���s��
��+�.A�Ac���|j�|��}|�td|��|gt|pd��z}t	|dd��dur(|�td���|�d|��nnt	|d	d��dur2|�|�|j}nt|��}|�d|��n)t	|d
d��dur|�d|��||i|pi��S)aWInvokes a filter on a value the same way the compiler does it.

        Note that on Python 3 this might return a coroutine in case the
        filter is running from an environment in async mode and the filter
        supports async execution.  It's your responsibility to await this
        if needed.

        .. versionadded:: 2.7
        Nzno filter named %rrh�
contextfilterFTz2Attempted to invoke context filter without contextr�evalcontextfilter�environmentfilter)	rw�getr[�listr�r$�insert�eval_ctxr*)r�rXr�r=�kwargs�contextr��funcs        r@�call_filterzEnvironment.call_filter�s(���|����%�%���<�%�&:�D�A�A�A��w��d�j�b�)�)�)���4��%�0�0�D�8�8���*�H����
�K�K��7�#�#�#�#�
�T�.��
6�
6�$�
>�
>����&�&�/�H�H�*�4�0�0�H��K�K��8�$�$�$�$�
�T�.��
6�
6�$�
>�
>��K�K��4� � � ��t�T�,�f�l��,�,�,rEc�z�|j�|��}|�td|��||g|pd�Ri|pi��S)zdInvokes a test on a value the same way the compiler does it.

        .. versionadded:: 2.7
        Nzno test named %rrh)rxr�r[)r�rXr�r=r�r�s      r@�	call_testzEnvironment.call_testsU��
�z�~�~�d�#�#���<�%�&8�$�?�?�?��t�E�;�T�Z�R�;�;�;�V�\�r�;�;�;rEc��	|�|||��S#t$r|�|���YdSwxYw)a�Parse the sourcecode and return the abstract syntax tree.  This
        tree of nodes is used by the compiler to convert the template into
        executable source- or bytecode.  This is useful for debugging or to
        extract information from templates.

        If you are :ref:`developing Jinja extensions <writing-extensions>`
        this gives you a good overview of the node tree generated.
        ��sourceN)�_parser&�handle_exception�r�r�rX�filenames    r@�parsezEnvironment.parse
sX��	1��;�;�v�t�X�6�6�6��"�	1�	1�	1��!�!��!�0�0�0�0�0�0�	1���s�� =�=c�d�t|||t|�������S)z8Internal parsing function used by `parse` and `compile`.)r+rr�r�s    r@r�zEnvironment._parses*���d�F�D�/�(�*C�*C�D�D�J�J�L�L�LrEc��t|��}	|j�|||��S#t$r|�|���YdSwxYw)a�Lex the given sourcecode and return a generator that yields
        tokens as tuples in the form ``(lineno, token_type, value)``.
        This can be useful for :ref:`extension development <writing-extensions>`
        and debugging templates.

        This does not perform preprocessing.  If you want the preprocessing
        of the extensions to be applied you have to filter source through
        the :meth:`preprocess` method.
        r�N)r�lexer�	tokeniterr&r�r�s    r@�lexzEnvironment.lexsk���6�"�"��	1��:�'�'���h�?�?�?��"�	1�	1�	1��!�!��!�0�0�0�0�0�0�	1���s�-� A�Ac�n���t��fd�|���t|����S)z�Preprocesses the source with all extensions.  This is automatically
        called for all parsing and compiling methods but *not* for :meth:`lex`
        because there you usually only want the actual source tokenized.
        c�2��|�|����Sr�)�
preprocess)�srZr�rXs  ��r@r�z(Environment.preprocess.<locals>.<lambda>3s������a��x�8�8�rE)rr�rr�s  ``r@r�zEnvironment.preprocess-sA����
�8�8�8�8�8�� � �"�"��f���
�
�	
rEc��|�|||��}|j�||||��}|���D]=}|�|��}t|t��st
|||��}�>|S)z�Called by the parser to do the preprocessing and filtering
        for all the extensions.  Returns a :class:`~jinja2.lexer.TokenStream`.
        )r�r��tokenizer��
filter_streamrMr))r�r�rXr��state�stream�exts       r@�	_tokenizezEnvironment._tokenize8s��������x�8�8����$�$�V�T�8�U�C�C���'�'�)�)�	=�	=�C��&�&�v�.�.�F��f�k�2�2�
=�$�V�T�8�<�<����
rEc�6�t||||||j���S)z|Internal hook that can be overridden to hook a different generate
        method in.

        .. versionadded:: 2.5
        )�
defer_initrs)rrs)r�r�rXr�r�s     r@�	_generatezEnvironment._generateDs/�������!��n�

�
�
�	
rEc�$�t||d��S)z{Internal hook that can be overridden to hook a different compile
        method in.

        .. versionadded:: 2.5
        �exec)�compile)r�r�r�s   r@�_compilezEnvironment._compileSs���v�x��0�0�0rEc�@�d}	t|t��r|}|�|||��}|�||||���}|r|S|�d}nt	|��}|�||��S#t$r|�|���YdSwxYw)a�Compile a node or template source code.  The `name` parameter is
        the load name of the template after it was joined using
        :meth:`join_path` if necessary, not the filename on the file system.
        the `filename` parameter is the estimated filename of the template on
        the file system.  If the template came from a database or memory this
        can be omitted.

        The return value of this method is a python code object.  If the `raw`
        parameter is `True` the return value will be a string with python
        code equivalent to the bytecode returned otherwise.  This method is
        mainly used internally.

        `defer_init` is use internally to aid the module code generator.  This
        causes the generated code to be able to import without the global
        environment variable to be set.

        .. versionadded:: 2.4
           `defer_init` parameter added.
        N)r�z
<template>r�)rMrr�r�rr�r&r�)r�r�rXr��rawr��source_hints       r@r�zEnvironment.compile[s���*��
	6��&�,�/�/�
=�$�����V�T�8�<�<���^�^�F�D�(�z�^�R�R�F��
��
���'���*�8�4�4���=�=���2�2�2��"�	6�	6�	6��!�!��!�5�5�5�5�5�5�	6���s�A
A9�)A9�9 B�Bc��t||d���}	|���}|jjs!t	d|jjjdd���|�|��n9#t$r,tj	���|�
|���YnwxYwtjtj
dd��|d�	��g}|�tj|d�	����}t!||��S)
a�A handy helper method that returns a callable that accepts keyword
        arguments that appear as variables in the expression.  If called it
        returns the result of the expression.

        This is useful if applications want to use the same rules as Jinja
        in template "configuration files" or similar situations.

        Example usage:

        >>> env = Environment()
        >>> expr = env.compile_expression('foo == 42')
        >>> expr(foo=23)
        False
        >>> expr(foo=42)
        True

        Per default the return value is converted to `None` if the
        expression returns an undefined value.  This can be changed
        by setting `undefined_to_none` to `False`.

        >>> env.compile_expression('var')() is None
        True
        >>> env.compile_expression('var', undefined_to_none=False)()
        Undefined

        .. versionadded:: 2.1
        �variable)r�zchunk after expressionNr�rQ�storer)�lineno)r+�parse_expressionr��eosr&�currentr��set_environment�sys�exc_infor�r�Assign�Name�from_string�Template�TemplateExpression)r�r��undefined_to_none�parser�expr�body�templates       r@�compile_expressionzEnvironment.compile_expression�s��8��f�J�7�7�7��		5��*�*�,�,�D��=�$�
�)�,�f�m�.C�.J�D�RV����
� � ��&�&�&�&��"�	5�	5�	5��|�~�~�)��%�%�V�%�4�4�4���	5������U�Z��'�:�:�D��K�K�K�L���#�#�E�N�4��$B�$B�$B�C�C��!�(�,=�>�>�>s�AA+�+3B!� B!�deflatedc�������ddlm}|�d�}|r�trtr$ddl}	|	�dtd���d	}nZddl}
ddl}|
�	��d
�
d��z}tjdkr|d
�
d��z
}����fd�}
��=ddl
m}m�m}m}|�dt%||�������|d�z��nAt&j����st'j���|d�z��	|�||��D]�}|j�||��\}}}	|�|||dd��}n+#t6$r}|s�|d|�d|����Yd}~�_d}~wwxYw|�|��}|r]|�|t=|����}|
|dz||�|��z��|d|�d|dz������|
||��|d|�d|������	�r�� ��n#�r�� ��wwxYw|d��dS)a;Finds all the templates the loader can find, compiles them
        and stores them in `target`.  If `zip` is `None`, instead of in a
        zipfile, the templates will be stored in a directory.
        By default a deflate zip algorithm is used. To switch to
        the stored algorithm, `zip` can be set to ``'stored'``.

        `extensions` and `filter_func` are passed to :meth:`list_templates`.
        Each template returned will be compiled to the target folder or
        zipfile.

        By default template compilation errors are ignored.  In case a
        log function is provided, errors are logged.  If you want template
        syntax errors to abort the compilation you can set `ignore_errors`
        to `False` and you will get an exception on syntax errors.

        If `py_compile` is set to `True` .pyc files will be written to the
        target instead of standard .py files.  This flag does not do anything
        on pypy and Python 3 where pyc files are not picked up by itself and
        don't give much benefit.

        .. versionadded:: 2.4
        r)�ModuleLoaderNc��dSr�rhr�s r@�log_functionz3Environment.compile_templates.<locals>.log_function�s���rErzV'py_compile=True' has no effect on PyPy or Python 3 and will be removed in version 3.0�)�
stacklevelFuÿÿÿÿziso-8859-15)�r�zc�l���r*�|��}d|_��||��dSt|t��r|�d��}ttj��|��d��5}|�	|��ddd��dS#1swxYwYdS)Ni��utf8�wb)
�
external_attr�writestrrMr�encode�open�os�path�join�write)r��data�info�f�ZipInfo�target�zip�zip_files    ����r@�
write_filez1Environment.compile_templates.<locals>.write_file�s�����	
"��w�x�(�(��%0��"��!�!�$��-�-�-�-�-��d�I�.�.�/��;�;�v�.�.�D��"�'�,�,�v�x�8�8�$�?�?�"�1��G�G�D�M�M�M�"�"�"�"�"�"�"�"�"�"�"�"����"�"�"�"�"�"s�B)�)B-�0B-)�ZipFiler
�ZIP_DEFLATED�
ZIP_STORED�w)r��storedzCompiling into Zip archive "%s"zCompiling into folder "%s"TzCould not compile "z": �czByte-compiled "z" as z
Compiled "zFinished compiling templates)!�loadersr�rr
�warnings�warn�DeprecationWarning�imp�marshal�	get_magicrr��version_info�zipfilerr
rrrHrr�isdir�makedirs�list_templatesrz�
get_sourcer�r&�get_module_filenamer�r�dumps�close)r�rrP�filter_funcrr��
ignore_errors�
py_compiler�rrr�	py_headerrrrrrXr�r��_�coderZrr
rs `  `                   @@r@�compile_templateszEnvironment.compile_templates�s�������@	*�)�)�)�)�)���
�
�
��	K��
K�$�
K������
�
�<�&� �	����#�
�
��
�
�
������M�M�O�O�.A�.H�.H��.W�.W�W�	��#�v�-�-��!4�!;�!;�M�!J�!J�J�I�
	"�
	"�
	"�
	"�
	"�
	"�
	"�
	"��?�J�J�J�J�J�J�J�J�J�J�J�J��w���T�<�
�K�K�K�C�P���H�
�L�:�V�C�D�D�D�D��7�=�=��(�(�
$���F�#�#�#��L�5��>�?�?�?�	!��+�+�J��D�D�
K�
K��&*�k�&<�&<�T�4�&H�&H�#���!���<�<���h��d�K�K�D�D��*����(��� �L�L����q�q�!I�J�J�J��H�H�H�H�����	����(�;�;�D�A�A���K��
�
�d�O�H�,E�,E�F�F�A��J�x�#�~�y�7�=�=��;K�;K�/K�L�L�L� �L�L�t�t�t�X�PS�^�^�!T�U�U�U�U��J�x��.�.�.� �L�L�$�$�$���!I�J�J�J�J�%
K�(�
!���� � � ����
!���� � � � �
!����	��3�4�4�4�4�4s7�'7I�E9�8I�9
F!�F�I�F!�!BI�I'c����|j���}����td����fd�����fd�|D��}|S)a�Returns a list of templates for this environment.  This requires
        that the loader supports the loader's
        :meth:`~BaseLoader.list_templates` method.

        If there are other files in the template folder besides the
        actual templates, the returned list can be filtered.  There are two
        ways: either `extensions` is set to a list of file extensions for
        templates, or a `filter_func` can be provided which is a callable that
        is passed a template name and should return `True` if it should end up
        in the result list.

        If the loader does not support that, a :exc:`TypeError` is raised.

        .. versionadded:: 2.4
        Nz<either extensions or filter_func can be passed, but not bothc�H��d|vo|�dd��d�vS)N�.r)�rsplit)r�rPs �r@r(z/Environment.list_templates.<locals>.filter_func2s*����a�x�E�A�H�H�S�!�$4�$4�Q�$7�:�$E�ErEc�*��g|]}�|���
|��Srhrh)�.0rXr(s  �r@�
<listcomp>z.Environment.list_templates.<locals>.<listcomp>6s(���A�A�A�d�{�{�4�/@�/@�A�T�A�A�ArE)rzr#r�)r�rPr(�namess `` r@r#zEnvironment.list_templatess~���� ��*�*�,�,���!��&��R����
F�
F�
F�
F�
F��"�A�A�A�A�e�A�A�A�E��rEc�8�ddlm}t||����dS)z�Exception handling helper.  This is used internally to either raise
        rewritten exceptions or return a rendered traceback for the template.
        r)�rewrite_traceback_stackr�N)�debugr8r)r�r�r8s   r@r�zEnvironment.handle_exception:s6��	3�2�2�2�2�2��(�(��7�7�7�8�8�8�8rEc��|S)a�Join a template with the parent.  By default all the lookups are
        relative to the loader root so this method returns the `template`
        parameter unchanged, but if the paths should be relative to the
        parent template, this function can be used to calculate the real
        template name.

        Subclasses may override this method and implement template path
        joining here.
        rh)r�r��parents   r@�	join_pathzEnvironment.join_pathBs	���rEc�(�|j�td���tj|j��|f}|j�,|j�|��}|�|jr|jr|S|j�|||��}|j�
||j|<|S)Nz(no loader for this environment specified)	rzr��weakref�refrJr�r|�
is_up_to_date�load)r�rXry�	cache_keyr�s     r@�_load_templatezEnvironment._load_templateNs����;���F�G�G�G��[���-�-�t�4�	��:�!��z�~�~�i�0�0�H��#��$�$�(0�(>�$� ���;�#�#�D�$��8�8���:�!�$,�D�J�y�!��rEc��t|t��r|S|�|�||��}|�||�|����S)a�Load a template from the loader.  If a loader is configured this
        method asks the loader for the template and returns a :class:`Template`.
        If the `parent` parameter is not `None`, :meth:`join_path` is called
        to get the real template name before loading.

        The `globals` parameter can be used to provide template wide globals.
        These variables are available in the context at render time.

        If the template does not exist a :exc:`TemplateNotFound` exception is
        raised.

        .. versionchanged:: 2.4
           If `name` is a :class:`Template` object it is returned from the
           function unchanged.
        )rMr�r<rC�make_globals)r�rXr;rys    r@�get_templatezEnvironment.get_template^sX��"�d�H�%�%�	��K����>�>�$��/�/�D��"�"�4��):�):�7�)C�)C�D�D�DrEc��t|t��r|���|std����|�|��}|D]b}t|t
��r|cS|�|�||��}	|�||��cS#ttf$rY�_wxYwt|���)ahWorks like :meth:`get_template` but tries a number of templates
        before it fails.  If it cannot find any of the templates, it will
        raise a :exc:`TemplatesNotFound` exception.

        .. versionchanged:: 2.11
            If names is :class:`Undefined`, an :exc:`UndefinedError` is
            raised instead. If no templates were found and names
            contains :class:`Undefined`, the message is more helpful.

        .. versionchanged:: 2.4
           If `names` contains a :class:`Template` object it is returned
           from the function unchanged.

        .. versionadded:: 2.3
        z0Tried to select from an empty list of templates.)�message)
rMr.rUr%rEr�r<rCr#r')r�r6r;ryrXs     r@�select_templatezEnvironment.select_templateus���"�e�Y�'�'�	/��,�,�.�.�.��	�#�O����
��#�#�G�,�,���	�	�D��$��)�)�
������!��~�~�d�F�3�3��
��*�*�4��9�9�9�9�9��$�n�5�
�
�
���
������&�&�&s�B�B3�2B3c���t|ttf��r|�|||��St|t��r|S|�|||��S)z�Does a typecheck and dispatches to :meth:`select_template`
        if an iterable of template names is given, otherwise to
        :meth:`get_template`.

        .. versionadded:: 2.3
        )rMrr.rFr�rI)r��template_name_or_listr;rys    r@�get_or_select_templatez"Environment.get_or_select_template�sg���+�l�I�-F�G�G�	)��$�$�%:�F�G�L�L�L�
�-�x�
8�
8�	)�(�(��#�#�$9�6�7�K�K�KrEc��|�|��}|p|j}|�||�|��|d��S)zuLoad a template from a string.  This parses the source given and
        returns a :class:`Template` object.
        N)rE�template_class�	from_coder�)r�r�ryrNr<s     r@r�zEnvironment.from_string�sH���#�#�G�,�,���3�� 3���}�}�T�4�<�<��#7�#7��$�G�G�GrEc�8�|s|jSt|jfi|��S)zReturn a dict for the globals.)ryrH)r��ds  r@rEzEnvironment.make_globals�s*���	 ��<���D�L�&�&�A�&�&�&rE)NNNN)NN)F)NNFF)T)NNr�NTFr�):�__name__�
__module__�__qualname__�__doc__�	sandboxedr�r�r;r�code_generator_classr,�
context_classrrr"r!rrrrr rrrr.r�r�r�r6r��propertyr(r�r�r�r�r�r�r3r�r�r�r�r�r�r�r�r�r.r#r�r<rCrFrIrLr�rErhrEr@rgrg�sh������x�x�|�I��I��I��F�)���M�.�)�3�/�1�-�3�/��#�)�3�����������/O(�O(�O(�O(�bC�C�C�*�*�*�#� �%�#�$�"�%�#������������)8-�8-�8-�8-�t
�H�Y�$E�F�F�F�E�P�P�P�:�:�:�";�;�;�KO�-�-�-�-�B<�<�<�<��1�1�1��\�1�M�M�M�1�1�1�1� 	
�	
�	
�	
�
�
�
�
�

�

�

�

�1�1�1��"6�"6�"6��\�"6�H*?�*?�*?�*?�^������l5�l5�l5�l5�\����@9�9�9�9�
�
�
��
�
��\�
��E�E�E��\�E�,�!'�!'�!'��\�!'�F�L�L�L��\�L�H�H�H�H�'�'�'�'�'rErgc� �eZdZdZeZeeee	e
eee
eeeeddedddfd�Zedd���Zed���Zed	���Zd
�Zd�Zd�Zd
�Zd�Zdd�Zdd�Zdd�Ze d���Z!e"d���Z#d�Z$e"d���Z%e"d���Z&d�Z'dS)r�a�The central template object.  This class represents a compiled template
    and is used to evaluate it.

    Normally the template object is generated from an :class:`Environment` but
    it also has a constructor that makes it possible to create a template
    instance directly using the constructor.  It takes the same arguments as
    the environment constructor but it's not possible to specify a loader.

    Every template object has a few methods and members that are guaranteed
    to exist.  However it's important that a template object should be
    considered immutable.  Modifications on the object are not supported.

    Template objects created from the constructor rather than an environment
    do have an `environment` attribute that points to a temporary environment
    that is probably shared with other templates created with the constructor
    and compatible settings.

    >>> template = Template('Hello {{ name }}!')
    >>> template.render(name='John Doe') == u'Hello John Doe!'
    True
    >>> stream = template.stream(name='John Doe')
    >>> next(stream) == u'Hello John Doe!'
    True
    >>> next(stream)
    Traceback (most recent call last):
        ...
    StopIteration
    rhTNFc��t|j||||||||	|
|||
t|��||||dddd|��}|�||���S)NrF)rN)rA�environment_class�	frozensetr�)r<r�rarkrbrlrcrmrnrorprqrdrrrPrsr`rtrur~r?s                     r@r�zTemplate.__new__�s{��,*��!���!�� ��!�����!��j�!�!������
����/
�
��2���v�c��:�:�:rEc�v�||jd�}t||��|�|||��}||_|S)z�Creates a template object from compiled code and the globals.  This
        is used by the loaders and environment to create a template object.
        )rO�__file__)�co_filenamer��_from_namespace�	_uptodate)r<rOr-ry�uptodate�	namespacer�s       r@rOzTemplate.from_code	sG��
%0�T�=M�N�N�	��T�9����
�
 �
 ��i��
A�
A������	rEc�0�|�|||��S)z�Creates a template object from a module.  This is used by the
        module loader to create a template object.

        .. versionadded:: 2.4
        )ra)r<rO�module_dictrys    r@�from_module_dictzTemplate.from_module_dicts���"�"�;��W�E�E�ErEc��t�|��}||_||_|d|_|d|_|d|_|d|_d|_|d|_	d|_
||d<||d<|S)NrXr_�blocks�root�
debug_inforO�__jinja_template__)r�r�rOryrXr�ri�root_render_func�_module�_debug_inforb)r<rOrdry�ts     r@razTemplate._from_namespaces����N�N�3����#��
���	��6�"����z�*��
��X�&���'�v�.�����	�"�,�/��
����$/�	�-� �*+�	�&�'��rEc���t|i|��}	t|�|�|������S#t$r|j���YdSwxYw)a�This method accepts the same arguments as the `dict` constructor:
        A dict, a dict subclass or some keyword arguments.  If no arguments
        are given the context will be empty.  These two calls do the same::

            template.render(knights='that say nih')
            template.render({'knights': 'that say nih'})

        This will return the rendered template as unicode string.
        N)rHr/rmr-rVrOr�)r�r=r��varss    r@�renderzTemplate.render4s~���T�$�V�$�$��	0��$�/�/��0@�0@��0F�0F�G�G�H�H�H���	0�	0�	0���-�-�/�/�/�/�/�/�	0���s�4A�#A*�)A*c� �td���)a.This works similar to :meth:`render` but returns a coroutine
        that when awaited returns the entire rendered template string.  This
        requires the async feature to be enabled.

        Example usage::

            await template.render_async(knights='that say nih; asynchronously')
        �8This feature is not available for this version of Python��NotImplementedError�r�r=r�s   r@�render_asynczTemplate.render_asyncDs��"�F�
�
�	
rEc�6�t|j|i|����S)z[Works exactly like :meth:`generate` but returns a
        :class:`TemplateStream`.
        )�TemplateStreamrrxs   r@r�zTemplate.streamRs#���m�d�m�T�<�V�<�<�=�=�=rEc/��K�t|i|��}	|�|�|����D]}|V��dS#t$r|j���V�YdSwxYw)ajFor very large templates it can be useful to not render the whole
        template at once but evaluate each statement after another and yield
        piece for piece.  This method basically does exactly that and returns
        a generator that yields one item after another as unicode strings.

        It accepts the same arguments as :meth:`render`.
        N)rHrmr-rVrOr�)r�r=r�rr�events     r@rzTemplate.generateXs������T�$�V�$�$��	6��.�.�t�/?�/?��/E�/E�F�F�
�
�������
�
���	6�	6�	6��"�3�3�5�5�5�5�5�5�5�5�	6���s�/A�%A*�)A*c� �td���)zsAn async version of :meth:`generate`.  Works very similarly but
        returns an async iterator instead.
        rurvrxs   r@�generate_asynczTemplate.generate_asyncgs��
"�F�
�
�	
rEc	�T�t|j|j|j|||j|��S)a^Create a new :class:`Context` for this template.  The vars
        provided will be passed to the template.  Per default the globals
        are added to the context.  If shared is set to `True` the data
        is passed as is to the context without adding the globals.

        `locals` can be a dict of local variables for internal usage.
        )r-rOrXriry�r�rrr;r�s    r@r-zTemplate.new_contextps/�����d�i���d�F�D�L�RX�
�
�	
rEc�L�t||�|||����S)aJThis method works like the :attr:`module` attribute when called
        without arguments but it will evaluate the template on every call
        rather than caching it.  It's also possible to provide
        a dict which is then used as context.  The arguments are the same
        as for the :meth:`new_context` method.
        )�TemplateModuler-r�s    r@�make_modulezTemplate.make_module|s&���d�D�$4�$4�T�6�6�$J�$J�K�K�KrEc� �td���)z�As template module creation can invoke template code for
        asynchronous executions this method must be used instead of the
        normal :meth:`make_module` one.  Likewise the module attribute
        becomes unavailable in async mode.
        rurvr�s    r@�make_module_asynczTemplate.make_module_async�s��"�F�
�
�	
rEc�X�|j�|jS|���x|_}|Sr�)rnr�)r�r�s  r@�_get_default_modulezTemplate._get_default_module�s/���<�#��<�� �,�,�.�.�.���r��	rEc�*�|���S)a�The template as module.  This is used for imports in the
        template runtime but is also useful if one wants to access
        exported template variables from the Python layer:

        >>> t = Template('{% macro foo() %}42{% endmacro %}23')
        >>> str(t.module)
        '23'
        >>> t.module.foo() == u'42'
        True

        This attribute is not available if async mode is enabled.
        )r�r�s r@�modulezTemplate.module�s���'�'�)�)�)rEc�N�t|j��D]\}}||kr|cS�dS)zrReturn the source line number of a line number in the
        generated bytecode as they are not in sync.
        r)�reversedrk)r�r��
template_line�	code_lines    r@�get_corresponding_linenoz!Template.get_corresponding_lineno�sC��)1���(A�(A�	%�	%�$�M�9��F�"�"�$�$�$�$�#��qrEc�<�|j�dS|���S)z?If this variable is `False` there is a newer version available.NT)rbr�s r@r@zTemplate.is_up_to_date�s!���>�!��4��~�~���rEc�\�|jr$d�|j�d��D��SgS)zThe debug info mapping.c
�x�g|]7}ttt|�d��������8S)�=)�tuple�map�int�split)r4r�s  r@r5z'Template.debug_info.<locals>.<listcomp>�s4��W�W�W�a�E�#�c�1�7�7�3�<�<�0�0�1�1�W�W�WrE�&)ror�r�s r@rkzTemplate.debug_info�s;����	X�W�W�4�;K�;Q�;Q�RU�;V�;V�W�W�W�W��	rEc��|j�dt|��z}nt|j��}d|jj�d|�d�S�Nz	memory:%x�<� �>)rX�id�reprr�rR�r�rXs  r@�__repr__zTemplate.__repr__�sD���9����D���)�D�D���	�?�?�D�� �N�3�3�3�T�T�T�:�:rEr�)NFN)(rRrSrTrUrgr\rrr"r!rrrrr rrrr.r��classmethodrOrgrarsryr�rrr-r�r�r3r�rYr�r�r@rkr�rhrEr@r�r��s���������>$��
.�)�3�/�1�-�3�/��#�)�3�������)/;�/;�/;�/;�b�����[���F�F��[�F�����[��,0�0�0� 
�
�
�>�>�>�
6�
6�
6�
�
�
�

�

�

�

�L�L�L�L�	
�	
�	
�	
�����\���
*�
*��X�
*����� � ��X� �����X��;�;�;�;�;rEr�c�,�eZdZdZdd�Zd�Zd�Zd�ZdS)r�z�Represents an imported template.  All the exported names of the
    template are available as attributes on this object.  Additionally
    converting it into an unicode- or bytestrings renders the contents.
    Nc��|�=|jjrtd���t|�|����}||_|j�|�����|j	|_
dS)NzuAsync mode requires a body stream to be passed to a template module.  Use the async methods of the API you are using.)rOr�RuntimeErrorr�rm�_body_streamr�r��get_exportedrXrR)r�r�r��body_streams    r@r�zTemplateModule.__init__�s������"�+�
�"������x�8�8��A�A�B�B�K�'����
���W�1�1�3�3�4�4�4� �
��
�
�
rEc�D�tt|j����Sr�)rr/r�r�s r@�__html__zTemplateModule.__html__�s���f�T�.�/�/�0�0�0rEc�*�t|j��Sr�)r/r�r�s r@�__str__zTemplateModule.__str__�s���d�'�(�(�(rEc��|j�dt|��z}nt|j��}d|jj�d|�d�Sr�)rRr�r�r�r�s  r@r�zTemplateModule.__repr__�sF���=� ���D���)�D�D���
�&�&�D�� �N�3�3�3�T�T�T�:�:rEr�)rRrSrTrUr�r�r�r�rhrEr@r�r��s_��������
&�&�&�&�1�1�1�)�)�)�;�;�;�;�;rEr�c��eZdZdZd�Zd�ZdS)r�z�The :meth:`jinja2.Environment.compile_expression` method returns an
    instance of this object.  It encapsulates the expression-like access
    to the template with an expression it wraps.
    c�"�||_||_dSr�)�	_template�_undefined_to_none)r�r�r�s   r@r�zTemplateExpression.__init__�s��!���"3����rEc���|j�t|i|����}t|j�|����|jd}|jrt|t��rd}|S)NrQ)	r�r-rHr0rmrrr�rMr.)r�r=r�r�r�s     r@�__call__zTemplateExpression.__call__�st���.�,�,�T�4�-B�6�-B�-B�C�C�����/�/��8�8�9�9�9�
�\�(�
#���"�	�z�"�i�'@�'@�	��B��	rEN)rRrSrTrUr�r�rhrEr@r�r��s<��������
4�4�4�����rEr�c�@�eZdZdZd�Zdd�Zd�Zd�Zd
d	�Zd
�Z	d�Z
dS)r{aA template stream works pretty much like an ordinary python generator
    but it can buffer multiple items to reduce the number of total iterations.
    Per default the output is unbuffered which means that for every unbuffered
    instruction in the template one unicode string is yielded.

    If buffering is enabled with a buffer size of 5, five items are combined
    into a new unicode string.  This is mainly useful if you are streaming
    big templates to a client via WSGI which flushes after each iteration.
    c�<�||_|���dSr�)�_gen�disable_buffering)r��gens  r@r�zTemplateStream.__init__s!����	���� � � � � rEN�strictc�v���d}t|t��r��d�t|d��}d}	����fd�|D��}n|}t|d��r|�|��n|D]}|�|���|r|���dSdS#|r|���wwxYw)a!Dump the complete stream into a file or file-like object.
        Per default unicode strings are written, if you want to encode
        before writing specify an `encoding`.

        Example usage::

            Template('Hello {{ name }}!').stream(name='foo').dump('hello.html')
        FNzutf-8rTc3�D�K�|]}|�����V��dSr�)r)r4r��encoding�errorss  ��r@�	<genexpr>z&TemplateStream.dump.<locals>.<genexpr>s1�����E�E�1�A�H�H�X�v�6�6�E�E�E�E�E�ErE�
writelines)rMrrr�r�r	r')r��fpr�r�r'�iterable�items  ``   r@�dumpzTemplateStream.dumps��������b�,�'�'�	���"���b�$���B��E�	��#�E�E�E�E�E��E�E�E������r�<�(�(�
#��
�
�h�'�'�'�'�$�#�#�D��H�H�T�N�N�N�N��
����
�
�
�
�
�
�
��u�
����
�
�
�
�
���s�AB�B8c�R�tt|j��|_d|_dS)zDisable the output buffering.FN)r�nextr��_next�bufferedr�s r@r�z TemplateStream.disable_buffering)s ���T�4�9�-�-��
���
�
�
rEc#��K�g}d}|j}		||kr,t|j��}||��|r|dz
}||k�,n#t$r|sYdSYnwxYwt	|��V�|dd�=d}�b)Nrr)�appendr�r��
StopIterationr/)r�rC�buf�c_size�pushrs      r@�_buffered_generatorz"TemplateStream._buffered_generator.s����������z��	�
��t�m�m��T�Y���A��D��G�G�G��$��!���	�t�m�m���
!�
�
�
����F�F���
������+�+�����A�A�A���F�	s�2A�A�A�c��|dkrtd���d|_tt|�|����|_dS)z<Enable buffering.  Buffer `size` items before yielding them.rzbuffer size too smallTN)�
ValueErrorr�rr�r�r�)r�rCs  r@�enable_bufferingzTemplateStream.enable_bufferingAsD���1�9�9��4�5�5�5���
��T�4�#;�#;�D�#A�#A�B�B��
�
�
rEc��|Sr�rhr�s r@�__iter__zTemplateStream.__iter__Is���rEc�*�|���Sr�)r�r�s r@�__next__zTemplateStream.__next__Ls���z�z�|�|�rE)Nr�)r�)rRrSrTrUr�r�r�r�r�r�r�rhrEr@r{r{�s���������!�!�!�����:���
���&C�C�C�C��������rEr{)OrUrr�r>�	functoolsrr�
markupsaferr�r�_compatrr	r
rrr
rrr�compilerrr�defaultsrrrrrrrrrrrrrr r!r"�
exceptionsr#r$r%r&r'r�r(r)r*r�r+�runtimer,r-r.�utilsr/r0r1r2r3r5r6r9rArDrKrSr[rer�rgr�r�r�r{rNrhrEr@�<module>r�s2����
�	�	�	�
�
�
�
�����������������������������$�$�$�$�$�$�(�(�(�(�(�(�)�)�)�)�)�)�������������������������!�!�!�!�!�!�������#�#�#�#�#�#�������&�&�&�&�&�&�(�(�(�(�(�(�(�(�(�(�(�(�*�*�*�*�*�*�%�%�%�%�%�%�'�'�'�'�'�'�&�&�&�&�&�&�#�#�#�#�#�#�+�+�+�+�+�+�)�)�)�)�)�)�+�+�+�+�+�+�#�#�#�#�#�#�&�&�&�&�&�&�!�!�!�!�!�!�)�)�)�)�)�)�+�+�+�+�+�+�(�(�(�(�(�(�,�,�,�,�,�,�)�)�)�)�)�)�+�+�+�+�+�+�&�&�&�&�&�&������������������������������� � � � � � �������������������!�!�!�!�!�!� � � � � � �������������������%�H�R�L�L�����$���$�$�$�	�	�	�$�$�$����$f'�f'�f'�f'�f'�&�f'�f'�f'�RM;�M;�M;�M;�M;�v�M;�M;�M;�`�;�;�;�;�;�V�;�;���;�D���������&�P�P�P�P�P�V�P�P���P�j&����rE