Your IP : 18.223.171.83


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__/nodes.cpython-37.opt-1.pyc

B

I��a���	@s2UdZddlZddlZddlZddlmZddlmZddl	m
Z
ejr\ddlZ
ddlmZejdd	d
�Zejejejejejejejd�Zejeejejejgejffed<ejej ej!d
�Z"ejeejejgejffed<ej#ej$ej%ej&ej'ej(dd�dd�d�Z)ejeejejejgejffed<Gdd�de*�Z+Gdd�de,�Z-Gdd�d�Z.d	ej/e.e.d�dd�Z0Gdd	�d	e-d�Z1Gdd �d e1�Z2Gd!d"�d"e1�Z3Gd#d$�d$e1�Z4Gd%d&�d&e2�Z5Gd'd(�d(e2�Z6Gd)d*�d*e2�Z7Gd+d,�d,e2�Z8Gd-d.�d.e2�Z9Gd/d0�d0e2�Z:Gd1d2�d2e2�Z;Gd3d4�d4e2�Z<Gd5d6�d6e2�Z=Gd7d8�d8e2�Z>Gd9d:�d:e2�Z?Gd;d<�d<e2�Z@Gd=d>�d>e2�ZAGd?d@�d@e2�ZBGdAdB�dBe2�ZCGdCdD�dDe1�ZDGdEdF�dFeD�ZEGdGdH�dHeD�ZFGdIdJ�dJeD�ZGGdKdL�dLeD�ZHGdMdN�dNeD�ZIGdOdP�dPeI�ZJGdQdR�dReI�ZKGdSdT�dTeI�ZLGdUdV�dVeI�ZMGdWdX�dXeI�ZGdYdZ�dZe3�ZNGd[d\�d\e3�ZOGd]d^�d^eD�ZPejQd_ej/e.ejLejMejejejejffd`�dadb�ZRGdcdd�ddeD�ZSGdedf�dfeS�ZTGdgdh�dheS�ZUGdidj�djeD�ZVGdkdl�dleD�ZWGdmdn�dneD�ZXGdodp�dpeD�ZYGdqdr�dreD�ZZGdsdt�dteD�Z[Gdudv�dve3�Z\Gdwdx�dxeE�Z]Gdydz�dzeE�Z^Gd{d|�d|eE�Z_Gd}d~�d~eE�Z`Gdd��d�eE�ZaGd�d��d�eE�ZbGd�d��d�eE�ZcGd�d��d�eE�ZdGd�d��d�eE�ZeGd�d��d�eF�ZfGd�d��d�eF�ZgGd�d��d�eF�ZhGd�d��d�eD�ZiGd�d��d�eD�ZjGd�d��d�eD�ZkGd�d��d�eD�ZlGd�d��d�eD�ZmGd�d��d�eD�ZnGd�d��d�eD�ZoGd�d��d�eD�ZpGd�d��d�e2�ZqGd�d��d�e2�ZrGd�d��d�e2�ZsGd�d��d�e2�ZtGd�d��d�e2�ZuGd�d��d�eu�Zvejejd�d��d�d��Zwexew�e-_y[wdS)�z�AST nodes generated by the parser for the compiler. Also provides
some node tree helper functions used by the parser and compiler in order
to normalize nodes.
�N)�deque)�Markup�)�_PassArg)�Environment�
_NodeBound�Node)Zbound)�*�/z//z**�%�+�-�_binop_to_func)�notrr
�
_uaop_to_funccCs||kS)N�)�a�brr�=/opt/alt/python37/lib/python3.7/site-packages/jinja2/nodes.py�<lambda>+�rcCs||kS)Nr)rrrrrr,r)�eq�ne�gtZgteq�ltZlteq�inZnotin�_cmpop_to_funcc@seZdZdZdS)�
Impossiblez8Raised if the node could not perform a requested action.N)�__name__�
__module__�__qualname__�__doc__rrrrr0src@seZdZdZdd�ZdS)�NodeTypez�A metaclass for nodes that handles the field and attribute
    inheritance.  fields and attributes from the parent class are
    automatically forwarded to the child.cCs�x|dD]t}g}|�t|r |dnt|d��|�|�|d��t|�dksRtd��t|�tt|��ksntd��t|�||<qW|�dd�t	�
||||�S)	N)�fields�
attributesrrrz multiple inheritance not allowedzlayout conflict�abstractF)�extend�getattr�object�get�len�AssertionError�set�tuple�
setdefault�type�__new__)Zmcs�name�bases�d�attrZstoragerrrr09s
zNodeType.__new__N)rrr r!r0rrrrr"4sr"c@s`eZdZdZd
dejedd�dd�Zejeej	fd�dd	�Z
ejeej	fdd
�dd�ZdS)�EvalContextzcHolds evaluation time information.  Custom attributes can be attached
    to it in extensions.
    Nr)�environment�
template_name�returncCs0||_t|j�r|�|�|_n|j|_d|_dS)NF)r6�callable�
autoescape�volatile)�selfr6r7rrr�__init__Js

zEvalContext.__init__)r8cCs
|j��S)N)�__dict__�copy)r<rrr�saveTszEvalContext.save)�oldr8cCs|j��|j�|�dS)N)r>�clear�update)r<rArrr�revertWs
zEvalContext.revert)N)rrr r!�t�Optional�strr=�Mapping�Anyr@rDrrrrr5Es
r5)�node�ctxr8cCs(|dkr$|jdkrtd��t|j�S|S)NzIif no eval context is passed, the node must have an attached environment.)r6�RuntimeErrorr5)rJrKrrr�get_eval_context\s

rMc@s�eZdZUdZdZejedfed<dZ	ejedfed<dZ
eed<ejd	ed
<ej
ej
dd�d
d�Zd+ejejeejejeejejeej
fd�dd�Zd,ejejeejejeejdd�dd�Zejeejed�dd�Zejejeejejedffejed�dd�Zedd�dd�Zd-eedd�dd�Zd	dd �d!d"�Zej
ed#�d$d%�ZejZed&�d'd(�Zed&�d)d*�Z dS).ra�Baseclass for all Jinja nodes.  There are a number of nodes available
    of different types.  There are four major types:

    -   :class:`Stmt`: statements
    -   :class:`Expr`: expressions
    -   :class:`Helper`: helper nodes
    -   :class:`Template`: the outermost wrapper node

    All nodes have fields and attributes.  Fields may be other nodes, lists,
    or arbitrary values.  Fields are passed to the constructor as regular
    positional arguments, attributes as keyword arguments.  Each node has
    two attributes: `lineno` (the line number of the node) and `environment`.
    The `environment` attribute is set at the end of the parsing process for
    all nodes automatically.
    r.r#)�linenor6r$TrNrr6N)r#r$r8cOs�|jrtd��|r�t|�t|j�krt|js>tt|�j�d���tt|�j�dt|j��dt|j�dkrjdnd����x$t|j|�D]\}}t|||�q�Wx"|jD]}t|||�	|d��q�W|r�tdt
t|������dS)	Nz#abstract nodes are not instantiablez takes 0 argumentsz takes 0 or z	 argumentr�s�zunknown attribute )r%�	TypeErrorr*r#r/r�zip�setattrr$�pop�next�iter)r<r#r$r1�argr4rrrr=s4z
Node.__init__)�exclude�onlyr8c	csnxh|jD]^}|dkr|dks<|dk	r,||ks<|dk	r||kry|t||�fVWqtk
rdYqXqWdS)aZThis method iterates over all fields that are defined and yields
        ``(key, value)`` tuples.  Per default all fields are returned, but
        it's possible to limit that to some fields by providing the `only`
        parameter or to exclude some using the `exclude` parameter.  Both
        should be sets or tuples of field names.
        N)r#r'�AttributeError)r<rXrYr1rrr�iter_fields�szNode.iter_fieldsccsXxR|�||�D]B\}}t|t�r@x.|D]}t|t�r&|Vq&Wqt|t�r|VqWdS)z�Iterates over all direct child nodes of the node.  This iterates
        over all fields and yields the values of they are nodes.  If the value
        of a field is a list all the nodes in that list are returned.
        N)r[�
isinstance�listr)r<rXrY�_�item�nrrr�iter_child_nodes�s	



zNode.iter_child_nodes)�	node_typer8cCsx|�|�D]}|SWdS)ziFind the first node of a given type.  If no such node exists the
        return value is `None`.
        N)�find_all)r<rb�resultrrr�find�sz	Node.findccs6x0|��D]$}t||�r|V|�|�EdHq
WdS)z�Find all the nodes of a given type.  If the type is a tuple,
        the check is performed for any of the tuple items.
        N)rar\rc)r<rbZchildrrrrc�s
z
Node.find_all)rKr8cCs>t|g�}x.|r8|��}d|jkr(||_|�|���qW|S)aReset the context of a node and all child nodes.  Per default the
        parser will all generate nodes that have a 'load' context as it's the
        most common one.  This method is used in the parser to set assignment
        targets and other nodes to a store context.
        rK)r�popleftr#rKr&ra)r<rK�todorJrrr�set_ctx�s

zNode.set_ctxF)rN�overrider8cCsLt|g�}x<|rF|��}d|jkr6|jdks0|r6||_|�|���qW|S)z.Set the line numbers of the node and children.rNN)rrfr$rNr&ra)r<rNrirgrJrrr�
set_lineno�s

zNode.set_lineno)r6r8cCs4t|g�}x$|r.|��}||_|�|���qW|S)z"Set the environment for all nodes.)rrfr6r&ra)r<r6rgrJrrr�set_environment�s
zNode.set_environment)�otherr8cCs,t|�t|�k	rtSt|���t|���kS)N)r/�NotImplementedr-r[)r<rlrrr�__eq__�szNode.__eq__)r8cs0d��fdd��jD��}t��j�d|�d�S)Nz, c3s$|]}|�dt�|d���VqdS)�=N)r')�.0r)r<rr�	<genexpr>�sz Node.__repr__.<locals>.<genexpr>�(�))�joinr#r/r)r<Zargs_strr)r<r�__repr__�sz
Node.__repr__cs8tjttjfdd���fdd��g��|�d���S)N)rJr8cs�t|t�s��t|��dS��dt|�j�d��|jsH��d�dSx�t|j�D]t\}}|rj��d�t||�}t|t	�r���d�x*t|�D]\}}|r���d��|�q�W��d�qT�|�qTW��d�dS)Nznodes.rrrsz, �[�])
r\r�append�reprr/rr#�	enumerater'r])rJ�idxZfield�valuer_)�_dump�bufrrr}�s(






zNode.dump.<locals>._dumprP)rE�UnionrrIrt)r<r)r}r~r�dump�s"z	Node.dump)NN)NN)F)!rrr r!r#rE�TuplerG�__annotations__r$r%�intrFrIr=�	Container�Iteratorr[raZTyperrerrcrh�boolrjrkrnr(�__hash__rur�rrrrrgs.
 

"		)�	metaclassc@seZdZdZdZdS)�StmtzBase node for all statements.TN)rrr r!r%rrrrr�sr�c@seZdZdZdZdS)�Helperz,Nodes that exist in a specific context only.TN)rrr r!r%rrrrr�sr�c@s$eZdZUdZdZejeed<dS)�TemplatezjNode that represents a template.  This must be the outermost node that
    is passed to the compiler.
    )�bodyr�N)	rrr r!r#rE�Listrr�rrrrr�$s
r�c@s$eZdZUdZdZejded<dS)�Outputz�A node that holds multiple expressions which are then printed out.
    This is used both for the `print` statement and the regular template data.
    )�nodes�Exprr�N)rrr r!r#rEr�r�rrrrr�-s
r�c@seZdZUdZdZded<dS)�Extendsz Represents an extends statement.)�templater�r�N)rrr r!r#r�rrrrr�6s
r�c@sXeZdZUdZdZeed<eed<ejeed<ejeed<ej	eed<e
ed<d	S)
�ForaxThe for loop.  `target` is the target for the iteration (usually a
    :class:`Name` or :class:`Tuple`), `iter` the iterable.  `body` is a list
    of nodes that are used as loop-body, and `else_` a list of nodes for the
    `else` block.  If no else node exists it has to be an empty list.

    For filtered nodes an expression can be stored as `test`, otherwise `None`.
    )�targetrVr��else_�test�	recursiver�rVr�r�r�r�N)rrr r!r#rr�rEr�rFr�rrrrr�=s
r�c@sHeZdZUdZdZeed<ejeed<ejded<ejeed<dS)�Ifz4If `test` is true, `body` is rendered, else `else_`.)r�r��elif_r�r�r�r�r�N)	rrr r!r#rr�rEr�rrrrr�Os
r�c@sHeZdZUdZdZeed<ejded<ejded<eje	ed<d	S)
�Macroz�A macro definition.  `name` is the name of the macro, `args` a list of
    arguments and `defaults` a list of defaults if there are any.  `body` is
    a list of nodes for the macro body.
    )r1�args�defaultsr�r1�Namer�r�r�r�N)
rrr r!r#rGr�rEr�rrrrrr�Ys
r�c@sHeZdZUdZdZded<ejded<ejded<ejeed	<d
S)�	CallBlockz�Like a macro without a name but a call instead.  `call` is called with
    the unnamed macro as `caller` argument this node holds.
    )�callr�r�r��Callr�r�r�r�r�r�N)	rrr r!r#r�rEr�rrrrrr�fs
r�c@s,eZdZUdZdZejeed<ded<dS)�FilterBlockzNode for filter sections.)r��filterr��Filterr�N)	rrr r!r#rEr�rr�rrrrr�rs
r�c@s@eZdZUdZdZejded<ejded<ejeed<dS)�Withz�Specific node for with statements.  In older versions of Jinja the
    with statement was implemented on the base of the `Scope` node instead.

    .. versionadded:: 2.9.3
    )�targets�valuesr�r�r�r�r�N)	rrr r!r#rEr�r�rrrrrr�zs

r�c@s<eZdZUdZdZeed<eje	ed<e
ed<e
ed<dS)�BlockzkA node that represents a block.

    .. versionchanged:: 3.0.0
        the `required` field was added.
    )r1r��scoped�requiredr1r�r�r�N)rrr r!r#rGr�rEr�rr�rrrrr��s
r�c@s.eZdZUdZdZded<eed<eed<dS)�Includez'A node that represents the include tag.)r��with_context�ignore_missingr�r�r�r�N)rrr r!r#r�r�rrrrr��s

r�c@s.eZdZUdZdZded<eed<eed<dS)�Importz&A node that represents the import tag.)r�r�r�r�r�r�r�N)rrr r!r#r�rGr�rrrrr��s

r�c@sHeZdZUdZdZded<ejeje	ej
e	e	ffed<eed<dS)�
FromImportaA node that represents the from import tag.  It's important to not
    pass unsafe names to the name attribute.  The compiler translates the
    attribute lookups directly into getattr calls and does *not* use the
    subscript callback of the interface.  As exported variables may not
    start with double underscores (which the parser asserts) this is not a
    problem for regular Jinja code, but if this node is used in an extension
    extra care must be taken.

    The list of names may contain tuples if aliases are wanted.
    )r��namesr�r�r�r�r�N)rrr r!r#r�rEr�rrGr�r�rrrrr��s


"r�c@seZdZUdZdZeed<dS)�ExprStmtzAA statement that evaluates an expression and discards the result.)rJrJN)rrr r!r#rr�rrrrr��s
r�c@s&eZdZUdZdZded<eed<dS)�Assignz"Assigns an expression to a target.)r�rJr�r�rJN)rrr r!r#r�rrrrrr��s
r�c@s:eZdZUdZdZded<ejded<eje	ed<dS)	�AssignBlockzAssigns a block to a target.)r�r�r�r�r�r�r�r�N)
rrr r!r#r�rErFr�rrrrrr��s

r�c@s<eZdZdZdZd
ejeejd�dd�Z	e
d�dd	�ZdS)r�zBaseclass for all expressions.TN)�eval_ctxr8cCs
t��dS)anReturn the value of the expression as constant or raise
        :exc:`Impossible` if this was not possible.

        An :class:`EvalContext` can be provided, if none is given
        a default context is created which requires the nodes to have
        an attached environment.

        .. versionchanged:: 2.4
           the `eval_ctx` parameter was added.
        N)r)r<r�rrr�as_const�sz
Expr.as_const)r8cCsdS)z8Check if it's possible to assign something to this node.Fr)r<rrr�
can_assign�szExpr.can_assign)N)rrr r!r%rErFr5rIr�r�r�rrrrr��s
r�c@sLeZdZUdZdZeed<eed<eed<dZde	j
ee	jd�d	d
�Z
dS)�BinExprz%Baseclass for all binary expressions.)�left�rightr�r��operatorTN)r�r8c
Cszt||�}|jjr&|j|jjkr&t��t|j}y||j�|�|j	�|��St
k
rt}zt�|�Wdd}~XYnXdS)N)rMr6�	sandboxedr�Zintercepted_binopsrrr�r�r��	Exception)r<r��f�errrr��s

zBinExpr.as_const)N)rrr r!r#r�r�rGr%rErFr5rIr�rrrrr��s
r�c@sDeZdZUdZdZeed<eed<dZd
e	j
ee	jd�dd	�Z
dS)�	UnaryExprz$Baseclass for all unary expressions.)rJrJr�TN)r�r8c
Cspt||�}|jjr&|j|jjkr&t��t|j}y||j�|��St	k
rj}zt�|�Wdd}~XYnXdS)N)
rMr6r�r�Zintercepted_unopsrrrJr�r�)r<r�r�r�rrrr�	s

zUnaryExpr.as_const)N)rrr r!r#r�r�rGr%rErFr5rIr�rrrrr�s
r�c@s4eZdZUdZdZeed<eed<ed�dd�ZdS)	r�aLooks up a name or stores a value in a name.
    The `ctx` of the node can be one of the following values:

    -   `store`: store a value in the name
    -   `load`: load that name
    -   `param`: like `store` but if the name was defined as function parameter.
    )r1rKr1rK)r8cCs
|jdkS)N>�false�False�true�None�none�True)r1)r<rrrr�&szName.can_assignN)	rrr r!r#rGr�r�r�rrrrr�s

r�c@s4eZdZUdZdZeed<eed<ed�dd�ZdS)	�NSRefz)Reference to a namespace value assignment)r1r4r1r4)r8cCsdS)NTr)r<rrrr�1szNSRef.can_assignN)	rrr r!r#rGr�r�r�rrrrr�*s

r�c@seZdZdZdZdS)�LiteralzBaseclass for literals.TN)rrr r!r%rrrrr�9sr�c@s\eZdZUdZdZejed<deje	ejd�dd�Z
ed
ejejeddd	�d
d��Z
dS)�ConstaAll constant values.  The parser will return this node for simple
    constants such as ``42`` or ``"foo"`` but it can be used to store more
    complex values such as lists too.  Only constants with a safe
    representation (objects where ``eval(repr(x)) == x`` is true).
    )r|r|N)r�r8cCs|jS)N)r|)r<r�rrrr�IszConst.as_constzt.Optional[Environment])r|rNr6r8cCs(ddlm}||�st��||||d�S)z�Return a const object if the value is representable as
        constant value in the generated code, otherwise it will raise
        an `Impossible` exception.
        r)�
has_safe_repr)rNr6)Zcompilerr�r)�clsr|rNr6r�rrr�from_untrustedLszConst.from_untrusted)N)NN)rrr r!r#rErIr�rFr5r��classmethodr�r�rrrrr�?s

r�c@s6eZdZUdZdZeed<deje	ed�dd�Z
dS)	�TemplateDatazA constant template string.)�datar�N)r�r8cCs,t||�}|jrt��|jr&t|j�S|jS)N)rMr;rr:rr�)r<r�rrrr�ds

zTemplateData.as_const)N)rrr r!r#rGr�rErFr5r�rrrrr�^s
r�c@s^eZdZUdZdZejeed<e	ed<d
ej
eejej
dfd�dd	�Zed
�dd�ZdS)r�z�For loop unpacking and some other things like multiple arguments
    for subscripts.  Like for :class:`Name` `ctx` specifies if the tuple
    is used for loading the names or storing.
    )�itemsrKr�rKN.)r�r8cs"t|���t�fdd�|jD��S)Nc3s|]}|���VqdS)N)r�)rp�x)r�rrrqysz!Tuple.as_const.<locals>.<genexpr>)rMr-r�)r<r�r)r�rr�ws
zTuple.as_const)r8cCs x|jD]}|��sdSqWdS)NFT)r�r�)r<r_rrrr�{szTuple.can_assign)N)rrr r!r#rEr�r�r�rGrFr5r�rIr�r�r�rrrrr�ms
$r�c@sDeZdZUdZdZejeed<dej	e
ejejd�dd�ZdS)	r�z&Any list literal such as ``[1, 2, 3]``)r�r�N)r�r8cst|����fdd�|jD�S)Ncsg|]}|����qSr)r�)rpr�)r�rr�
<listcomp>�sz!List.as_const.<locals>.<listcomp>)rMr�)r<r�r)r�rr��s
z
List.as_const)N)
rrr r!r#rEr�r�r�rFr5rIr�rrrrr��s
r�c@sJeZdZUdZdZejded<d	eje	ej
ejejfd�dd�ZdS)
�DictzeAny dict literal such as ``{1: 2, 3: 4}``.  The items must be a list of
    :class:`Pair` nodes.
    )r��Pairr�N)r�r8cs"t|���t�fdd�|jD��S)Nc3s|]}|���VqdS)N)r�)rpr�)r�rrrq�sz Dict.as_const.<locals>.<genexpr>)rM�dictr�)r<r�r)r�rr��s
z
Dict.as_const)N)
rrr r!r#rEr�r�rFr5r�rIr�rrrrr��s


r�c@sLeZdZUdZdZeed<eed<d	eje	ej
ejejfd�dd�ZdS)
r�zA key, value pair for dicts.)�keyr|r�r|N)r�r8cCs"t||�}|j�|�|j�|�fS)N)rMr�r�r|)r<r�rrrr��s
z
Pair.as_const)N)
rrr r!r#r�r�rErFr5r�rIr�rrrrr��s

r�c@sJeZdZUdZdZeed<eed<d	ej	e
ejeejfd�dd�Z
dS)
�Keywordz>A key, value pair for keyword arguments where key is a string.)r�r|r�r|N)r�r8cCst||�}|j|j�|�fS)N)rMr�r|r�)r<r�rrrr��s
zKeyword.as_const)N)rrr r!r#rGr�r�rErFr5r�rIr�rrrrr��s

r�c@sNeZdZUdZdZeed<eed<ejeed<d
eje	ej
d�dd	�ZdS)�CondExprzZA conditional expression (inline if expression).  (``{{
    foo if bar else baz }}``)
    )r��expr1�expr2r�r�r�N)r�r8cCs>t||�}|j�|�r"|j�|�S|jdkr2t��|j�|�S)N)rMr�r�r�r�r)r<r�rrrr��s

zCondExpr.as_const)N)rrr r!r#r�r�rErFr5rIr�rrrrr��s
r�)�_FilterTestCommonr�)rJr�r8c
s��fdd�|jD�}t�fdd�|jD��}|jdk	rxy|�|j����Wn*tk
rv}zt�|�Wdd}~XYnX|jdk	r�y|�	|j����Wn*tk
r�}zt�|�Wdd}~XYnX||fS)Ncsg|]}|����qSr)r�)rpr�)r�rrr��sz!args_as_const.<locals>.<listcomp>c3s|]}|���VqdS)N)r�)rpr�)r�rrrq�sz args_as_const.<locals>.<genexpr>)
r�r��kwargs�dyn_argsr&r�r�r�
dyn_kwargsrC)rJr�r�r�r�r)r�r�
args_as_const�s

r�c@s|eZdZUdZeed<eed<ejeed<eje	ed<ej
eed<ej
eed<dZdZd
ej
e
ejd
�dd�Zd	S)r�)rJr1r�r�r�r�rJr1r�r�r�r�TN)r�r8c
Cst||�}|jrt��|jr&|jj}n|jj}|�|j�}t	�
|�}|dksV|t	jkr\t��|jjr�t
|dd�dks~t�|�r�t��t||�\}}|�d|j�|��|t	jkr�|�d|�n|t	jkr�|�d|j�y
|||�Stk
�r}zt�|�Wdd}~XYnXdS)NZjinja_async_variantFTr)rMr;r�
_is_filterr6�filtersZtestsr)r1rZfrom_obj�contextZis_asyncr'�inspectZiscoroutinefunctionr��insertrJr�Zeval_contextr�)r<r�Zenv_map�funcZpass_argr�r�r�rrrr��s0






z_FilterTestCommon.as_const)N)rrr r#r�r�rGrEr�r�rFr%r�r5rIr�rrrrr��s
r�csBeZdZUdZejeed<dejeej	d��fdd�
Z
�ZS)r�z�Apply a filter to an expression. ``name`` is the name of the
    filter, the other fields are the same as :class:`Call`.

    If ``node`` is ``None``, the filter is being used in a filter block
    and is applied to the content of the block.
    rJN)r�r8cs|jdkrt��t�j|d�S)N)r�)rJr�superr�)r<r�)�	__class__rrr�s
zFilter.as_const)N)rrr r!rErFr�r�r5rIr��
__classcell__rr)r�rr�s
r�c@seZdZdZdZdS)�Testa/Apply a test to an expression. ``name`` is the name of the test,
    the other field are the same as :class:`Call`.

    .. versionchanged:: 3.0
        ``as_const`` shares the same logic for filters and tests. Tests
        check for volatile, async, and ``@pass_context`` etc.
        decorators.
    FN)rrr r!r�rrrrr�"sr�c@sVeZdZUdZdZeed<ejeed<eje	ed<ej
eed<ej
eed<dS)	r�a/Calls an expression.  `args` is a list of arguments, `kwargs` a list
    of keyword arguments (list of :class:`Keyword` nodes), and `dyn_args`
    and `dyn_kwargs` has to be either `None` or a node that is used as
    node for dynamic positional (``*args``) or keyword (``**kwargs``)
    arguments.
    )rJr�r�r�r�rJr�r�r�r�N)rrr r!r#r�r�rEr�r�rFrrrrr�/s
r�c@sHeZdZUdZdZeed<eed<eed<d
ej	e
ejd�dd	�ZdS)�Getitemz@Get an attribute or item from an expression and prefer the item.)rJrWrKrJrWrKN)r�r8c
Csh|jdkrt��t||�}y|j�|j�|�|j�|��Stk
rb}zt�|�Wdd}~XYnXdS)N�load)	rKrrMr6�getitemrJr�rWr�)r<r�r�rrrr�Gs

zGetitem.as_const)N)
rrr r!r#r�r�rGrErFr5rIr�rrrrr�?s
r�c@sHeZdZUdZdZeed<eed<eed<d
ej	e
ejd�dd	�ZdS)�GetattrznGet an attribute or item from an expression that is a ascii-only
    bytestring and prefer the attribute.
    )rJr4rKrJr4rKN)r�r8c
Csb|jdkrt��t||�}y|j�|j�|�|j�Stk
r\}zt�|�Wdd}~XYnXdS)Nr�)	rKrrMr6r'rJr�r4r�)r<r�r�rrrr�_s

zGetattr.as_const)N)
rrr r!r#r�r�rGrErFr5rIr�rrrrr�Us
r�c@sXeZdZUdZdZejeed<ejeed<ejeed<d
eje	e
d�dd	�ZdS)�Slicez_Represents a slice object.  This must only be used as argument for
    :class:`Subscript`.
    )�start�stop�stepr�r�r�N)r�r8csJt|���tjttjtjd��fdd�}t||j�||j�||j��S)N)�objr8cs|dkrdS|���S)N)r�)r�)r�rr�constxszSlice.as_const.<locals>.const)	rMrErFr�rI�slicer�r�r�)r<r�r�r)r�rr�us
"zSlice.as_const)N)rrr r!r#rErFr�r�r5r�r�rrrrr�ks
r�c@s<eZdZUdZdZejeed<dej	e
ed�dd�ZdS)	�ConcatzXConcatenates the list of expressions provided after converting
    them to strings.
    )r�r�N)r�r8cs$t|���d��fdd�|jD��S)NrPc3s|]}t|����VqdS)N)rGr�)rpr�)r�rrrq�sz"Concat.as_const.<locals>.<genexpr>)rMrtr�)r<r�r)r�rr��s
zConcat.as_const)N)
rrr r!r#rEr�r�r�rFr5rGr�rrrrr��s
r�c@sFeZdZUdZdZeed<ejded<d
ej	e
ejd�dd	�ZdS)�CompareziCompares an expression with some other expressions.  `ops` must be a
    list of :class:`Operand`\s.
    )�expr�opsr��Operandr�N)r�r8c
Cs�t||�}|j�|�}}y<x6|jD],}|j�|�}t|j||�}|sLdS|}q$WWn*tk
r�}zt�|�Wdd}~XYnX|S)NF)rMr�r�r�r�opr�r)r<r�rdr|r�Z	new_valuer�rrrr��s
zCompare.as_const)N)
rrr r!r#r�r�rEr�rFr5rIr�rrrrr��s

r�c@s&eZdZUdZdZeed<eed<dS)r�z$Holds an operator and an expression.)r�r�r�r�N)rrr r!r#rGr�r�rrrrr��s
r�c@seZdZdZdZdS)�Mulz(Multiplies the left with the right node.r	N)rrr r!r�rrrrr��sr�c@seZdZdZdZdS)�Divz#Divides the left by the right node.r
N)rrr r!r�rrrrr��sr�c@seZdZdZdZdS)�FloorDivzbDivides the left by the right node and converts the
    result into an integer by truncating.
    z//N)rrr r!r�rrrrr��sr�c@seZdZdZdZdS)�AddzAdd the left to the right node.rN)rrr r!r�rrrrr��sr�c@seZdZdZdZdS)�Subz&Subtract the right from the left node.r
N)rrr r!r�rrrrr��sr�c@seZdZdZdZdS)�ModzLeft modulo right.rN)rrr r!r�rrrrr��sr�c@seZdZdZdZdS)�PowzLeft to the power of right.z**N)rrr r!r�rrrrr��sr�c@s.eZdZdZdZdejeejd�dd�Z	dS)�AndzShort circuited AND.�andN)r�r8cCs"t||�}|j�|�o |j�|�S)N)rMr�r�r�)r<r�rrrr��s
zAnd.as_const)N)
rrr r!r�rErFr5rIr�rrrrr�src@s.eZdZdZdZdejeejd�dd�Z	dS)�OrzShort circuited OR.�orN)r�r8cCs"t||�}|j�|�p |j�|�S)N)rMr�r�r�)r<r�rrrr��s
zOr.as_const)N)
rrr r!r�rErFr5rIr�rrrrr�src@seZdZdZdZdS)�NotzNegate the expression.rN)rrr r!r�rrrrr�src@seZdZdZdZdS)�NegzMake the expression negative.r
N)rrr r!r�rrrrr�src@seZdZdZdZdS)�Posz8Make the expression positive (noop for most expressions)rN)rrr r!r�rrrrr�src@seZdZUdZdZeed<dS)�EnvironmentAttributez�Loads an attribute from the environment object.  This is useful for
    extensions that want to call a callback stored on the environment.
    )r1r1N)rrr r!r#rGr�rrrrrs
rc@s&eZdZUdZdZeed<eed<dS)�ExtensionAttributez�Returns the attribute of an extension bound to the environment.
    The identifier is the identifier of the :class:`Extension`.

    This node is usually constructed by calling the
    :meth:`~jinja2.ext.Extension.attr` method on an extension.
    )�
identifierr1r	r1N)rrr r!r#rGr�rrrrrs
rc@seZdZUdZdZeed<dS)�ImportedNamea&If created with an import name the import name is returned on node
    access.  For example ``ImportedName('cgi.escape')`` returns the `escape`
    function from the cgi module on evaluation.  Imports are optimized by the
    compiler so there is no need to assign them to local variables.
    )�
importnamerN)rrr r!r#rGr�rrrrr
s
r
c@s,eZdZUdZdZeed<dd�dd�ZdS)�InternalNamea6An internal name in the compiler.  You cannot create these nodes
    yourself but the parser provides a
    :meth:`~jinja2.parser.Parser.free_identifier` method that creates
    a new identifier for you.  This identifier is not available from the
    template and is not treated specially by the compiler.
    )r1r1N)r8cCstd��dS)NzKCan't create internal names.  Use the `free_identifier` method on a parser.)rQ)r<rrrr=2szInternalName.__init__)rrr r!r#rGr�r=rrrrr's
rc@s6eZdZUdZdZeed<deje	e
d�dd�ZdS)	�MarkSafez:Mark the wrapped expression as safe (wrap it as `Markup`).)r�r�N)r�r8cCst||�}t|j�|��S)N)rMrr�r�)r<r�rrrr�?s
zMarkSafe.as_const)N)rrr r!r#r�r�rErFr5rr�rrrrr
9s
r
c@sBeZdZUdZdZeed<deje	ej
eejfd�dd�Z
dS)	�MarkSafeIfAutoescapez�Mark the wrapped expression as safe (wrap it as `Markup`) but
    only if autoescaping is active.

    .. versionadded:: 2.5
    )r�r�N)r�r8cCs4t||�}|jrt��|j�|�}|jr0t|�S|S)N)rMr;rr�r�r:r)r<r�r�rrrr�Ns
zMarkSafeIfAutoescape.as_const)N)rrr r!r#r�r�rErFr5rrrIr�rrrrrDs


rc@seZdZdZdS)�ContextReferenceaMReturns the current template context.  It can be used like a
    :class:`Name` node, with a ``'load'`` ctx and will return the
    current :class:`~jinja2.runtime.Context` object.

    Here an example that assigns the current template name to a
    variable named `foo`::

        Assign(Name('foo', ctx='store'),
               Getattr(ContextReference(), 'name'))

    This is basically equivalent to using the
    :func:`~jinja2.pass_context` decorator when using the high-level
    API, which causes a reference to the context to be passed as the
    first argument to a function.
    N)rrr r!rrrrrZsrc@seZdZdZdS)�DerivedContextReferencez�Return the current template context including locals. Behaves
    exactly like :class:`ContextReference`, but includes local
    variables, such as from a ``for`` loop.

    .. versionadded:: 2.11
    N)rrr r!rrrrrlsrc@seZdZdZdS)�ContinuezContinue a loop.N)rrr r!rrrrrusrc@seZdZdZdS)�Breakz
Break a loop.N)rrr r!rrrrrysrc@s$eZdZUdZdZejeed<dS)�ScopezAn artificial scope.)r�r�N)	rrr r!r#rEr�rr�rrrrr}s
rc@s,eZdZUdZdZeed<eje	ed<dS)�OverlayScopea�An overlay scope for extensions.  This is a largely unoptimized scope
    that however can be used to introduce completely arbitrary variables into
    a sub scope from a dictionary or dictionary like object.  The `context`
    field has to evaluate to a dictionary object.

    Example usage::

        OverlayScope(context=self.call_method('get_context'),
                     body=[...])

    .. versionadded:: 2.10
    )r�r�r�r�N)
rrr r!r#r�r�rEr�rrrrrr�s
rc@s$eZdZUdZdZejeed<dS)�EvalContextModifiera
Modifies the eval context.  For each option that should be modified,
    a :class:`Keyword` has to be added to the :attr:`options` list.

    Example to change the `autoescape` setting::

        EvalContextModifier(options=[Keyword('autoescape', Const(True))])
    )�optionsrN)	rrr r!r#rEr�r�r�rrrrr�s
rc@s$eZdZUdZdZejeed<dS)�ScopedEvalContextModifierz�Modifies the eval context and reverts it later.  Works exactly like
    :class:`EvalContextModifier` but will only modify the
    :class:`~jinja2.nodes.EvalContext` for nodes in the :attr:`body`.
    )r�r�N)	rrr r!r#rEr�rr�rrrrr�s
rzte.NoReturn)r�r�r8cOstd��dS)Nzcan't create custom node types)rQ)r�r�rrr�_failing_new�sr)zr!r�r��typingrE�collectionsrZ
markupsaferZutilsrZ
TYPE_CHECKINGZtyping_extensionsZter6rZTypeVarr�mul�truediv�floordiv�pow�mod�add�subrr�rG�CallablerIr��not_�pos�negrrrr�ger�lerr�rr/r"r5rFrMrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr
rr
rrrrrrrrrr�staticmethodr0rrrr�<module>s�0,22		


			.0



		
	



?>