Your IP : 3.149.238.67


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.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.)�bound)�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!rrrr r"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)r1rrr r.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)r2�buf�iterator�argrrr r,Ls



cCsttt|��S)z3Simple args to string conversion and concatenation.)rr5r()r2rrr r-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-)r2r>rrr �unicode_join\srAFr�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)rH)�dict�itemsrZ
context_class)
rCrDrErFrGrHrI�parent�key�valuerrr �new_contexths
rOc@s@eZdZdZddd�dd�Zeejd�dd	�Zed
�dd�Z	dS)
r*zThe `self` in templates.rBN)�contextrcCs
||_dS)N)�_TemplateReference__context)rrPrrr �__init__�szTemplateReference.__init__)�namercCs|jj|}t||j|d�S)Nr)rQrE�BlockReference)rrSrErrr �__getitem__�szTemplateReference.__getitem__)rcCsdt|�j�d|jj�d�S)N�<� �>)�typer"rQrS)rrrr �__repr__�szTemplateReference.__repr__)
r"r#r$�__doc__rRr(r%�AnyrUrZrrrr r*�s)�dict_methodrcs,t���dtjd��fdd��}t�t|�S)NrB)rrcs�|���S)N)�get_all)r)r]rr �f_all�sz_dict_method_all.<locals>.f_all)�	functools�wrapsr%r\�castr)r]r_r)r]r �_dict_method_all�srcc
@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)-rBa�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__rdr>r?r@)�clsr>rrr �__init_subclass__�s
zContext.__init_subclass__r)rCrLrSrErHcCs^||_i|_||_t|j|�|_t�|_||_|dkr<t�nt|�|_dd�|�	�D�|_
dS)NcSsi|]\}}|g|�qSrr)�.0�k�vrrr �
<dictcomp>�sz$Context.__init__.<locals>.<dictcomp>)rLrFrCr
�eval_ctx�set�
exported_varsrSZglobals_keysrKrE)rrCrLrSrErHrrr rR�szContext.__init__)rTr/)rS�currentrcCs\y$|j|}|�|�d}||Wn(tk
rL|jjd|�d�dd�SXt||||�S)zRender a parent block.rz there is no parent block called �.�super)rS)rE�index�LookupErrorrC�	undefinedrT)rrSrqrErtrrr rs�s
z
Context.super)rM�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)rrMrwrrr �get�szContext.getr/)rMrcCs`|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.
        )rS)rdrFrLrCrvrer)rrM�rvrrr rf�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.
        )rdrf�
isinstancer/rrFrL)rrMrzrrr res






zContext.resolve_or_missingcs�fdd��jD�S)z+Get a new dict with the exported variables.csi|]}�j||�qSr)rF)rjrk)rrr rm*sz(Context.get_exported.<locals>.<dictcomp>)rp)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.
        )rFrLrJ)rrrr r^,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)
r7rZfrom_objr!rPry�derivedZeval_contextrnrC�pop�
StopIterationrv)Z_Context__selfr}r~rZ__traceback_hide__Zpass_argrrr �call7s,








zContext.call)rIrcCsDt|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)rjrkrlrrr �	<genexpr>msz"Context.derived.<locals>.<genexpr>)rOrCrSr^rnrE�updaterK)rrIrPrrr r�ds
zContext.derived)rSrcCs||jkp||jkS)N)rFrL)rrSrrr �__contains__tszContext.__contains__cCs|�|�}|tkrt|��|S)zpLook up a variable by name with ``[]`` syntax, or raise a
        ``KeyError`` if the key is not found.
        )rerrx)rrM�itemrrr rUws
zContext.__getitem__cCs$dt|�j�d|���d|j�d�S)NrVrWz of rX)rYr"r^rS)rrrr rZ�szContext.__repr__)N)N)N)$r"r#r$r[rdr%�ClassVar�bool�__annotations__ri�Dictr(r\�Optional�Callable�Iterator�MutableMappingrR�Unionrsryrfrer|r^rr�r�rcrJ�keys�valuesrKr�rUrZrrrr rB�s*
X*$


c@szeZdZdZedejejdgejefe	dd�dd�Z
eejdd�d	d
��Z
eed�dd��Zeed�d
d��ZdS)rTz"One block on a template reference.rBN)rSrP�stackrrcCs||_||_||_||_dS)N)rS�_context�_stack�_depth)rrSrPr�rrrr rR�szBlockReference.__init__)rTr/)rcCsJ|jdt|j�kr0|jjjd|j�d�dd�St|j|j|j|jd�S)zSuper the block.rz there is no parent block called rrrs)rS)r��lenr�r�rCrvrSrT)rrrr rs�szBlockReference.superc�s<tdd�|j|j|j�2�IdH�}|jjjr8t|�S|S)Nc
�s.g|y3dH}Wn
tk
s"X|�qYS)N)�StopAsyncIteration)rjr1rrr �
<listcomp>�sz.BlockReference._async_call.<locals>.<listcomp>)rr�r�r�rn�
autoescaper)rrzrrr �_async_call�s
$
zBlockReference._async_callcCs>|jjjr|��St|j|j|j��}|jjjr:t	|�S|S)N)
r�rC�is_asyncr�rr�r�rnr�r)rrzrrr r!�s

zBlockReference.__call__)r"r#r$r[r(r%�Listr�r�r'rR�propertyr�rsrr�r!rrrr rT�s
rTc@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)�iterablerv�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�rvr�r�rrr rR�s
zLoopContext.__init__)r�rcCst|�S)N)�iter)r�rrr r��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�rtr�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�)rrrr r�szLoopContext.depthcCs
|jdS)z-Current iteration of the loop, starting at 1.r)�index0)rrrr rt�szLoopContext.indexcCs|j|jS)zrNumber of iterations from the end of the loop, ending at 0.

        Requires calculating :attr:`length`.
        )r�rt)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�)rrzrrr �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)rNrcGs|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�)rrNrrr �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�)rrzrrr �__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�rrr r!is
zLoopContext.__call__cCs"dt|�j�d|j�d|j�d�S)NrVrW�/rX)rYr"rtr�)rrrr rZwszLoopContext.__repr__)Nr).r"r#r$r[r�r�r%r�r'r�rr�r\r�r�r�r&r�TyperR�staticmethodr�r�r�r�r�rrtr�r�r�r�r�r�r�r�r�r�r�r��Tupler�rr(r!rZrrrr r)�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)r0r�)r�rcCst|�S)N)r)r�rrr r�~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�)rjr1rrr r��sz+AsyncLoopContext.length.<locals>.<listcomp>)	r�r�r�r�r�r�rtr�r)rr�rrr r��s
 zAsyncLoopContext.lengthc�s|jIdH|jS)N)r�rt)rrrr r��szAsyncLoopContext.revindex0c�s|jIdH|jS)N)r�r�)rrrr r��szAsyncLoopContext.revindexc�sH|jtk	r|jSy|j��IdH|_Wntk
r@t|_YnX|jS)N)r�rr��	__anext__r�)rrrr r��s
zAsyncLoopContext._peek_nextc�s|��IdHtkS)N)r�r)rrrr r��szAsyncLoopContext.lastr/c�s$|��IdH}|tkr |�d�S|S)Nzthere is no next item)r�rr�)rrzrrr r��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�)rrzrrr r��s
zAsyncLoopContext.__anext__N)r"r#r$r%�
AsyncIteratorr\r�r�r�r&r�
AsyncIterabler�r�r'r�r�r�r�r�r�r�r�r�r�rrrr r0{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.)rC�funcrS�	arguments�catch_kwargs�
catch_varargs�caller�default_autoescapec		Csl||_||_t|�|_||_||_||_||_||_d|k|_	|dkrbt
|j�r\|�d�}n|j}||_dS)Nr�)
�_environment�_funcr��_argument_countrSr�r�r�r��explicit_caller�callabler��_default_autoescape)	rrCr�rSr�r�r�r�r�rrr rR�s


zMacro.__init__)r~rrc
	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)rSzmacro 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))r{r
r�r�r�r�r�r�r�rxrr6r�r�r�rvr�r�rSr�r�r��_invoke)
rr~rr�r��offZfound_callerrSrNr�rrr r!�sH





zMacro.__call__)r�r�rc�s |j|�IdH}|rt|�S|S)N)r�r)rr�r�rzrrr �
_async_invoke0szMacro._async_invokecCs.|jjr|�||�S|j|�}|r*t|�}|S)N)r�r�r�r�r)rr�r�rzrrr r�8s
z
Macro._invoke)rcCs0|jdkrdnt|j�}dt|�j�d|�d�S)NZ	anonymousrVrWrX)rS�reprrYr")rrSrrr rZCszMacro.__repr__)N)r"r#r$r[r%r�r(r�r�r�rRrrr\r!r�r�rZrrrr r+�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�objrS�excrcCs||_||_||_||_dS)N)r�r�r�r�)rr�r�rSr�rrr rR^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�r{r(r)rrrr �_undefined_messagejs
zUndefined._undefined_messagezte.NoReturn)r~rrcOs|�|j��dS)zeRaise an :exc:`UndefinedError` when operations are performed
        on the undefined value.
        N)r�r�)rr~rrrr �_fail_with_undefined_error�sz$Undefined._fail_with_undefined_error)rSrcCs |dd�dkrt|��|��S)Nr<�__)�AttributeErrorr�)rrSrrr �__getattr__�szUndefined.__getattr__)�otherrcCst|�t|�kS)N)rY)rr�rrr �__eq__�szUndefined.__eq__cCs|�|�S)N)r�)rr�rrr �__ne__�szUndefined.__ne__cCstt|��S)N)�idrY)rrrr �__hash__�szUndefined.__hash__cCsdS)Nr4r)rrrr �__str__�szUndefined.__str__cCsdS)Nrr)rrrr r��szUndefined.__len__ccsdEdHdS)Nrr)rrrr r��szUndefined.__iter__cCsxdD]
}dVqWdS)Nrr)r�_rrr r��s
zUndefined.__aiter__cCsdS)NFr)rrrr �__bool__�szUndefined.__bool__cCsdS)Nr/r)rrrr rZ�szUndefined.__repr__);r"r#r$r[�	__slots__rrr%r�r(r\r�rrRr�r�rr�r��__add__�__radd__�__sub__�__rsub__�__mul__�__rmul__Z__div__Z__rdiv__�__truediv__�__rtruediv__�__floordiv__�
__rfloordiv__�__mod__�__rmod__�__pos__�__neg__r!rU�__lt__�__le__�__gt__�__ge__�__int__�	__float__�__complex__�__pow__�__rpow__r�r�r�r'r�r�r�r�r�r�r�r�rZrrrr r/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)�warningr�)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~rrc
sLyt�j||�Wn4|jk
rF}z��d|�|�Wdd}~XYnXdS)NzTemplate variable error: %s)rsr�r��error)rr~r�e)�	__class__rrr r��s
zKmake_logging_undefined.<locals>.LoggingUndefined._fail_with_undefined_error)rcs�|�t���S)N)rsr�)r)r
rrr r��sz8make_logging_undefined.<locals>.LoggingUndefined.__str__cs�|�t���S)N)rsr�)r)r
rrr r��sz9make_logging_undefined.<locals>.LoggingUndefined.__iter__cs�|�t���S)N)rsr�)r)r
rrr r��sz9make_logging_undefined.<locals>.LoggingUndefined.__bool__)r"r#r$r�r%r\r�r(r�r�r�r�r��
__classcell__r)rr)r
r �LoggingUndefined�sr)�logging�	getLoggerr"�
addHandler�
StreamHandler�sys�stderrr/)rrr
rr)rrr �make_logging_undefined�s
rc@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()rrrr r3szChainableUndefined.__html__)r�rcCs|S)Nr)rr�rrr r�	szChainableUndefined.__getattr__N)	r"r#r$r[r�r(r3r�rUrrrr r�s
rc@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�messagerrr r�s
zDebugUndefined.__str__N)r"r#r$r[r�r(r�rrrr rs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$r[r�r/r�r�r�r�r�r�r�r�r�rrrr r/s
r)NFNN)Ir[r`r�typingr%�collectionsr�	itertoolsrZ
markupsaferrrZasync_utilsrr	�
exceptionsr
rrZnodesr
�utilsrrrrrrr�TypeVarrr�r\r�
TYPE_CHECKINGr
Ztyping_extensions�terCrZProtocolrZexportedZasync_exportedr.r&r(r,r-rAr�r�r�r�r��MappingrOr*rc�registerrBrTr)r0r+r/r�rrrrr�rrrr �<module>s�
hl0FGq: 

?>