Your IP : 3.147.27.154


Current Path : /opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/runtime.cpython-37.opt-1.pyc

B

^�a��@s2dZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddl	mZdd	l
mZdd
l
mZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZe�d�Zejdej dej!fd�Z"ej#�rNddl$Z$ddl%Z&ddl'm(Z(Gdd�de&j)�Z*dddd d!d"d#d$d%d&d'd(d)d*d+gZ+d,d-d.gZ,eed/�d0d'�Z-ej.ej!e/d1�d2d%�Z0ej.ej!e/d1�d3d&�Z1ej.ej!e/d1�d4d5�Z2dQd7ej3e/ej4e/ej d8gej5e/ffej3ej4e/ej!fe6ej3ej7e/ej!fej3ej8e/ej!fd8d9�d:d;�Z9Gd<d�d�Z:e"e"d=�d>d?�Z;ej8j<Gd@d8�d8��Z=GdAdB�dB�Z>GdCd�d�Z?GdDd,�d,e?�Z@GdEd�d�ZAGdFd*�d*�ZBdeBfej3dGejCeBejCeBdH�dIdJ�ZDGdKdL�dLeB�ZEGdMdN�dNeB�ZFGdOdP�dPeB�ZGeB`HeE`HeF`HeG`HdS)Rz;The runtime functions and state used by compiled templates.�N)�abc)�chain)�escape)�Markup)�soft_str�)�
auto_aiter)�
auto_await)�TemplateNotFound)�TemplateRuntimeError)�UndefinedError)�EvalContext)�_PassArg)�concat)�internalcode)�missing)�	Namespace)�object_type_repr)�pass_eval_context�V�F.)Zbound)�Environmentc@s(eZdZdejedeed�dd�ZdS)�LoopRenderFuncr)�reciter�loop_render_func�depth�returncCsdS)N�)�selfrrrrr�?/opt/alt/python37/lib/python3.7/site-packages/jinja2/runtime.py�__call__#szLoopRenderFunc.__call__N)r)	�__name__�
__module__�__qualname__�t�Iterabler�int�strr rrrrr"sr�LoopContext�TemplateReference�Macrorrrrr�markup_join�str_join�identityr
r�	Undefinedr�AsyncLoopContextrr	)�xrcCs|S)zLReturns its argument. Useful for certain things in the
    environment.
    r)r0rrrr-Es)�seqrcCsLg}tt|�}x4|D],}|�|�t|d�rtd��t||��SqWt|�S)z?Concatenation that escapes if necessary and converts to string.�__html__�)�mapr�append�hasattrr�joinrr)r1Zbuf�iterator�argrrrr+Ls



cCsttt|��S)z3Simple args to string conversion and concatenation.)rr4r')r1rrrr,WscCs ddl}|jdtdd�t|�S)NrzWThis template must be recompiled with at least Jinja 3.0, or it will fail in Jinja 3.1.�)�
stacklevel)�warnings�warn�DeprecationWarningr,)r1r<rrr�unicode_join\sr?Fr�Context)�environment�
template_name�blocks�vars�shared�globals�localsrc
Csp|dkri}|r|}nt|pdf|�}|r\|r6t|�}x$|��D]\}}	|	tk	r@|	||<q@W|j|||||d�S)z%Internal helper for context creation.Nr)rF)�dict�itemsrZ
context_class)
rArBrCrDrErFrG�parent�key�valuerrr�new_contexths
rMc@s@eZdZdZddd�dd�Zeejd�dd	�Zed
�dd�Z	dS)
r)zThe `self` in templates.r@N)�contextrcCs
||_dS)N)�_TemplateReference__context)rrNrrr�__init__�szTemplateReference.__init__)�namercCs|jj|}t||j|d�S)Nr)rOrC�BlockReference)rrQrCrrr�__getitem__�szTemplateReference.__getitem__)rcCsdt|�j�d|jj�d�S)N�<� �>)�typer!rOrQ)rrrr�__repr__�szTemplateReference.__repr__)
r!r"r#�__doc__rPr'r$�AnyrSrXrrrrr)�s)�dict_methodrcs,t���dtjd��fdd��}t�t|�S)Nr@)rrcs�|���S)N)�get_all)r)r[rr�f_all�sz_dict_method_all.<locals>.f_all)�	functools�wrapsr$rZ�castr)r[r]r)r[r�_dict_method_all�srac
@s�eZdZUdZdZejeed<dd�dd�Z	d*dej
eejfej
eej
eejdgejeffej
ejeejfd	�d
d�Zeejdgejefejdd
�dd�Zd+eejejd�dd�Zeejejdfd�dd�Zeejd�dd�Zej
eejfd�dd�Zej
eejfd�dd�Zeejejejejejdfd�dd��Zd,ej
ej
eejfdd �d!d"�Zeej�Zeej�Zeej �Z eed#�d$d%�Z!eejd�d&d'�Z"ed�d(d)�Z#dS)-r@a�The template context holds the variables of a template.  It stores the
    values passed to the template and also the names the template exports.
    Creating instances is neither supported nor useful as it's created
    automatically at various stages of the template evaluation and should not
    be created by hand.

    The context is immutable.  Modifications on :attr:`parent` **must not**
    happen and modifications on :attr:`vars` are allowed from generated
    template code only.  Template filters and global functions marked as
    :func:`pass_context` get the active context passed as first argument
    and are allowed to access the context read-only.

    The template context supports read only dict operations (`get`,
    `keys`, `values`, `items`, `iterkeys`, `itervalues`, `iteritems`,
    `__getitem__`, `__contains__`).  Additionally there is a :meth:`resolve`
    method that doesn't fail with a `KeyError` but returns an
    :class:`Undefined` object for missing variables.
    F�_legacy_resolve_modeN)rcCsDd|jkrd|_n.d|jks"|jr@ddl}|jdtdd�d|_dS)	N�resolve_or_missingF�resolverzOverriding 'resolve' is deprecated and will not have the expected behavior in Jinja 3.1. Override 'resolve_or_missing' instead r:)r;T)�__dict__rbr<r=r>)�clsr<rrr�__init_subclass__�s
zContext.__init_subclass__r)rArJrQrCrFcCs^||_i|_||_t|j|�|_t�|_||_|dkr<t�nt|�|_dd�|�	�D�|_
dS)NcSsi|]\}}|g|�qSrr)�.0�k�vrrr�
<dictcomp>�sz$Context.__init__.<locals>.<dictcomp>)rJrDrAr
�eval_ctx�set�
exported_varsrQZglobals_keysrIrC)rrArJrQrCrFrrrrP�szContext.__init__)rRr.)rQ�currentrcCs\y$|j|}|�|�d}||Wn(tk
rL|jjd|�d�dd�SXt||||�S)zRender a parent block.rz there is no parent block called �.�super)rQ)rC�index�LookupErrorrA�	undefinedrR)rrQrorCrrrrrrq�s
z
Context.super)rK�defaultrcCs"y||Stk
r|SXdS)z�Look up a variable by name, or return a default if the key is
        not found.

        :param key: The variable name to look up.
        :param default: The value to return if the key is not found.
        N)�KeyError)rrKrurrr�get�szContext.getr.)rKrcCs`|jr<||jkr|j|S||jkr.|j|S|jj|d�S|�|�}|tkr\|jj|d�S|S)aNLook up a variable by name, or return an :class:`Undefined`
        object if the key is not found.

        If you need to add custom behavior, override
        :meth:`resolve_or_missing`, not this method. The various lookup
        functions use that method, not this one.

        :param key: The variable name to look up.
        )rQ)rbrDrJrArtrcr)rrK�rvrrrrd�s





zContext.resolvecCsN|jr"|�|�}t|t�rtS|S||jkr6|j|S||jkrJ|j|StS)aNLook up a variable by name, or return a ``missing`` sentinel
        if the key is not found.

        Override this method to add custom lookup behavior.
        :meth:`resolve`, :meth:`get`, and :meth:`__getitem__` use this
        method. Don't call this method directly.

        :param key: The variable name to look up.
        )rbrd�
isinstancer.rrDrJ)rrKrxrrrrcs






zContext.resolve_or_missingcs�fdd��jD�S)z+Get a new dict with the exported variables.csi|]}�j||�qSr)rD)rhri)rrrrk*sz(Context.get_exported.<locals>.<dictcomp>)rn)rr)rr�get_exported(szContext.get_exportedcCs(|js|jS|js|jSt|jf|j�S)z�Return the complete context as dict including the exported
        variables.  For optimizations reasons this might not return an
        actual copy so be careful with using it.
        )rDrJrH)rrrrr\,s
zContext.get_all)�
_Context__obj�args�kwargsrcOs�d}t|d�r$t�|j�dk	r$|j}t�|�}|tjkrt|�d�rP|�|d�}|�d�rh|�|d�}|f|}n.|tjkr�|jf|}n|tj	kr�|j	f|}|�
dd�|�
dd�y
|||�Stk
r�|j	�d�SXdS)z�Call the callable with the arguments and keyword arguments
        provided but inject the active context or environment as first
        argument if the callable has :func:`pass_context` or
        :func:`pass_environment`.
        Tr NZ
_loop_varsZ_block_varszGvalue was undefined because a callable raised a StopIteration exception)
r6rZfrom_objr rNrw�derivedZeval_contextrlrA�pop�
StopIterationrt)Z_Context__selfr{r|r}Z__traceback_hide__Zpass_argrrr�call7s,








zContext.call)rGrcCsDt|j|ji|��dd|�}|j|_|j�dd�|j��D��|S)z�Internal helper function to create a derived context.  This is
        used in situations where the system needs a new context in the same
        template that is independent.
        TNcss|]\}}|t|�fVqdS)N)�list)rhrirjrrr�	<genexpr>msz"Context.derived.<locals>.<genexpr>)rMrArQr\rlrC�updaterI)rrGrNrrrr~ds
zContext.derived)rQrcCs||jkp||jkS)N)rDrJ)rrQrrr�__contains__tszContext.__contains__cCs|�|�}|tkrt|��|S)zpLook up a variable by name with ``[]`` syntax, or raise a
        ``KeyError`` if the key is not found.
        )rcrrv)rrK�itemrrrrSws
zContext.__getitem__cCs$dt|�j�d|���d|j�d�S)NrTrUz of rV)rWr!r\rQ)rrrrrX�szContext.__repr__)N)N)N)$r!r"r#rYrbr$ZClassVar�bool�__annotations__rg�Dictr'rZ�Optional�Callable�Iterator�MutableMappingrP�Unionrqrwrdrcrzr\rr�r~rarH�keys�valuesrIr�rSrXrrrrr@�s*
X*$


c@szeZdZdZedejejdgejefe	dd�dd�Z
eejdd�d	d
��Z
eed�dd��Zeed�d
d��ZdS)rRz"One block on a template reference.r@N)rQrN�stackrrcCs||_||_||_||_dS)N)rQ�_context�_stack�_depth)rrQrNr�rrrrrP�szBlockReference.__init__)rRr.)rcCsJ|jdt|j�kr0|jjjd|j�d�dd�St|j|j|j|jd�S)zSuper the block.rz there is no parent block called rprq)rQ)r��lenr�r�rArtrQrR)rrrrrq�szBlockReference.superc�s<tdd�|j|j|j�2�IdH�}|jjjr8t|�S|S)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)�StopAsyncIteration)rhr0rrr�
<listcomp>�sz.BlockReference._async_call.<locals>.<listcomp>)rr�r�r�rl�
autoescaper)rrxrrr�_async_call�s
$
zBlockReference._async_callcCs>|jjjr|��St|j|j|j��}|jjjr:t	|�S|S)N)
r�rA�is_asyncr�rr�r�rlr�r)rrxrrrr �s

zBlockReference.__call__)r!r"r#rYr'r$�Listr�r�r&rP�propertyr�rqrr�r rrrrrR�s
rRc@s�eZdZUdZdZdZejee	d<e
Zeje	d<e
Z
eje	d<e
Zeje	d<e
Zeje	d<d7ejeejd
ejdedd�d
d�Zeejeejed�dd��Zeed�dd��Zed�dd�Zeed�dd��Zeed�dd��Zeed�dd��Zeed�dd��Zeed�dd ��Zejd�d!d"�Z eed�d#d$��Z!eej"ejd
fd�d%d&��Z#eej"ejd
fd�d'd(��Z$eed)�d*d+�Z%ejed,�d-d.�Z&dd�d/d0�Z'ej(ejdfd�d1d2�Z)e*ejee+d�d3d4��Z,e+d�d5d6�Z-dS)8r(zeA wrapper iterable for dynamic ``for`` loops, with information
    about the loop and iteration.
    ���N�_length�_after�_current�_before�_last_changed_valuerr.r)�iterablert�recurse�depth0rcCs(||_|�|�|_||_||_||_dS)a@
        :param iterable: Iterable to wrap.
        :param undefined: :class:`Undefined` class to use for next and
            previous items.
        :param recurse: The function to render the loop body when the
            loop is marked recursive.
        :param depth0: Incremented when looping recursively.
        N)�	_iterable�_to_iterator�	_iterator�
_undefined�_recurser�)rr�rtr�r�rrrrP�s
zLoopContext.__init__)r�rcCst|�S)N)�iter)r�rrrr��szLoopContext._to_iterator)rcCsl|jdk	r|jSyt|j�|_WnDtk
rdt|j�}|�|�|_t|�|j|jt	k	|_YnX|jS)z�Length of the iterable.

        If the iterable is a generator or otherwise does not have a
        size, it is eagerly evaluated to get a size.
        N)
r�r�r��	TypeErrorr�r�r�rrr�r)rr�rrr�length�s

 zLoopContext.lengthcCs|jS)N)r�)rrrr�__len__�szLoopContext.__len__cCs
|jdS)zBHow many levels deep a recursive loop currently is, starting at 1.r)r�)rrrrr�szLoopContext.depthcCs
|jdS)z-Current iteration of the loop, starting at 1.r)�index0)rrrrrr�szLoopContext.indexcCs|j|jS)zrNumber of iterations from the end of the loop, ending at 0.

        Requires calculating :attr:`length`.
        )r�rr)rrrr�	revindex0�szLoopContext.revindex0cCs|j|jS)zrNumber of iterations from the end of the loop, ending at 1.

        Requires calculating :attr:`length`.
        )r�r�)rrrr�revindexszLoopContext.revindexcCs
|jdkS)z0Whether this is the first iteration of the loop.r)r�)rrrr�firstszLoopContext.firstcCs$|jtk	r|jSt|jt�|_|jS)aReturn the next element in the iterable, or :data:`missing`
        if the iterable is exhausted. Only peeks one item ahead, caching
        the result in :attr:`_last` for use in subsequent checks. The
        cache is reset when :meth:`__next__` is called.
        )r�r�nextr�)rrrr�
_peek_nexts
zLoopContext._peek_nextcCs|��tkS)z�Whether this is the last iteration of the loop.

        Causes the iterable to advance early. See
        :func:`itertools.groupby` for issues this can cause.
        The :func:`groupby` filter avoids that issue.
        )r�r)rrrr�lastszLoopContext.lastcCs|jr|�d�S|jS)zZThe item in the previous iteration. Undefined during the
        first iteration.
        zthere is no previous item)r�r�r�)rrrr�previtem)s
zLoopContext.previtemcCs|��}|tkr|�d�S|S)a	The item in the next iteration. Undefined during the last
        iteration.

        Causes the iterable to advance early. See
        :func:`itertools.groupby` for issues this can cause.
        The :func:`jinja-filters.groupby` filter avoids that issue.
        zthere is no next item)r�rr�)rrxrrr�nextitem3s	
zLoopContext.nextitem)r|rcGs|std��||jt|�S)z�Return a value from the given args, cycling through based on
        the current :attr:`index0`.

        :param args: One or more values to cycle through.
        zno items for cycling given)r�r�r�)rr|rrr�cycleCszLoopContext.cycle)rLrcGs|j|kr||_dSdS)z�Return ``True`` if previously called with a different value
        (including when called for the first time).

        :param value: One or more values to compare to the last call.
        TF)r�)rrLrrr�changedNs
zLoopContext.changedcCs|S)Nr)rrrr�__iter__ZszLoopContext.__iter__cCsF|jtk	r|j}t|_n
t|j�}|jd7_|j|_||_||fS)Nr)r�rr�r�r�r�r�)rrxrrr�__next__]s

zLoopContext.__next__cCs&|jdkrtd��|j||j|jd�S)z�When iterating over nested data, render the body of the loop
        recursively with the given inner iterable data.

        The loop must have the ``recursive`` marker for this to work.
        NzCThe loop must have the 'recursive' marker to be called recursively.)r)r�r�r)rr�rrrr is
zLoopContext.__call__cCs"dt|�j�d|j�d|j�d�S)NrTrU�/rV)rWr!rrr�)rrrrrXwszLoopContext.__repr__)Nr).r!r"r#rYr�r�r$r�r&r�rr�rZr�r�r�r%r�TyperP�staticmethodr�r�r�r�r�rrrr�r�r�r�r�r�r�r�r�r�r�r��Tupler�rr'r rXrrrrr(�sN
		
c@s�eZdZUejejed<eejej	e
eje
feje
d�dd��Ze
ed�dd��Ze
ed�dd	��Ze
ed�d
d��Zejd�dd
�Ze
ed�dd��Ze
ejejdfd�dd��Zdd�dd�Zejejdfd�dd�ZdS)r/r�)r�rcCst|�S)N)r)r�rrrr�~szAsyncLoopContext._to_iterator)rc�sx|jdk	r|jSyt|j�|_WnPtk
rpdd�|j2�IdH}|�|�|_t|�|j|jtk	|_YnX|jS)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)r�)rhr0rrrr��sz+AsyncLoopContext.length.<locals>.<listcomp>)	r�r�r�r�r�r�rrr�r)rr�rrrr��s
 zAsyncLoopContext.lengthc�s|jIdH|jS)N)r�rr)rrrrr��szAsyncLoopContext.revindex0c�s|jIdH|jS)N)r�r�)rrrrr��szAsyncLoopContext.revindexc�sH|jtk	r|jSy|j��IdH|_Wntk
r@t|_YnX|jS)N)r�rr��	__anext__r�)rrrrr��s
zAsyncLoopContext._peek_nextc�s|��IdHtkS)N)r�r)rrrrr��szAsyncLoopContext.lastr.c�s$|��IdH}|tkr |�d�S|S)Nzthere is no next item)r�rr�)rrxrrrr��s
zAsyncLoopContext.nextitemcCs|S)Nr)rrrr�	__aiter__�szAsyncLoopContext.__aiter__c�sL|jtk	r|j}t|_n|j��IdH}|jd7_|j|_||_||fS)Nr)r�rr�r�r�r�r�)rrxrrrr��s
zAsyncLoopContext.__anext__N)r!r"r#r$�
AsyncIteratorrZr�r�r�r%r�
AsyncIterabler�r�r&r�r�r�r�r�r�r�r�r�r�rrrrr/{s"

c
@s�eZdZdZddejdefeejeeeeej	ed�dd�Z
eeej
ej
ed�d	d
���Zejej
eed�dd
�Zejej
eed�dd�Zed�dd�ZdS)r*zWraps a macro function.Nr.)rA�funcrQ�	arguments�catch_kwargs�
catch_varargs�caller�default_autoescapec		Csl||_||_t|�|_||_||_||_||_||_d|k|_	|dkrbt
|j�r\|�d�}n|j}||_dS)Nr�)
�_environment�_funcr��_argument_countrQr�r�r�r��explicit_caller�callabler��_default_autoescape)	rrAr�rQr�r�r�r�r�rrrrP�s


zMacro.__init__)r|r}rc
	Os�|r*t|dt�r*|dj}|dd�}n|j}t|d|j��}t|�}d}||jkr�x`|jt|�d�D]B}y|�|�}Wnt	k
r�t
}YnX|dkr�d}|�|�qlWn|j}|j
r�|s�|�dd�}	|	dkr�|jjddd�}	|�|	�|j�r|�|�n@|�rFd|k�r(td|j�d	���td|j�d
tt|������|j�rd|�||jd��n.t|�|jk�r�td|j�dt|j��d���|�||�S)
NrrFr�TzNo caller defined)rQzmacro zX was invoked with two values for the special caller argument. This is most likely a bug.z takes no keyword argument z takes not more than z argument(s))ryr
r�r�r�r�r�r�rrvrr5r�r�r�rtr�r�rQr�r�r��_invoke)
rr|r}r�r��offZfound_callerrQrLr�rrrr �sH





zMacro.__call__)r�r�rc�s |j|�IdH}|rt|�S|S)N)r�r)rr�r�rxrrr�
_async_invoke0szMacro._async_invokecCs.|jjr|�||�S|j|�}|r*t|�}|S)N)r�r�r�r�r)rr�r�rxrrrr�8s
z
Macro._invoke)rcCs0|jdkrdnt|j�}dt|�j�d|�d�S)NZ	anonymousrTrUrV)rQ�reprrWr!)rrQrrrrXCszMacro.__repr__)N)r!r"r#rYr$r�r'r�r�r�rPrrrZr r�r�rXrrrrr*�s4Lc@s�eZdZdZdZdedefeje	ej
eje	ejedd�dd�Z
ee	d�dd	��Zeej
ej
d
d�dd
��Zee	ej
d�dd��ZeZZZZeZZZZeZZeZZeZZ eZ!Z"eZ#Z$eZ%Z&Z'Z(eZ)Z*Z+eZ,Z-ej
e.d�dd�Z/ej
e.d�dd�Z0e1d�dd�Z2e	d�dd�Z3e1d�dd�Z4ej5ej
d�dd�Z6ej7ej
d�dd�Z8e.d�d d!�Z9e	d�d"d#�Z:dS)$r.ahThe default undefined type.  This undefined type can be printed and
    iterated over, but every other access will raise an :exc:`UndefinedError`:

    >>> foo = Undefined(name='foo')
    >>> str(foo)
    ''
    >>> not foo
    True
    >>> foo + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    )�_undefined_hint�_undefined_obj�_undefined_name�_undefined_exceptionN)�hint�objrQ�excrcCs||_||_||_||_dS)N)r�r�r�r�)rr�r�rQr�rrrrP^szUndefined.__init__)rcCsZ|jr|jS|jtkr"|j�d�St|jt�sDt|j��d|j��St|j��d|j��S)zXBuild a message about the undefined value based on how it was
        accessed.
        z
 is undefinedz has no element z has no attribute )r�r�rr�ryr'r)rrrr�_undefined_messagejs
zUndefined._undefined_messagezte.NoReturn)r|r}rcOs|�|j��dS)zeRaise an :exc:`UndefinedError` when operations are performed
        on the undefined value.
        N)r�r�)rr|r}rrr�_fail_with_undefined_error�sz$Undefined._fail_with_undefined_error)rQrcCs |dd�dkrt|��|��S)Nr:�__)�AttributeErrorr�)rrQrrr�__getattr__�szUndefined.__getattr__)�otherrcCst|�t|�kS)N)rW)rr�rrr�__eq__�szUndefined.__eq__cCs|�|�S)N)r�)rr�rrr�__ne__�szUndefined.__ne__cCstt|��S)N)�idrW)rrrr�__hash__�szUndefined.__hash__cCsdS)Nr3r)rrrr�__str__�szUndefined.__str__cCsdS)Nrr)rrrrr��szUndefined.__len__ccsdEdHdS)Nrr)rrrrr��szUndefined.__iter__cCsxdD]
}dVqWdS)Nrr)r�_rrrr��s
zUndefined.__aiter__cCsdS)NFr)rrrr�__bool__�szUndefined.__bool__cCsdS)Nr.r)rrrrrX�szUndefined.__repr__);r!r"r#rY�	__slots__rrr$r�r'rZr�rrPr�r�rr�r��__add__�__radd__�__sub__�__rsub__�__mul__�__rmul__Z__div__Z__rdiv__�__truediv__�__rtruediv__�__floordiv__�
__rfloordiv__�__mod__�__rmod__�__pos__�__neg__r rS�__lt__�__le__�__gt__�__ge__�__int__�	__float__�__complex__�__pow__�__rpow__r�r�r�r&r�r�r�r�r�r�r�r�rXrrrrr.HsB
 zlogging.Logger)�logger�basercsZ�dkr,ddl}|�t����|�tj��tdd��fdd��G��fdd�d|�}|S)akGiven a logger object this returns a new undefined class that will
    log certain failures.  It will log iterations and printing.  If no
    logger is given a default logger is created.

    Example::

        logger = logging.getLogger(__name__)
        LoggingUndefined = make_logging_undefined(
            logger=logger,
            base=Undefined
        )

    .. versionadded:: 2.8

    :param logger: the logger to use.  If not provided, a default logger
                   is created.
    :param base: the base class to add logging functionality to.  This
                 defaults to :class:`Undefined`.
    Nr)�undefrcs��d|j�dS)NzTemplate variable warning: %s)Zwarningr�)r)rrr�_log_message�sz,make_logging_undefined.<locals>._log_messagecsteZdZdZejejdd���fdd�Zed���fdd�Zej	ejd���fd	d
�Z
ed���fdd�Z�Z
S)
z0make_logging_undefined.<locals>.LoggingUndefinedrzte.NoReturn)r|r}rc
sLyt�j||�Wn4|jk
rF}z��d|�|�Wdd}~XYnXdS)NzTemplate variable error: %s)rqr�r��error)rr|r}�e)�	__class__rrrr��s
zKmake_logging_undefined.<locals>.LoggingUndefined._fail_with_undefined_error)rcs�|�t���S)N)rqr�)r)rrrrr��sz8make_logging_undefined.<locals>.LoggingUndefined.__str__cs�|�t���S)N)rqr�)r)rrrrr��sz9make_logging_undefined.<locals>.LoggingUndefined.__iter__cs�|�t���S)N)rqr�)r)rrrrr��sz9make_logging_undefined.<locals>.LoggingUndefined.__bool__)r!r"r#r�r$rZr�r'r�r�r�r�r��
__classcell__r)rr)rr�LoggingUndefined�sr)�loggingZ	getLoggerr!Z
addHandlerZ
StreamHandler�sys�stderrr.)rrr	rr)rrr�make_logging_undefined�s
rc@s6eZdZdZdZed�dd�Zedd�dd�ZeZd	S)
�ChainableUndefineda�An undefined that is chainable, where both ``__getattr__`` and
    ``__getitem__`` return itself rather than raising an
    :exc:`UndefinedError`.

    >>> foo = ChainableUndefined(name='foo')
    >>> str(foo.bar['baz'])
    ''
    >>> foo.bar['baz'] + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined

    .. versionadded:: 2.11.0
    r)rcCst|�S)N)r')rrrrr2szChainableUndefined.__html__)r�rcCs|S)Nr)rr�rrrr�	szChainableUndefined.__getattr__N)	r!r"r#rYr�r'r2r�rSrrrrr
�s
r
c@s"eZdZdZdZed�dd�ZdS)�DebugUndefinedaAn undefined that returns the debug info when printed.

    >>> foo = DebugUndefined(name='foo')
    >>> str(foo)
    '{{ foo }}'
    >>> not foo
    True
    >>> foo + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    r)rcCsL|jrd|j��}n,|jtkr&|j}ndt|j��d|j�d�}d|�d�S)Nzundefined value printed: zno such element: �[�]z{{ z }})r�r�rr�r)r�messagerrrr�s
zDebugUndefined.__str__N)r!r"r#rYr�r'r�rrrrrsrc@s:eZdZdZdZejZZZ	ejZ
ZZZ
ejZdS)�StrictUndefinedasAn undefined that barks on print and iteration as well as boolean
    tests and all kinds of comparisons.  In other words: you can do nothing
    with it except checking if it's defined using the `defined` test.

    >>> foo = StrictUndefined(name='foo')
    >>> str(foo)
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    >>> not foo
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    >>> foo + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    rN)r!r"r#rYr�r.r�r�r�r�r�r�r�r�r�rrrrr/s
r)NFNN)IrYr^r
�typingr$�collectionsr�	itertoolsrZ
markupsaferrrZasync_utilsrr	�
exceptionsr
rrZnodesr
ZutilsrrrrrrrZTypeVarrr�rZrZ
TYPE_CHECKINGr	Ztyping_extensionsZterArZProtocolrZexportedZasync_exportedr-r%r'r+r,r?r�r�r�r�r��MappingrMr)ra�registerr@rRr(r/r*r.r�rr
rrr�rrrr�<module>s�
hl0FGq: 

?>