%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/jinja2/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/jinja2/__pycache__/runtime.cpython-35.pyc



�bUX�@ssdZddlZddlmZddlmZmZddlmZm	Z	m
Z
mZmZm
Z
mZddlmZmZmZddlmZmZmZmZmZmZmZdd	d
ddd
ddddddddgZeZdd�Ze�Zdd�Z dd�Z!dddddd�Z"Gdd	�d	e�Z#Gdd�de�Z$y!ddl%m&Z&e&j'e$�Wne(k
r�YnXGd d!�d!e�Z)Gd"d�de�Z*eGd#d$�d$e��Z+Gd%d
�d
e�Z,eGd&d'�d'e��Z-ddd(d�Z.eGd)d*�d*e-��Z/eGd+d,�d,e-��Z0e-`1e/`1e0`1dS)-z}
    jinja2.runtime
    ~~~~~~~~~~~~~~

    Runtime helpers.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD.
�N)�chain)�EvalContext�_context_function_types)�Markup�soft_unicode�escape�missing�concat�internalcode�object_type_repr)�UndefinedError�TemplateRuntimeError�TemplateNotFound)�imap�	text_type�	iteritems�implements_iterator�implements_to_string�string_types�PY2�LoopContext�TemplateReference�Macrorr
rr	r�markup_join�unicode_join�	to_string�identityr�make_logging_undefinedcCs|S)N�)�xrr�0/usr/lib/python3/dist-packages/jinja2/runtime.py�<lambda>"sr!cCshg}tt|�}xF|D]>}|j|�t|d�rtd�jt||��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 r2sc
Cs�|dkri}|r!|}nt|p-f|�}|r�|rNt|�}xPt|�D]B\}}	|dd�dkr[|	tk	r[|	||dd�<q[W|j||||�S)z(Internal helper to for context creation.N�Zl_)�dictrrZ
context_class)
�environmentZ
template_name�blocks�varsZshared�globals�locals�parent�key�valuerrr �new_context7s	"r3c@s:eZdZdZdd�Zdd�Zdd�ZdS)	rzThe `self` in templates.cCs
||_dS)N)�_TemplateReference__context)�self�contextrrr �__init__OszTemplateReference.__init__cCs&|jj|}t||j|d�S)Nr)r4r,�BlockReference)r5�namer,rrr �__getitem__RszTemplateReference.__getitem__cCsd|jj|jjfS)Nz<%s %r>)�	__class__�__name__r4r9)r5rrr �__repr__Vs	zTemplateReference.__repr__N)r<�
__module__�__qualname__�__doc__r7r:r=rrrr rLsc@s	eZdZdZd)Zd
d�Zdd
�Zddd�Zdd�Zdd�Z	dd�Z
edd��Zddd�Z
dd�Zed�Zed�Zed�Zer�ed �Zed!�Zed"�Z[d#d$�Zd%d&�Zd'd(�ZdS)*�Contexta�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.
    r0r-r+�eval_ctx�
exported_varsr9r,�__weakref__cCsk||_i|_||_t|j|�|_t�|_||_tdd�t	|�D��|_
dS)Ncss$|]\}}||gfVqdS)Nr)�.0�k�vrrr �	<genexpr>~sz#Context.__init__.<locals>.<genexpr>)r0r-r+rrB�setrCr9r*rr,)r5r+r0r9r,rrr r7ss				zContext.__init__c
Csny,|j|}|j|�d}||Wn,tk
rZ|jjd|dd�SYnXt||||�S)zRender a parent block.�z#there is no parent block called %r.r9�super)r,�index�LookupErrorr+�	undefinedr8)r5r9Zcurrentr,rLrrr rK�s

z
Context.superNcCs)y||SWntk
r$|SYnXdS)zfReturns an item from the template context, if it doesn't exist
        `default` is returned.
        N)�KeyError)r5r1�defaultrrr �get�s
zContext.getcCsG||jkr|j|S||jkr4|j|S|jjd|�S)z�Looks up a variable like `__getitem__` or `get` but returns an
        :class:`Undefined` object with the name of the name looked up.
        r9)r-r0r+rN)r5r1rrr �resolve�s
zContext.resolvecs t�fdd��jD��S)z+Get a new dict with the exported variables.c3s"|]}|�j|fVqdS)N)r-)rErF)r5rr rH�sz'Context.get_exported.<locals>.<genexpr>)r*rC)r5r)r5r �get_exported�szContext.get_exportedcCst|j|j�S)z`Return a copy of the complete context as dict including the
        exported variables.
        )r*r0r-)r5rrr �get_all�szContext.get_allcOs�d}|j}x$dD]}t||�r|}PqWt|t�r�t|dd�rg|f|}nGt|dd�r�|jf|}n"t|dd�r�|jf|}y|||�SWn"tk
r�|jjd�SYnXdS)	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�environmentfunctionrzGvalue was undefined because a callable raised a StopIteration exceptionN)rUrVrW)	�__call__r$�
isinstancer�getattrrBr+�
StopIterationrN)Z_Context__selfZ
_Context__obj�args�kwargsZ__traceback_hide__�fnZfn_typerrr �call�s&	

zContext.callcCspt|j|ji|jdd|�}|jj|j�|j|_|jjdd�t|j�D��|S)z5Internal helper function to create a derived context.TNcss'|]\}}|t|�fVqdS)N)�list)rErFrGrrr rH�sz"Context.derived.<locals>.<genexpr>)	r3r+r9r0r-�updaterBr,r)r5r/r6rrr �derived�s&zContext.derivedcs4�fdd�}tt��j|_�|_|S)Ncst|j����S)N)rZrT)r5)�methrr r!�szContext._all.<locals>.<lambda>)rZr*r@r<)rc�proxyr)rcr �_all�s	zContext._all�keys�values�items�iterkeys�
itervaluesrcCs||jkp||jkS)N)r-r0)r5r9rrr �__contains__�szContext.__contains__cCs.|j|�}t|t�r*t|��|S)zTLookup a variable or raise `KeyError` if the variable is
        undefined.
        )rRrY�	UndefinedrO)r5r1�itemrrr r:�szContext.__getitem__cCs&d|jjt|j��|jfS)Nz
<%s %s of %r>)r;r<�reprrTr9)r5rrr r=�s	zContext.__repr__)zparentzvarszenvironmentzeval_ctxz
exported_varsznamezblocksz__weakref__)r<r>r?r@�	__slots__r7rKrQrRrSrTr
r_rbrerfrgrhrrirjrrkr:r=rrrr rA]s.
	
!		rA)�Mappingc@sFeZdZdZdd�Zedd��Zedd��ZdS)	r8z"One block on a template reference.cCs(||_||_||_||_dS)N)r9�_context�_stack�_depth)r5r9r6�stack�depthrrr r7s			zBlockReference.__init__cCs_|jdt|j�kr<|jjjd|jdd�St|j|j|j|jd�S)zSuper the block.rJz#there is no parent block called %r.r9rK)rs�lenrrrqr+rNr9r8)r5rrr rK	szBlockReference.supercCs>t|j|j|j��}|jjjr:t|�}|S)N)r	rrrsrqrBZ
autoescaper)r5�rvrrr rXszBlockReference.__call__N)	r<r>r?r@r7�propertyrKr
rXrrrr r8s
r8c@s�eZdZdZdddd�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Cstt|�|_||_|j�|_d|_||_yt|�|_Wn!t	t
fk
rod|_YnXdS)NrJ���)�iter�	_iterator�_recurse�
_safe_next�_after�index0�depth0rv�_length�	TypeError�AttributeError)r5�iterableZrecurser�rrr r7s			zLoopContext.__init__cGs'|std��||jt|�S)z7Cycles among the arguments with the current loop index.zno items for cycling given)r�rrv)r5r\rrr �cycle.szLoopContext.cyclecCs
|jdkS)Nr)r)rrrr r!4szLoopContext.<lambda>cCs
|jtkS)N)r~�_last_iteration)rrrr r!5scCs|jdS)NrJ)r)rrrr r!6scCs|j|jS)N)�lengthr)rrrr r!7scCs|j|jS)N)r�rL)rrrr r!8scCs|jdS)NrJ)r�)rrrr r!9scCs|jS)N)r�)r5rrr �__len__;szLoopContext.__len__cCs
t|�S)N)�LoopContextIterator)r5rrr �__iter__>szLoopContext.__iter__cCs.yt|j�SWntk
r)tSYnXdS)N)�nextr{r[r�)r5rrr r}As
zLoopContext._safe_nextcCs8|jdkrtd��|j||j|jd�S)NzMTried to call non recursive loop.  Maybe you forgot the 'recursive' modifier.rJ)r|r�r�)r5r�rrr �loopGszLoopContext.loopcCsT|jdkrMt|j�}t|�|_|jd}t|�||_|jS)Nr))r��tupler{rzrrv)r5r�Ziterations_donerrr r�Ss
zLoopContext.lengthcCsd|jj|j|jfS)Nz
<%s %r/%r>)r;r<rLr�)r5rrr r=`s	zLoopContext.__repr__)r<r>r?r@r7r�rx�firstZlastrLZrevindexZ	revindex0rur�r�r}r
r�rXr�r=rrrr rs"	
c@s@eZdZdZd
Zdd�Zdd�Zdd�Zd	S)r�z The iterator for a loop context.r6cCs
||_dS)N)r6)r5r6rrr r7mszLoopContextIterator.__init__cCs|S)Nr)r5rrr r�pszLoopContextIterator.__iter__cCsR|j}|jd7_|jtkr0t��|j}|j�|_||fS)NrJ)r6rr~r�r[r})r5ZctxZ	next_elemrrr �__next__ss			zLoopContextIterator.__next__N)zcontext)r<r>r?r@ror7r�r�rrrr r�hs
r�c@s@eZdZdZdd�Zedd��Zdd�ZdS)	rzWraps a macro function.c		Cs[||_||_t|�|_||_||_||_||_||_||_	dS)N)
�_environment�_funcrv�_argument_countr9�	arguments�defaults�catch_kwargs�
catch_varargs�caller)	r5r+�funcr9r�r�r�r�r�rrr r7�s							zMacro.__init__c	Os�t|d|j��}t|�}||jkr�x�t|jt|�d��D]�\}}y|j|�}Wn_tk
r�y|j||j|}Wn.tk
r�|j	j
d|d|�}YnXYnX|j|�qTW|jr2|jdd�}|dkr%|j	j
ddd�}|j|�|j
rK|j|�n+|rvtd|jtt|��f��|jr�|j||jd��n7t|�|jkr�td|jt|j�f��|j|�S)Nzparameter %r was not providedr9r�zNo caller definedz%macro %r takes no keyword argument %rz+macro %r takes not more than %d argument(s))r`r�rv�	enumerater��poprOr��
IndexErrorr�rNr#r�r�r�r9r�rzr�r�)	r5r\r]r�Zoff�idxr9r2r�rrr rX�s<,

			
		zMacro.__call__cCs2d|jj|jdkr!dp-t|j�fS)Nz<%s %s>Z	anonymous)r;r<r9rn)r5rrr r=�s	zMacro.__repr__N)r<r>r?r@r7r
rXr=rrrr r}s*c@s$eZdZdZdZdededd�Zed	d
��Z	edd��Z
e	ZZZ
ZZZZZZZZZZZZZZZZZZZ Z!Z"Z#d
d�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*e*Z+dd�Z,dS)rlazThe default undefined type.  This undefined type can be printed and
    iterated over, but every other access will raise an :exc:`jinja2.exceptions.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_exceptionNcCs(||_||_||_||_dS)N)r�r�r�r�)r5�hint�objr9�excrrr r7�s			zUndefined.__init__cOs�|jdkr~|jtkr.d|j}q�t|jt�s_dt|j�|jf}q�dt|j�|jf}n	|j}|j|��dS)z{Regular callback function for undefined objects that raises an
        `jinja2.exceptions.UndefinedError` on call.
        Nz%r is undefinedz%s has no element %rz%r has no attribute %r)r�r�rr�rYrrr�)r5r\r]r�rrr �_fail_with_undefined_error�s	z$Undefined._fail_with_undefined_errorcCs,|dd�dkr"t|��|j�S)Nr)�__)r�r�)r5r9rrr �__getattr__�szUndefined.__getattr__cCst|�t|�kS)N)�type)r5�otherrrr �__eq__�szUndefined.__eq__cCs|j|�S)N)r�)r5r�rrr �__ne__�szUndefined.__ne__cCstt|��S)N)�idr�)r5rrr �__hash__�szUndefined.__hash__cCsdS)Nr"r)r5rrr �__str__szUndefined.__str__cCsdS)Nrr)r5rrr r�szUndefined.__len__ccsdS)Nr)r5rrr r�szUndefined.__iter__cCsdS)NFr)r5rrr �__nonzero__szUndefined.__nonzero__cCsdS)Nrlr)r5rrr r=szUndefined.__repr__)z_undefined_hintz_undefined_objz_undefined_namez_undefined_exception)-r<r>r?r@rorrr7r
r�r��__add__�__radd__�__mul__�__rmul__Z__div__Z__rdiv__�__truediv__�__rtruediv__�__floordiv__�
__rfloordiv__�__mod__�__rmod__�__pos__�__neg__rXr:�__lt__�__le__�__gt__�__ge__�__int__�	__float__�__complex__�__pow__�__rpow__r�r�r�r�r�r�r��__bool__r=rrrr rl�s frlcs��dkr@ddl}|jt���j|jtj���dkrRt��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`.
    Nrcs�|jdkr~|jtkr.d|j}q�t|jt�s_dt|j�|jf}q�dt|j�|jf}n	|j}�jd|�dS)Nz%s is undefinedz%s has no element %sz%s has no attribute %szTemplate variable warning: %s)r�r�rr�rYrrZwarning)Zundefr�)�loggerrr �_log_message.s	z,make_logging_undefined.<locals>._log_messagecs�eZdZ��fdd�Z��fdd�Z��fdd�Zer~��fdd�Z��fd	d
�Zn��fdd�Z	d
S)z0make_logging_undefined.<locals>.LoggingUndefinedcsby�j|||�SWnD|jk
r]}z!�jdt|��|�WYdd}~XnXdS)NzTemplate variable error: %s)r�r��error�str)r5r\r]�e)�baser�rr r�@s
zKmake_logging_undefined.<locals>.LoggingUndefined._fail_with_undefined_errorcs�j|�}�|�|S)N)r�)r5rw)r�r�rr r�Gs
z8make_logging_undefined.<locals>.LoggingUndefined.__str__cs�j|�}�|�|S)N)r�)r5rw)r�r�rr r�Ls
z9make_logging_undefined.<locals>.LoggingUndefined.__iter__cs�j|�}�|�|S)N)r�)r5rw)r�r�rr r�Rs
z<make_logging_undefined.<locals>.LoggingUndefined.__nonzero__cs�j|�}�|�|S)N)�__unicode__)r5rw)r�r�rr r�Ws
z<make_logging_undefined.<locals>.LoggingUndefined.__unicode__cs�j|�}�|�|S)N)r�)r5rw)r�r�rr r�\s
z9make_logging_undefined.<locals>.LoggingUndefined.__bool__N)
r<r>r?r�r�r�rr�r�r�r)r�r�r�rr �LoggingUndefined>sr�)�loggingZ	getLoggerr<Z
addHandlerZ
StreamHandler�sys�stderrrl)r�r�r�r�r)r�r�r�r rs"#c@s(eZdZdZfZdd�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
    cCsN|jdkrC|jtkr)d|jSdt|j�|jfSd|jS)Nz{{ %s }}z{{ no such element: %s[%r] }}z!{{ undefined value printed: %s }})r�r�rr�r)r5rrr r�tszDebugUndefined.__str__N)r<r>r?r@ror�rrrr r�ds
r�c@sAeZdZdZfZejZZZ	Z
ZZZ
ZdS)�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
    N)r<r>r?r@rorlr�r�r�r�r�r�r�r�r�rrrr r�sr�)2r@r��	itertoolsrZjinja2.nodesrrZjinja2.utilsrrrrr	r
rZjinja2.exceptionsrr
rZjinja2._compatrrrrrrr�__all__rr�objectr�rrr3rrA�collectionsrp�register�ImportErrorr8rr�rrlrr�r�rorrrr �<module>
sJ44	�
M@UQ

Zerion Mini Shell 1.0