U a͆ @s2UdZddlZddlZddlZddlmZddlmZddl m Z ej r\ddl Z ddlmZejdd d Zejejejejejejejd Zejeejejejgejffed <ejej ej!d Z"ejeejejgejffed<ej#ej$ej%ej&ej'ej(dddddZ)ejeejejejgejffed<Gddde*Z+Gddde,Z-GdddZ.d ej/e.e.dddZ0Gdd d e-dZ1Gdd d e1Z2Gd!d"d"e1Z3Gd#d$d$e1Z4Gd%d&d&e2Z5Gd'd(d(e2Z6Gd)d*d*e2Z7Gd+d,d,e2Z8Gd-d.d.e2Z9Gd/d0d0e2Z:Gd1d2d2e2Z;Gd3d4d4e2ZGd9d:d:e2Z?Gd;d<dd>e2ZAGd?d@d@e2ZBGdAdBdBe2ZCGdCdDdDe1ZDGdEdFdFeDZEGdGdHdHeDZFGdIdJdJeDZGGdKdLdLeDZHGdMdNdNeDZIGdOdPdPeIZJGdQdRdReIZKGdSdTdTeIZLGdUdVdVeIZMGdWdXdXeIZGdYdZdZe3ZNGd[d\d\e3ZOGd]d^d^eDZPejQd_ej/e.ejLejMejejejejffd`dadbZRGdcddddeDZSGdedfdfeSZTGdgdhdheSZUGdidjdjeDZVGdkdldleDZWGdmdndneDZXGdodpdpeDZYGdqdrdreDZZGdsdtdteDZ[Gdudvdve3Z\GdwdxdxeEZ]GdydzdzeEZ^Gd{d|d|eEZ_Gd}d~d~eEZ`GdddeEZaGdddeEZbGdddeEZcGdddeEZdGdddeEZeGdddeFZfGdddeFZgGdddeFZhGdddeDZiGdddeDZjGdddeDZkGdddeDZlGdddeDZmGdddeDZnGdddeDZoGdddeDZpGddde2ZqGddde2ZrGddde2ZsGddde2ZtGddde2ZuGdddeuZvejejddddZwexewe-_y[wdS)zAST 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 _NodeBoundNode)bound)*///**%+-_binop_to_func)notrr _uaop_to_funccCs||kSNabrrMC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-8gbwd15f\jinja2\nodes.py+rcCs||kSrrrrrrr,r)eqnegtZgteqltZlteqinnotin_cmpop_to_funcc@seZdZdZdS) Impossiblez8Raised if the node could not perform a requested action.N__name__ __module__ __qualname____doc__rrrrr#0sr#c@seZdZdZddZdS)NodeTypezA metaclass for nodes that handles the field and attribute inheritance. fields and attributes from the parent class are automatically forwarded to the child.cCsdD]t}g}|t|r|dnt|d|||dt|dksPtdt|tt|ksltdt|||<q|ddt ||||S) N)fields attributesrrrz multiple inheritance not allowedzlayout conflictabstractF) extendgetattrobjectgetlenAssertionErrorsettuple setdefaulttype__new__)ZmcsnamebasesdattrZstoragerrrr79s zNodeType.__new__N)r%r&r'r(r7rrrrr)4sr)c@s`eZdZdZd dejeddddZejeej fddd Z ejeej fdd d d Z dS) EvalContextzcHolds evaluation time information. Custom attributes can be attached to it in extensions. Nr) environment template_namereturncCs0||_t|jr|||_n|j|_d|_dSNF)r=callable autoescapevolatile)selfr=r>rrr__init__Js  zEvalContext.__init__r?cCs |jSr)__dict__copyrDrrrsaveTszEvalContext.save)oldr?cCs|j|j|dSr)rGclearupdate)rDrKrrrrevertWs zEvalContext.revert)N) r%r&r'r(tOptionalstrrEMappingAnyrJrNrrrrr<Es r<)nodectxr?cCs(|dkr$|jdkrtdt|jS|S)NzIif no eval context is passed, the node must have an attached environment.)r= RuntimeErrorr<)rTrUrrrget_eval_context\s  rWc@seZdZUdZdZejedfed<dZ ejedfed<dZ e ed<ej d ed <ej ej d d d dZd-ej ejeej ejeejejeej fdddZd.ej ejeej ejeejddddZejeej edddZejejeejejedffejedddZeddddZd/e eddddZd dd d!d"Zej ed#d$d%Ze d&d'd(Zed&d)d*Zed&d+d,Zd S)0raBaseclass 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*linenor=r+TrYrr=N)r*r+r?cOs|jrtd|rt|t|jkrt|js>tt|jdtt|jdt|jdt|jdkrjdndt|j|D]\}}t|||q|jD]}t||| |dq|rtdt t |dS) Nz#abstract nodes are not instantiablez takes 0 argumentsz takes 0 or z argumentrszunknown attribute ) r, TypeErrorr1r*r6r%zipsetattrr+popnextiter)rDr*r+r8argr;rrrrEs0 z Node.__init__)excludeonlyr?c csj|jD]^}|dkr|dks:|dk r*||ks:|dk r||krz|t||fVWqtk rbYqXqdS)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)rDrcrdr8rrr iter_fieldss" zNode.iter_fieldsccsP|||D]>\}}t|tr:|D]}t|tr"|Vq"q t|tr |Vq dS)zIterates 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)rf isinstancelistr)rDrcrd_itemnrrriter_child_nodess     zNode.iter_child_nodes) node_typer?cCs||D] }|SdS)ziFind the first node of a given type. If no such node exists the return value is `None`. N)find_all)rDrmresultrrrfindsz Node.findccs2|D]$}t||r|V||EdHqdS)zFind all the nodes of a given type. If the type is a tuple, the check is performed for any of the tuple items. N)rlrgrn)rDrmchildrrrrns  z Node.find_all)rUr?cCs:t|g}|r6|}d|jkr&||_||q |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. rU)rpopleftr*rUr-rl)rDrUtodorTrrrset_ctxs  z Node.set_ctxF)rYoverrider?cCsHt|g}|rD|}d|jkr4|jdks.|r4||_||q |S)z.Set the line numbers of the node and children.rYN)rrrr+rYr-rl)rDrYrursrTrrr set_linenos  zNode.set_lineno)r=r?cCs0t|g}|r,|}||_||q |S)z"Set the environment for all nodes.)rrrr=r-rl)rDr=rsrTrrrset_environments  zNode.set_environment)otherr?cCs,t|t|k rtSt|t|kSr)r6NotImplementedr4rf)rDrxrrr__eq__sz Node.__eq__rFcCstt|Sr)hashr4rfrIrrr__hash__sz Node.__hash__cs0dfddjD}tjd|dS)N, c3s$|]}|dt|dVqdS)=N)r.).0rrIrr sz Node.__repr__..())joinr*r6r%)rDargs_strrrIr__repr__sz Node.__repr__cs8tjttjfddfdd g|dS)N)rTr?cst|tst|dSdt|jd|jsHddSt|jD]p\}}|rhdt||}t|t rdt|D]\}}|rd|qdqR|qRddS)Nznodes.rrr}[]) rgrappendreprr6r%r* enumerater.rh)rTidxfieldvaluerj_dumpbufrrrs(          zNode.dump.._dumpr[)rOUnionrrSrrIrrrdumps"z Node.dump)NN)NN)F) r%r&r'r(r*rOTuplerQ__annotations__r+r,intrPrSrE ContainerIteratorrfrlTyperrprrnrtboolrvrwrzr|rrrrrrrgs@    "   ) metaclassc@seZdZdZdZdS)StmtzBase node for all statements.TNr%r&r'r(r,rrrrrsrc@seZdZdZdZdS)Helperz,Nodes that exist in a specific context only.TNrrrrrrsrc@s$eZdZUdZdZejeed<dS)TemplatezjNode that represents a template. This must be the outermost node that is passed to the compiler. bodyrN r%r&r'r(r*rOListrrrrrrr%s rc@s$eZdZUdZdZejded<dS)OutputzA node that holds multiple expressions which are then printed out. This is used both for the `print` statement and the regular template data. nodesExprrN)r%r&r'r(r*rOrrrrrrr.s rc@seZdZUdZdZded<dS)Extendsz Represents an extends statement.)templaterrN)r%r&r'r(r*rrrrrr7s rc@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`. )targetrarelse_test recursiverrarrrrN) r%r&r'r(r*rrrOrrPrrrrrr>s rc@sHeZdZUdZdZeed<ejeed<ejded<ejeed<dS)Ifz4If `test` is true, `body` is rendered, else `else_`.)rrelif_rrrrrN) r%r&r'r(r*rrrOrrrrrrPs rc@sHeZdZUdZdZeed<ejded<ejded<eje ed<d S) MacrozA 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. )r8argsdefaultsrr8NamerrrrN) r%r&r'r(r*rQrrOrrrrrrrZs rc@sHeZdZUdZdZded<ejded<ejded<ejeed <d S) CallBlockzLike a macro without a name but a call instead. `call` is called with the unnamed macro as `caller` argument this node holds. )callrrrCallrrrrrrN) r%r&r'r(r*rrOrrrrrrrgs rc@s,eZdZUdZdZejeed<ded<dS) FilterBlockzNode for filter sections.)rfilterrFilterrNrrrrrrss rc@s@eZdZUdZdZejded<ejded<ejeed<dS)WithzSpecific 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 )targetsvaluesrrrrrN) r%r&r'r(r*rOrrrrrrrr{s rc@s<eZdZUdZdZeed<eje ed<e ed<e ed<dS)BlockzkA node that represents a block. .. versionchanged:: 3.0.0 the `required` field was added. )r8rscopedrequiredr8rrrN) r%r&r'r(r*rQrrOrrrrrrrrs rc@s.eZdZUdZdZded<eed<eed<dS)Includez'A node that represents the include tag.)r with_contextignore_missingrrrrN)r%r&r'r(r*rrrrrrrs rc@s.eZdZUdZdZded<eed<eed<dS)Importz&A node that represents the import tag.)rrrrrrrN)r%r&r'r(r*rrQrrrrrrs rc@sHeZdZUdZdZded<ejeje ej e e ffed<e ed<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. )rnamesrrrrrN) r%r&r'r(r*rrOrrrQrrrrrrrs  "rc@seZdZUdZdZeed<dS)ExprStmtzAA statement that evaluates an expression and discards the result.rTrTN)r%r&r'r(r*rrrrrrrs rc@s&eZdZUdZdZded<eed<dS)Assignz"Assigns an expression to a target.)rrTrrrTN)r%r&r'r(r*rrrrrrrs rc@s:eZdZUdZdZded<ejded<eje ed<dS) AssignBlockzAssigns a block to a target.)rrrrrrrrN) r%r&r'r(r*rrOrPrrrrrrrs rc@s<eZdZdZdZd ejeejdddZ e ddd Z dS) rzBaseclass for all expressions.TNeval_ctxr?cCs tdS)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#rDrrrras_consts z Expr.as_constrFcCsdS)z8Check if it's possible to assign something to this node.FrrIrrr can_assignszExpr.can_assign)N) r%r&r'r(r,rOrPr<rSrrrrrrrrs rc@sLeZdZUdZdZeed<eed<eed<dZd e j e e j dd d Z dS) BinExprz%Baseclass for all binary expressions.)leftrightrroperatorTNrcCslt||}|jjr&|j|jjkr&tt|j}z||j||j |WSt k rftYnXdSr) rWr= sandboxedrZintercepted_binopsr#rrrr ExceptionrDrfrrrrs   zBinExpr.as_const)Nr%r&r'r(r*rrrQr,rOrPr<rSrrrrrrs rc@sDeZdZUdZdZeed<eed<dZd e j e e j ddd Z dS) UnaryExprz$Baseclass for all unary expressions.rrTrTNrcCsbt||}|jjr&|j|jjkr&tt|j}z||j|WSt k r\tYnXdSr) rWr=rrZintercepted_unopsr#rrTrrrrrrr s   zUnaryExpr.as_const)Nrrrrrrs rc@s4eZdZUdZdZeed<eed<edddZdS) ra Looks 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. )r8rUr8rUrFcCs |jdkS)N>NonetruefalsenoneFalseTruer8rIrrrr'szName.can_assignN r%r&r'r(r*rQrrrrrrrrs rc@s4eZdZUdZdZeed<eed<edddZdS) NSRefz)Reference to a namespace value assignment)r8r;r8r;rFcCsdS)NTrrIrrrr2szNSRef.can_assignNrrrrrr+s rc@seZdZdZdZdS)LiteralzBaseclass for literals.TNrrrrrr:src@s\eZdZUdZdZejed<d eje ejdddZ e d 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). rrNrcCs|jSrrrrrrrJszConst.as_constzt.Optional[Environment])rrYr=r?cCs(ddlm}||st||||dS)zReturn 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_reprrX)compilerrr#)clsrrYr=rrrrfrom_untrustedMs zConst.from_untrusted)N)NN)r%r&r'r(r*rOrSrrPr<r classmethodrrrrrrr@s  rc@s6eZdZUdZdZeed<deje edddZ dS) TemplateDatazA constant template string.)datarNrcCs,t||}|jrt|jr&t|jS|jSr)rWrCr#rBrrrrrrres   zTemplateData.as_const)N) r%r&r'r(r*rQrrOrPr<rrrrrr_s rc@s^eZdZUdZdZejeed<e ed<d ej e ej ej dfddd Zed d d ZdS)rzFor 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. )itemsrUrrUN.rcs"t|tfdd|jDS)Nc3s|]}|VqdSrrrxrrrrzsz!Tuple.as_const..)rWr4rrrrrrxs zTuple.as_constrFcCs|jD]}|sdSqdS)NFT)rr)rDrjrrrr|s zTuple.can_assign)N)r%r&r'r(r*rOrrrrQrPr<rrSrrrrrrrrns $rc@sDeZdZUdZdZejeed<dej e ejej dddZ dS) rz&Any list literal such as ``[1, 2, 3]``rrNrcst|fdd|jDS)Ncsg|]}|qSrrrrrr sz!List.as_const..)rWrrrrrrs z List.as_const)N) r%r&r'r(r*rOrrrrPr<rSrrrrrrs rc@sJeZdZUdZdZejded<d eje ej ej ej fdddZ dS) DictzeAny dict literal such as ``{1: 2, 3: 4}``. The items must be a list of :class:`Pair` nodes. rPairrNrcs"t|tfdd|jDS)Nc3s|]}|VqdSrrrrrrrsz Dict.as_const..)rWdictrrrrrrs z Dict.as_const)N) r%r&r'r(r*rOrrrPr<rrSrrrrrrs rc@sLeZdZUdZdZeed<eed<d eje ej ej ej fdddZ dS) rzA key, value pair for dicts.keyrrrNrcCs"t||}|j||j|fSr)rWrrrrrrrrs z Pair.as_const)N) r%r&r'r(r*rrrOrPr<rrSrrrrrrs rc@sJeZdZUdZdZeed<eed<d ej e ej eej fdddZ dS) Keywordz>A key, value pair for keyword arguments where key is a string.rrrNrcCst||}|j|j|fSr)rWrrrrrrrrs zKeyword.as_const)N)r%r&r'r(r*rQrrrOrPr<rrSrrrrrrs rc@sNeZdZUdZdZeed<eed<ejeed<d eje ej ddd Z dS) CondExprzZA conditional expression (inline if expression). (``{{ foo if bar else baz }}``) )rexpr1expr2rrrNrcCs>t||}|j|r"|j|S|jdkr2t|j|Sr)rWrrrrr#rrrrrs     zCondExpr.as_const)N) r%r&r'r(r*rrrOrPr<rSrrrrrrs r)_FilterTestCommonr)rTrr?csfdd|jD}tfdd|jD}|jdk rhz||jWntk rftYnX|jdk rz| |jWntk rtYnX||fS)Ncsg|]}|qSrrrrrrrsz!args_as_const..c3s|]}|VqdSrrrrrrrsz args_as_const..) rrkwargsdyn_argsr-rrr# dyn_kwargsrM)rTrrrrrr args_as_consts    rc@s|eZdZUdZeed<eed<ejeed<eje ed<ej eed<ej eed<dZ dZ d ej e ejd d d Zd S)r)rTr8rrrrrTr8rrrrTNrcCst||}|jrt|jr&|jj}n|jj}||j}t |}|dksV|t j kr\t|jj rt |dddks~t|rtt||\}}|d|j||t jkr|d|n|t jkr|d|jz |||WStk rtYnXdS)NZjinja_async_variantFTr)rWrCr# _is_filterr=filterstestsr0r8rZfrom_objcontextZis_asyncr.inspectiscoroutinefunctionrinsertrTrZ eval_contextr)rDrZenv_mapfuncZpass_argrrrrrrs4       z_FilterTestCommon.as_const)N)r%r&r'r*rrrQrOrrrPr,rr<rSrrrrrrs rcsBeZdZUdZejeed<dejeej dfdd Z Z S)rzApply 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. rTNrcs|jdkrttj|dS)Nr)rTr#superrr __class__rrrs zFilter.as_const)N) r%r&r'r(rOrPrrr<rSr __classcell__rrr rrs rc@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)r%r&r'r(rrrrrr #s r c@sVeZdZUdZdZeed<ejeed<eje ed<ej eed<ej eed<dS) ra/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. )rTrrrrrTrrrrN) r%r&r'r(r*rrrOrrrPrrrrr0s rc@sHeZdZUdZdZeed<eed<eed<d ej e ej ddd Z dS) Getitemz@Get an attribute or item from an expression and prefer the item.)rTrbrUrTrbrUNrcCsZ|jdkrtt||}z |j|j||j|WStk rTtYnXdSNload) rUr#rWr=getitemrTrrbrrrrrrHs   zGetitem.as_const)N r%r&r'r(r*rrrQrOrPr<rSrrrrrr@s rc@sHeZdZUdZdZeed<eed<eed<d ej e ej ddd Z dS) GetattrznGet an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute. )rTr;rUrTr;rUNrcCsT|jdkrtt||}z|j|j||jWStk rNtYnXdSr) rUr#rWr=r.rTrr;rrrrrr`s  zGetattr.as_const)NrrrrrrVs rc@sXeZdZUdZdZejeed<ejeed<ejeed<d eje e ddd Z dS) Slicez_Represents a slice object. This must only be used as argument for :class:`Subscript`. )startstopsteprrrNrcsJt|tjttjtjdfdd }t||j||j||jS)N)objr?cs|dkr dS|Srr)rrrrconstyszSlice.as_const..const) rWrOrPrrSslicerrr)rDrrrrrrvs "zSlice.as_const)N) r%r&r'r(r*rOrPrrr<rrrrrrrls rc@s<eZdZUdZdZejeed<dej e e dddZ dS) ConcatzXConcatenates the list of expressions provided after converting them to strings. rrNrcs$t|dfdd|jDS)Nr[c3s|]}t|VqdSr)rQrrrrrrsz"Concat.as_const..)rWrrrrrrrs zConcat.as_const)N) r%r&r'r(r*rOrrrrPr<rQrrrrrrs rc@sFeZdZUdZdZeed<ejded<d ej e ej ddd Z dS) CompareziCompares an expression with some other expressions. `ops` must be a list of :class:`Operand`\s. )expropsrOperandrNrcCsvt||}|j|}}z<|jD]0}|j|}t|j||}|sNWdS|}q"Wntk rptYnX|Sr@)rWrrrr"oprr#)rDrrorr  new_valuerrrrs     zCompare.as_const)N) r%r&r'r(r*rrrOrrPr<rSrrrrrrs rc@s&eZdZUdZdZeed<eed<dS)rz$Holds an operator and an expression.)r rr rN)r%r&r'r(r*rQrrrrrrrs rc@seZdZdZdZdS)Mulz(Multiplies the left with the right node.r Nr%r&r'r(rrrrrr"sr"c@seZdZdZdZdS)Divz#Divides the left by the right node.r Nr#rrrrr$sr$c@seZdZdZdZdS)FloorDivzjDivides the left by the right node and truncates conver the result into an integer by truncating. r Nr#rrrrr%sr%c@seZdZdZdZdS)AddzAdd the left to the right node.rNr#rrrrr&sr&c@seZdZdZdZdS)Subz&Subtract the right from the left node.rNr#rrrrr'sr'c@seZdZdZdZdS)ModzLeft modulo right.rNr#rrrrr(sr(c@seZdZdZdZdS)PowzLeft to the power of right.r Nr#rrrrr)sr)c@s.eZdZdZdZdejeejdddZ dS)AndzShort circuited AND.andNrcCs"t||}|j|o |j|SrrWrrrrrrrrs z And.as_const)N r%r&r'r(rrOrPr<rSrrrrrr*sr*c@s.eZdZdZdZdejeejdddZ dS)OrzShort circuited OR.orNrcCs"t||}|j|p |j|Srr,rrrrrs z Or.as_const)Nr-rrrrr.sr.c@seZdZdZdZdS)NotzNegate the expression.rNr#rrrrr0sr0c@seZdZdZdZdS)NegzMake the expression negative.rNr#rrrrr1sr1c@seZdZdZdZdS)Posz8Make the expression positive (noop for most expressions)rNr#rrrrr2sr2c@seZdZUdZdZeed<dS)EnvironmentAttributezLoads an attribute from the environment object. This is useful for extensions that want to call a callback stored on the environment. rr8Nr%r&r'r(r*rQrrrrrr3s r3c@s&eZdZUdZdZeed<eed<dS)ExtensionAttributezReturns 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. ) identifierr8r6r8Nr4rrrrr5s r5c@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. ) importnamer8Nr4rrrrr7s r7c@s,eZdZUdZdZeed<ddddZdS) 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. rr8NrFcCs tddS)NzKCan't create internal names. Use the `free_identifier` method on a parser.r\rIrrrrE3szInternalName.__init__)r%r&r'r(r*rQrrErrrrr9(s r9c@s6eZdZUdZdZeed<deje e dddZ dS) MarkSafez:Mark the wrapped expression as safe (wrap it as `Markup`).rrNrcCst||}t|j|Sr)rWrrrrrrrr@s zMarkSafe.as_const)N) r%r&r'r(r*rrrOrPr<rrrrrrr;:s r;c@sBeZdZUdZdZeed<deje ej e ej fdddZ dS) MarkSafeIfAutoescapezMark the wrapped expression as safe (wrap it as `Markup`) but only if autoescaping is active. .. versionadded:: 2.5 r<rNrcCs4t||}|jrt|j|}|jr0t|S|Sr)rWrCr#rrrBr)rDrrrrrrOs  zMarkSafeIfAutoescape.as_const)N)r%r&r'r(r*rrrOrPr<rrrSrrrrrr=Es r=c@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. Nr$rrrrr>[sr>c@seZdZdZdS)DerivedContextReferencezReturn the current template context including locals. Behaves exactly like :class:`ContextReference`, but includes local variables, such as from a ``for`` loop. .. versionadded:: 2.11 Nr$rrrrr?msr?c@seZdZdZdS)ContinuezContinue a loop.Nr$rrrrr@vsr@c@seZdZdZdS)Breakz Break a loop.Nr$rrrrrAzsrAc@s$eZdZUdZdZejeed<dS)ScopezAn artificial scope.rrNrrrrrrB~s rBc@s,eZdZUdZdZeed<eje ed<dS) OverlayScopeaAn 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 )rrrrN) r%r&r'r(r*rrrOrrrrrrrCs  rCc@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))]) )optionsrEN) r%r&r'r(r*rOrrrrrrrrDs rDc@s$eZdZUdZdZejeed<dS)ScopedEvalContextModifierzModifies 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`. rrNrrrrrrFs rFz te.NoReturn)rrr?cOs tddS)Nzcan't create custom node typesr:)rrrrr _failing_newsrG)zr(rrtypingrO collectionsrZ markupsaferutilsr TYPE_CHECKINGZtyping_extensionster=rTypeVarrmultruedivfloordivpowmodaddsubrrrQCallablerSrnot_posnegrrrrgerler"rr#r6r)r<rPrWrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrr"r$r%r&r'r(r)r*r.r0r1r2r3r5r7r9r;r=r>r?r@rArBrCrDrFrG staticmethodr7rrrrs    , (,  3           " 0