%PDF- %PDF-
Mini Shell

Mini Shell

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

B

��RfL�
@s�dZddlmZddlmZmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZmZddlmZmZmZmZmZmZmZmZddd	d
ddd
ddddddg
ZeZdd�Ze�Zdd�Z dd�Z!d+dd�Z"Gdd�de�Z#Gdd�de�Z$yddl%m&Z&e&�'e$�Wne(k
�rYnXGdd �d e�Z)Gd!d�de�Z*eGd"d#�d#e��Z+Gd$d	�d	e�Z,eGd%d&�d&e��Z-eGd'd(�d(e-��Z.eGd)d*�d*e-��Z/e-`0e.`0e/`0dS),z}
    jinja2.runtime
    ~~~~~~~~~~~~~~

    Runtime helpers.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD.
�)�chain)�EvalContext�_context_function_types)�Markup�soft_unicode�escape�missing�concat�internalcode�object_type_repr)�UndefinedError�TemplateRuntimeError�TemplateNotFound)�next�imap�	text_type�	iteritems�implements_iterator�implements_to_string�string_types�PY2�LoopContext�TemplateReference�Macrorr
rr	r�markup_join�unicode_join�	to_string�identityrcCs|S)N�)�xrr�?/opt/alt/python37/lib/python3.7/site-packages/jinja2/runtime.py�<lambda> �r!cCsLg}tt|�}x4|D],}|�|�t|d�rtd��t||��SqWt|�S)z@Concatenation that escapes if necessary and converts to unicode.Z__html__�)rr�append�hasattrr�joinrr	)�seqZbuf�iterator�argrrr r%s



cCsttt|��S)z4Simple args to unicode conversion and concatenation.)r	rr)r'rrr r0sNc
Cs�|dkri}|r|}nt|pdf|�}|rt|r6t|�}x<t|�D]0\}}	|dd�dkr@|	tk	r@|	||dd�<q@Wt||||�S)z(Internal helper to for context creation.Nr�Zl_)�dictrr�Context)
�environmentZ
template_name�blocks�varsZshared�globals�locals�parent�key�valuerrr �new_context5sr5c@s(eZdZdZdd�Zdd�Zdd�ZdS)	rzThe `self` in templates.cCs
||_dS)N)�_TemplateReference__context)�self�contextrrr �__init__LszTemplateReference.__init__cCs|jj|}t||j|d�S)Nr)r6r.�BlockReference)r7�namer.rrr �__getitem__OszTemplateReference.__getitem__cCsd|jj|jjfS)Nz<%s %r>)�	__class__�__name__r6r;)r7rrr �__repr__SszTemplateReference.__repr__N)r>�
__module__�__qualname__�__doc__r9r<r?rrrr rIsc@s�eZdZdZdZdd�Zdd�Zd"dd	�Zd
d�Zdd
�Z	dd�Z
edd��Zd#dd�Z
dd�Zed�Zed�Zed�Zer�ed�Zed�Zed�Z[dd�Zdd�Zd d!�ZdS)$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:`contextfunction`\s 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.
    )r2r/r-�eval_ctx�
exported_varsr;r.�__weakref__cCsJ||_i|_||_t|j|�|_t�|_||_tdd�t	|�D��|_
dS)Ncss|]\}}||gfVqdS)Nr)�.0�k�vrrr �	<genexpr>{sz#Context.__init__.<locals>.<genexpr>)r2r/r-rrC�setrDr;r+rr.)r7r-r2r;r.rrr r9pszContext.__init__cCsXy$|j|}|�|�d}||Wn$tk
rH|jjd|dd�SXt||||�S)zRender a parent block.�z#there is no parent block called %r.�super)r;)r.�index�LookupErrorr-�	undefinedr:)r7r;Zcurrentr.rMrrr rL}s

z
Context.superNcCs"y||Stk
r|SXdS)zfReturns an item from the template context, if it doesn't exist
        `default` is returned.
        N)�KeyError)r7r3�defaultrrr �get�szContext.getcCs6||jkr|j|S||jkr(|j|S|jj|d�S)z�Looks up a variable like `__getitem__` or `get` but returns an
        :class:`Undefined` object with the name of the name looked up.
        )r;)r/r2r-rO)r7r3rrr �resolve�s




zContext.resolvecst�fdd��jD��S)z+Get a new dict with the exported variables.c3s|]}|�j|fVqdS)N)r/)rFrG)r7rr rI�sz'Context.get_exported.<locals>.<genexpr>)r+rD)r7r)r7r �get_exported�szContext.get_exportedcCst|jf|j�S)z`Return a copy of the complete context as dict including the
        exported variables.
        )r+r2r/)r7rrr �get_all�szContext.get_allcOs�d}|j}xdD]}t||�r|}PqWt|t�r|t|dd�rJ|f|}n2t|dd�rd|jf|}nt|dd�r||jf|}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 is a :func:`contextfunction` or
        :func:`environmentfunction`.
        T)�contextfunction�evalcontextfunction�environmentfunctionrVrrWrXzGvalue was undefined because a callable raised a StopIteration exceptionN)	�__call__r%�
isinstancer�getattrrCr-�
StopIterationrO)Z_Context__selfZ
_Context__obj�args�kwargsZ__traceback_hide__�fnZfn_typerrr �call�s"



zContext.callcCsPt|j|ji|jdd|�}|j�|j�|j|_|j�dd�t|j�D��|S)z5Internal helper function to create a derived context.TNcss|]\}}|t|�fVqdS)N)�list)rFrGrHrrr rI�sz"Context.derived.<locals>.<genexpr>)	r5r-r;r2r/�updaterCr.r)r7r1r8rrr �derived�szContext.derivedcs$�fdd�}tt��j|_�|_|S)Ncst|�����S)N)r[rU)r7)�methrr r!�r"zContext._all.<locals>.<lambda>)r[r+rBr>)rd�proxyr)rdr �_all�szContext._all�keys�values�items�iterkeys�
itervaluesrcCs||jkp||jkS)N)r/r2)r7r;rrr �__contains__�szContext.__contains__cCs |�|�}t|t�rt|��|S)zTLookup a variable or raise `KeyError` if the variable is
        undefined.
        )rSrZ�	UndefinedrP)r7r3�itemrrr r<�s

zContext.__getitem__cCsd|jjt|���|jfS)Nz
<%s %s of %r>)r=r>�reprrUr;)r7rrr r?�s
zContext.__repr__)N)N)r>r@rArB�	__slots__r9rLrRrSrTrUr
r`rcrfrgrhrirrjrkrrlr<r?rrrr r,Zs,

	
!
		r,)�Mappingc@s0eZdZdZdd�Zedd��Zedd��ZdS)	r:z"One block on a template reference.cCs||_||_||_||_dS)N)r;�_context�_stack�_depth)r7r;r8�stack�depthrrr r9szBlockReference.__init__cCsF|jdt|j�kr,|jjjd|jdd�St|j|j|j|jd�S)zSuper the block.rKz#there is no parent block called %r.rL)r;)rt�lenrsrrr-rOr;r:)r7rrr rLszBlockReference.supercCs,t|j|j|j��}|jjjr(t|�}|S)N)r	rsrtrrrCZ
autoescaper)r7�rvrrr rYs
zBlockReference.__call__N)	r>r@rArBr9�propertyrLr
rYrrrr r:�s
r:c@s�eZdZdZddd�Zdd�Zedd	��Zed
d	��Zedd	��Z	edd	��Z
ed
d	��Zedd	��Zdd�Z
dd�Zdd�Zedd��ZeZ[edd��Zdd�ZdS)rz%A loop context for dynamic iteration.Nrc	CsXt|�|_||_|��|_d|_||_yt|�|_Wnt	t
fk
rRd|_YnXdS)N���)�iter�	_iterator�_recurse�
_safe_next�_after�index0�depth0rw�_length�	TypeError�AttributeError)r7�iterableZrecurser�rrr r9s

zLoopContext.__init__cGs|std��||jt|�S)z7Cycles among the arguments with the current loop index.zno items for cycling given)r�r�rw)r7r]rrr �cycle+szLoopContext.cyclecCs
|jdkS)Nr)r�)rrrr r!1r"zLoopContext.<lambda>cCs
|jtkS)N)r�_last_iteration)rrrr r!2r"cCs
|jdS)NrK)r�)rrrr r!3r"cCs|j|jS)N)�lengthr�)rrrr r!4r"cCs|j|jS)N)r�rM)rrrr r!5r"cCs
|jdS)NrK)r�)rrrr r!6r"cCs|jS)N)r�)r7rrr �__len__8szLoopContext.__len__cCst|�S)N)�LoopContextIterator)r7rrr �__iter__;szLoopContext.__iter__cCs$y
t|j�Stk
rtSXdS)N)rr|r\r�)r7rrr r~>s
zLoopContext._safe_nextcCs(|jdkrtd��|�||j|jd�S)NzMTried to call non recursive loop.  Maybe you forgot the 'recursive' modifier.rK)r}r�r�)r7r�rrr �loopDs
zLoopContext.loopcCs8|jdkr2t|j�}t|�|_t|�|jd|_|jS)NrK)r��tupler|r{rwr�)r7r�rrr r�Ps



zLoopContext.lengthcCsd|jj|j|jfS)Nz
<%s %r/%r>)r=r>rMr�)r7rrr r?\szLoopContext.__repr__)Nr)r>r@rArBr9r�ry�firstZlastrMZrevindexZ	revindex0rvr�r�r~r
r�rYr�r?rrrr rs"
	c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
r�z The iterator for a loop context.)r8cCs
||_dS)N)r8)r7r8rrr r9iszLoopContextIterator.__init__cCs|S)Nr)r7rrr r�lszLoopContextIterator.__iter__cCs<|j}|jd7_|jtkr$t��|j}|��|_||fS)NrK)r8r�rr�r\r~)r7ZctxZ	next_elemrrr �__next__os

zLoopContextIterator.__next__N)r>r@rArBrpr9r�r�rrrr r�ds
r�c@s,eZdZdZdd�Zedd��Zdd�ZdS)	rzWraps a macro function.c		Cs>||_||_t|�|_||_||_||_||_||_||_	dS)N)
�_environment�_funcrw�_argument_countr;�	arguments�defaults�catch_kwargs�
catch_varargs�caller)	r7r-�funcr;r�r�r�r�r�rrr r9|s
zMacro.__init__c	Osnt|d|j��}t|�}||jkr�x�t|jt|�d��D]x\}}y|�|�}WnVtk
r�y|j||j|}Wn(tk
r�|j	j
d||d�}YnXYnX|�|�q<W|jr�|�dd�}|dkr�|j	j
ddd�}|�|�|j
r�|�|�n |�rtd|jtt|��f��|j�r<|�||jd��n(t|�|jk�rdtd|jt|j�f��|j|�S)Nzparameter %r was not provided)r;r�zNo caller definedz%macro %r takes no keyword argument %rz+macro %r takes not more than %d argument(s))rar�rw�	enumerater��poprPr��
IndexErrorr�rOr$r�r�r�r;rr{r�r�)	r7r]r^r�Zoff�idxr;r4r�rrr rY�s<
 
zMacro.__call__cCs$d|jj|jdkrdpt|j�fS)Nz<%s %s>Z	anonymous)r=r>r;ro)r7rrr r?�szMacro.__repr__N)r>r@rArBr9r
rYr?rrrr rys*c@s�eZdZdZdZdedefdd�Zedd��Z	edd	��Z
e	ZZZ
ZZZZZZZZZZZZZZZZZZZ Z!Z"Z#d
d�Z$dd
�Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*dd�Z+dS)rmaVThe 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):
      ...
    UndefinedError: 'foo' is undefined
    )�_undefined_hint�_undefined_obj�_undefined_name�_undefined_exceptionNcCs||_||_||_||_dS)N)r�r�r�r�)r7�hint�objr;�excrrr r9�szUndefined.__init__cOsl|jdkrX|jtkr d|j}q^t|jt�sBdt|j�|jf}q^dt|j�|jf}n|j}|�|��dS)ziRegular callback function for undefined objects that raises an
        `UndefinedError` on call.
        Nz%r is undefinedz%s has no element %rz%r has no attribute %r)r�r�rr�rZrrr�)r7r]r^r�rrr �_fail_with_undefined_error�s

z$Undefined._fail_with_undefined_errorcCs |dd�dkrt|��|��S)Nr*�__)r�r�)r7r;rrr �__getattr__�szUndefined.__getattr__cCst|�t|�kS)N)�type)r7�otherrrr �__eq__�szUndefined.__eq__cCs|�|�S)N)r�)r7r�rrr �__ne__�szUndefined.__ne__cCstt|��S)N)�idr�)r7rrr �__hash__�szUndefined.__hash__cCsdS)Nr#r)r7rrr �__str__�szUndefined.__str__cCsdS)Nrr)r7rrr r�szUndefined.__len__ccsdS)Nr)r7rrr r�szUndefined.__iter__cCsdS)NFr)r7rrr �__nonzero__szUndefined.__nonzero__cCsdS)Nrmr)r7rrr r?
szUndefined.__repr__),r>r@rArBrprrr9r
r�r��__add__�__radd__�__mul__�__rmul__Z__div__Z__rdiv__�__truediv__�__rtruediv__�__floordiv__�
__rfloordiv__�__mod__�__rmod__�__pos__�__neg__rYr<�__lt__�__le__�__gt__�__ge__�__int__�	__float__�__complex__�__pow__�__rpow__r�r�r�r�r�r�r�r?rrrr rm�sdrmc@seZdZdZdZdd�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):
      ...
    UndefinedError: 'foo' is undefined
    rcCs<|jdkr2|jtkrd|jSdt|j�|jfSd|jS)Nz{{ %s }}z{{ no such element: %s[%r] }}z!{{ undefined value printed: %s }})r�r�rr�r)r7rrr r�s



zDebugUndefined.__str__N)r>r@rArBrpr�rrrr r�s
r�c@s6eZdZdZdZejZZZ	Z
ZZZ
ZdS)�StrictUndefineda=An 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):
      ...
    UndefinedError: 'foo' is undefined
    >>> not foo
    Traceback (most recent call last):
      ...
    UndefinedError: 'foo' is undefined
    >>> foo + 42
    Traceback (most recent call last):
      ...
    UndefinedError: 'foo' is undefined
    rN)r>r@rArBrprmr�r�r�r�r�r�r��__bool__r�rrrr r�)sr�)NNNN)1rB�	itertoolsrZjinja2.nodesrrZjinja2.utilsrrrrr	r
rZjinja2.exceptionsrr
rZjinja2._compatrrrrrrrr�__all__rr�objectr�rrr5rr,�collectionsrq�register�ImportErrorr:rr�rrmr�r�rprrrr �<module>
sH$(
L@T

Zerion Mini Shell 1.0