o g9 @sbUdZddlZddlZddlZzddlmZWney&ddlmZYnwddl m Z ddl m Z ej r@ddlZddlmZejdd d Zejejejejejejejd Zejeejejejgejffe d <ej!ej"ej#d Z$ejeejejgejffe d<ej%ej&ej'ej(ej)ej*dddddZ+ejeejejejgejffe d<Gddde,Z-Gddde.Z/GdddZ0dd dej1e0de0fddZ2Gdd d e/d Z3Gd!d"d"e3Z4Gd#d$d$e3Z5Gd%d&d&e3Z6Gd'd(d(e4Z7Gd)d*d*e4Z8Gd+d,d,e4Z9Gd-d.d.e4Z:Gd/d0d0e4Z;Gd1d2d2e4ZGd7d8d8e4Z?Gd9d:d:e4Z@Gd;d<dd>e4ZBGd?d@d@e4ZCGdAdBdBe4ZDGdCdDdDe4ZEGdEdFdFe3ZFGdGdHdHeFZGGdIdJdJeFZHGdKdLdLeFZIGdMdNdNeFZJGdOdPdPeFZKGdQdRdReKZLGdSdTdTeKZMGdUdVdVeKZNGdWdXdXeKZOGdYdZdZeKZGd[d\d\e5ZPGd]d^d^e5ZQGd_d`d`eFZRdejSdadbej1e0dejNejOejejejejfffdcddZTGdedfdfeFZUGdgdhdheUZVGdidjdjeUZWGdkdldleFZXGdmdndneFZYGdodpdpeFZZGdqdrdreFZ[GdsdtdteFZ\GdudvdveFZ]Gdwdxdxe5Z^GdydzdzeGZ_Gd{d|d|eGZ`Gd}d~d~eGZaGdddeGZbGdddeGZcGdddeGZdGdddeGZeGdddeGZfGdddeGZgGdddeHZhGdddeHZiGdddeHZjGdddeFZkGdddeFZlGdddeFZmGdddeFZnGdddeFZoGdddeFZpGdddeFZqGdddeFZrGddde4ZsGddde4ZtGddde4ZuGddde4ZvGddde4ZwGdddewZxdejdejddfddZyezeye/_{[ydS)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||vSNabrr./usr/lib/python3/dist-packages/jinja2/nodes.py.rcCs||vSrrrrrrr/r)eqnegtgteqltlteqinnotin_cmpop_to_funcc@eZdZdZdS) Impossiblez8Raised if the node could not perform a requested action.N__name__ __module__ __qualname____doc__rrrrr&3r&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]:}g}|t|r|dnt|d|||dt|dks(Jdt|tt|ks6Jdt|||<q|ddt ||||S) N)fields attributesrrrz multiple inheritance not allowedzlayout conflictabstractF) extendgetattrobjectgetlensettuple setdefaulttype__new__)mcsnamebasesdattrstoragerrrr:<s zNodeType.__new__N)r(r)r*r+r:rrrrr-7s r-c@sheZdZdZ ddddejeddfddZdejeej ffd d Z d ejeej fddfd d Z dS) EvalContextzcHolds evaluation time information. Custom attributes can be attached to it in extensions. N environmentr template_namereturncCs0||_t|jr|||_n|j|_d|_dSNF)rBcallable autoescapevolatile)selfrBrCrrr__init__Ms   zEvalContext.__init__cCs |jSr)__dict__copyrIrrrsaveW zEvalContext.saveoldcCs|j|j|dSr)rKclearupdate)rIrPrrrrevertZ zEvalContext.revertr) r(r)r*r+tOptionalstrrJMappingAnyrNrSrrrrrAHs  "rAnodectxrDcCs(|dur|jdur tdt|jS|S)NzIif no eval context is passed, the node must have an attached environment.)rB RuntimeErrorrA)rZr[rrrget_eval_context_s  r]c @seZdZUdZdZejedfed<dZ ejedfed<dZ e ed<ej d ed <dej dej d d fd dZ d*dej ejedej ejed ejejeej ffddZ d*dej ejedej ejed ejdfddZdejed ej efddZdejejeejejedffd ejefddZded dfddZd+de ded dfdd Zd,d!d"Zd#ej d efd$d%ZejZd efd&d'Zd efd(d)Z d S)-raBaseclass 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.linenorBr/Tr_rrBrDNcOs|jrtd|rNt|t|jkr=|jstt|jdtt|jdt|jdt|jdkr8ddt|j|D] \}}t|||qC|jD] }t||| |dqQ|rktdt t |dS) Nz#abstract nodes are not instantiablez takes 0 argumentsz takes 0 or z argumentrszunknown attribute ) r0 TypeErrorr5r.r9r(zipsetattrr/popnextiter)rIr.r/r<argr?rrrrJs* z Node.__init__excludeonlyc csj|jD].}|dur|dus|dur||vs|dur2||vr2z |t||fVWqty1YqwqdS)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.r2AttributeError)rIrirjr<rrr iter_fieldss  zNode.iter_fieldsccsR|||D]\}}t|tr|D] }t|tr|Vqqt|tr&|VqdS)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)rl isinstancelistr)rIrirj_itemnrrriter_child_nodess   zNode.iter_child_nodes node_typecCs||D]}|SdS)ziFind the first node of a given type. If no such node exists the return value is `None`. N)find_all)rIrsresultrrrfindsz Node.findccs4|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)rrrmrt)rIrschildrrrrts   z Node.find_allr[cCs<t|g}|r|}d|jvr||_|||s|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. r[)rpopleftr.r[r1rr)rIr[todorZrrrset_ctxs  z Node.set_ctxFoverridecCsJt|g}|r#|}d|jvr|jdus|r||_|||s|S)z.Set the line numbers of the node and children.r_N)rrxr/r_r1rr)rIr_r{ryrZrrr set_linenos  zNode.set_linenocCs2t|g}|r|}||_|||s|S)z"Set the environment for all nodes.)rrxrBr1rr)rIrBryrZrrrset_environments zNode.set_environmentothercCs,t|t|ur tSt|t|kSr)r9NotImplementedr7rl)rIr~rrr__eq__sz Node.__eq__cs0dfddjD}tjd|dS)N, c3s&|]}|dt|dVqdS)=N)r2).0rrMrr s$z Node.__repr__..())joinr.r9r()rIargs_strrrMr__repr__sz Node.__repr__cs:dtjttjfddffdd g|dS)NrZrDcst|tst|dSdt|jd|js$ddSt|jD]8\}}|r4dt||}t|t r]dt|D]\}}|rRd|qGdq)|q)ddS)Nznodes.rrr[]) rmrappendreprr9r(r. enumerater2rn)rZidxfieldvaluerp_dumpbufrrrs(          zNode.dump.._dumpra)rUUnionrrYrrMrrrdumps$ z Node.dumpNN)F)rBrrDr)!r(r)r*r+r.rUTuplerW__annotations__r/r0intrVrYrJ ContainerIteratorrlrrTyperrvrrtrzboolr|r}rr3__hash__rrrrrrrjsN    "    ) metaclassc@eZdZdZdZdS)StmtzBase node for all statements.TNr(r)r*r+r0rrrrrrc@r)Helperz,Nodes that exist in a specific context only.TNrrrrrr!rrc@$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.rUListrrrrrrr' 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.rUrrrrrrr0rrc@seZdZUdZdZded<dS)Extendsz Represents an extends statement.)templaterrN)r(r)r*r+r.rrrrrr9  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`. )targetrgrelse_test recursiverrgrrrrN) r(r)r*r+r.rrrUrrVrrrrrr@s  rc@sHeZdZUdZdZeed<ejeed<ejded<ejeed<dS)Ifz4If `test` is true, `body` is rendered, else `else_`.)rrelif_rrrrrN) r(r)r*r+r.rrrUrrrrrrRs 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. )r<argsdefaultsrr<NamerrrrN) r(r)r*r+r.rWrrUrrrrrrr\s 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.rrUrrrrrrris rc@s,eZdZUdZdZejeed<ded<dS) FilterBlockzNode for filter sections.)rfilterrFilterrNrrrrrrus  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.rUrrrrrrrr}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. )r<rscopedrequiredr<rrrN) r(r)r*r+r.rWrrUrrrrrrrrs  rc@s.eZdZUdZdZded<eed<eed<dS)Includez'A node that represents the include tag.)r with_contextignore_missingrrrrN)r(r)r*r+r.rrrrrrr  rc@s.eZdZUdZdZded<eed<eed<dS)Importz&A node that represents the import tag.)rrrrrrrN)r(r)r*r+r.rrWrrrrrrrrc@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.rrUrrrWrrrrrrrs  " rc@eZdZUdZdZeed<dS)ExprStmtzAA statement that evaluates an expression and discards the result.rZrZN)r(r)r*r+r.rrrrrrrrrc@s&eZdZUdZdZded<eed<dS)Assignz"Assigns an expression to a target.)rrZrrrZN)r(r)r*r+r.rrrrrrr  rc@s:eZdZUdZdZded<ejded<eje ed<dS) AssignBlockzAssigns a block to a target.)rrrrrrrrN) r(r)r*r+r.rrUrVrrrrrrrs rc@s>eZdZdZdZd dejedejfddZ de fdd Z dS) rzBaseclass for all expressions.TNeval_ctxrDcCst)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. )r&rIrrrras_consts z Expr.as_constcCdS)z8Check if it's possible to assign something to this node.FrrMrrr can_assignszExpr.can_assignr) r(r)r*r+r0rUrVrArYrrrrrrrrs  rc@sNeZdZUdZdZeed<eed<eed<dZd de j e d e j fd d Z dS) BinExprz%Baseclass for all binary expressions.)leftrightrroperatorTNrrDc Csnt||}|jjr|j|jjvrtt|j}z||j||j |WSt y6}zt|d}~wwr) r]rB sandboxedrintercepted_binopsr&rrrr ExceptionrIrferrrrs  zBinExpr.as_constrr(r)r*r+r.rrrWr0rUrVrArYrrrrrrs  rc@sFeZdZUdZdZeed<eed<dZd de j e de j fd d Z dS) UnaryExprz$Baseclass for all unary expressions.rrZrTNrrDc Csdt||}|jjr|j|jjvrtt|j}z ||j|WSt y1}zt|d}~wwr) r]rBrrintercepted_unopsr&rrZrrrrrrr s  zUnaryExpr.as_constrrrrrrrs  rc@4eZdZUdZdZeed<eed<defddZdS) 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. )r<r[r<r[rDcCs |jdvS)N>NoneTruenonetrueFalsefalser<rMrrrr)rOzName.can_assignN r(r)r*r+r.rWrrrrrrrrs rc@r) NSRefz)Reference to a namespace value assignment)r<r?r<r?rDcCr)NTrrMrrrr4szNSRef.can_assignNrrrrrr-s rc@r)LiteralzBaseclass for literals.TNrrrrrr<rrc @sheZdZUdZdZejed<ddeje dejfddZ e  ddejd eje d d ddfd 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). rrNrrDcCs|jSrrrrrrrLszConst.as_constr_rBzt.Optional[Environment]cCs(ddlm}||s t||||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_reprr^)compilerrr&)clsrr_rBrrrrfrom_untrustedOs zConst.from_untrustedrr)r(r)r*r+r.rUrYrrVrAr classmethodrrrrrrrBs"  rc@s8eZdZUdZdZeed<d deje defddZ dS) TemplateDatazA constant template string.)datarNrrDcCs,t||}|jr t|jrt|jS|jSr)r]rHr&rGrrrrrrrgs  zTemplateData.as_constr) r(r)r*r+r.rWrrUrVrArrrrrra rc@s`eZdZUdZdZejeed<e ed<d dej e dej ej dffd d Zdefd 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. )itemsr[rr[NrrD.c"t|tfdd|jDS)Nc3|]}|VqdSrrrxrrrr|z!Tuple.as_const..)r]r7rrrrrrz zTuple.as_constcCs|jD] }|s dSqdS)NFT)rr)rIrprrrr~s zTuple.can_assignr)r(r)r*r+r.rUrrrrWrVrArrYrrrrrrrrps &rc@sFeZdZUdZdZejeed<d dej e dejej fddZ dS) rz&Any list literal such as ``[1, 2, 3]``rrNrrDcst|fdd|jDS)Ncg|]}|qSrrrrrr z!List.as_const..)r]rrrrrrs z List.as_constr) r(r)r*r+r.rUrrrrVrArYrrrrrrs &rc@sNeZdZUdZdZejded< d deje dej ej ej ffdd Z dS) DictzeAny dict literal such as ``{1: 2, 3: 4}``. The items must be a list of :class:`Pair` nodes. rPairrNrrDcr)Nc3rrrrrrrrrz Dict.as_const..)r]dictrrrrrr z Dict.as_constr) r(r)r*r+r.rUrrrVrAr rYrrrrrr s r c@sPeZdZUdZdZeed<eed< d deje dej ej ej ffdd Z dS) r zA key, value pair for dicts.keyrrrNrrDcCs"t||}|j||j|fSr)r]rrrrrrrrrz Pair.as_constr) r(r)r*r+r.rrrUrVrArrYrrrrrr s r c@sLeZdZUdZdZeed<eed<d dej e dej eej ffdd Z dS) Keywordz>A key, value pair for keyword arguments where key is a string.rrrNrrDcCst||}|j|j|fSr)r]rrrrrrrrs zKeyword.as_constr)r(r)r*r+r.rWrrrUrVrArrYrrrrrrs *rc@sPeZdZUdZdZeed<eed<ejeed<d deje dej fd d Z dS) CondExprzZA conditional expression (inline if expression). (``{{ foo if bar else baz }}``) )rexpr1expr2rrrNrrDcCs>t||}|j|r|j|S|jdurt|j|Sr)r]rrrrr&rrrrrs     zCondExpr.as_constr) r(r)r*r+r.rrrUrVrArYrrrrrrs  r)_FilterTestCommonrrc sfdd|jD}tfdd|jD}|jdur7z ||jWnty6}zt|d}~ww|jdur[z| |jW||fStyZ}zt|d}~ww||fS)Ncr rrrrrrr r z!args_as_const..c3rrrrrrrrrz args_as_const..) rrkwargsdyn_argsr1rrr& dyn_kwargsrR)rZrrrrrrr args_as_consts$  rc@s~eZdZUdZeed<eed<ejeed<eje ed<ej eed<ej eed<dZ dZ dd ej e d ejfd d Zd S)r)rZr<rrrrrZr<rrrrTNrrDc Cst||}|jr t|jr|jj}n|jj}||j}t |}|dus+|t j ur.t|jj rBt |dddus?t|rBtt||\}}|d|j||t jur_|d|n |t jurk|d|jz||i|WSty}zt|d}~ww)Njinja_async_variantFTr)r]rHr& _is_filterrBfilterstestsr4r<rfrom_objcontextis_asyncr2inspectiscoroutinefunctionrinsertrZr eval_contextr)rIrenv_mapfuncpass_argrrrrrrrs6      z_FilterTestCommon.as_constr)r(r)r*r.rrrWrUrr rVr0rrArYrrrrrrs  rcsDeZdZUdZejeed<ddejedej ffdd 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. rZNrrDcs|jdurttj|dS)Nr)rZr&superrr __class__rrrs zFilter.as_constr) r(r)r*r+rUrVrrrArYr __classcell__rrr*rrs (rc@r)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. )rZrrrrrZrrrrN) r(r)r*r+r.rrrUrrrVrrrrr2s rc@sJeZdZUdZdZeed<eed<eed<d dej e dej fd d Z dS) Getitemz@Get an attribute or item from an expression and prefer the item.)rZrhr[rZrhr[NrrDc Cs\|jdkrtt||}z|j|j||j|WSty-}zt|d}~wwNload) r[r&r]rBgetitemrZrrhrrIrrrrrrJs  zGetitem.as_constr r(r)r*r+r.rrrWrUrVrArYrrrrrr.Bs  r.c@sJeZdZUdZdZeed<eed<eed<d dej e dej fd d Z dS) GetattrznGet an attribute or item from an expression that is a ascii-only bytestring and prefer the attribute. )rZr?r[rZr?r[NrrDc CsV|jdkrtt||}z |j|j||jWSty*}zt|d}~wwr/) r[r&r]rBr2rZrr?rr2rrrrbs  zGetattr.as_constrr3rrrrr4Xs  r4c@sZeZdZUdZdZejeed<ejeed<ejeed<d deje de fd d Z dS) Slicez_Represents a slice object. This must only be used as argument for :class:`Subscript`. )startstopstepr6r7r8NrrDcsLt|dtjtdtjtjffdd }t||j||j||jS)NobjrDcs|durdS|Srr)r9rrrconst{s zSlice.as_const..const) r]rUrVrrYslicer6r7r8)rIrr:rrrrxs $zSlice.as_constr) r(r)r*r+r.rUrVrrrAr;rrrrrr5ns r5c@s>eZdZUdZdZejeed<d dej e de fddZ dS) ConcatzXConcatenates the list of expressions provided after converting them to strings. rrNrrDcs$t|dfdd|jDS)Nrac3s|] }t|VqdSr)rWrrrrrrsz"Concat.as_const..)r]rrrrrrrs zConcat.as_constr) r(r)r*r+r.rUrrrrVrArWrrrrrr<s r<c@sHeZdZUdZdZeed<ejded<d dej e dej fd d Z dS) CompareziCompares an expression with some other expressions. `ops` must be a list of :class:`Operand`\s. )expropsr>Operandr?NrrDc Cszt||}|j|}}z|jD]}|j|}t|j||}|s'WdS|}qW|Sty<}zt|d}~wwrE)r]r>rr?r$oprr&)rIrrurrA new_valuerrrrrs    zCompare.as_constr) r(r)r*r+r.rrrUrrVrArYrrrrrr=s  r=c@s&eZdZUdZdZeed<eed<dS)r@z$Holds an operator and an expression.)rAr>rAr>N)r(r)r*r+r.rWrrrrrrr@rr@c@r)Mulz(Multiplies the left with the right node.r Nr(r)r*r+rrrrrrCrrCc@r)Divz#Divides the left by the right node.r NrDrrrrrErrEc@r)FloorDivzbDivides the left by the right node and converts the result into an integer by truncating. r NrDrrrrrFsrFc@r)AddzAdd the left to the right node.rNrDrrrrrGrrGc@r)Subz&Subtract the right from the left node.rNrDrrrrrHrrHc@r)ModzLeft modulo right.rNrDrrrrrIrrIc@r)PowzLeft to the power of right.r NrDrrrrrJrrJc@0eZdZdZdZddejedejfddZ dS) AndzShort circuited AND.andNrrDcCs"t||}|j|o|j|Srr]rrrrrrrrrz And.as_constr r(r)r*r+rrUrVrArYrrrrrrL rLc@rK) OrzShort circuited OR.orNrrDcCs"t||}|j|p|j|SrrNrrrrrrz Or.as_constrrOrrrrrQrPrQc@r)NotzNegate the expression.rNrDrrrrrSrrSc@r)NegzMake the expression negative.rNrDrrrrrTrrTc@r)Posz8Make the expression positive (noop for most expressions)rNrDrrrrrUrrUc@r)EnvironmentAttributezLoads an attribute from the environment object. This is useful for extensions that want to call a callback stored on the environment. rr<Nr(r)r*r+r.rWrrrrrrV s  rVc@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. ) identifierr<rYr<NrWrrrrrXs  rXc@r) 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. ) importnamer[NrWrrrrrZs  rZc@s(eZdZUdZdZeed<dddZdS) 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. rr<rDNcCtd)NzKCan't create internal names. Use the `free_identifier` method on a parser.rbrMrrrrJ5szInternalName.__init__)rDN)r(r)r*r+r.rWrrJrrrrr\*s r\c@s8eZdZUdZdZeed<d deje de fddZ dS) MarkSafez:Mark the wrapped expression as safe (wrap it as `Markup`).r>r>NrrDcCst||}t|j|Sr)r]rr>rrrrrrBrTzMarkSafe.as_constr) r(r)r*r+r.rrrUrVrArrrrrrr_<rr_c@sFeZdZUdZdZeed< d deje dej e ej ffddZ dS) MarkSafeIfAutoescapezMark the wrapped expression as safe (wrap it as `Markup`) but only if autoescaping is active. .. versionadded:: 2.5 r`r>NrrDcCs4t||}|jr t|j|}|jrt|S|Sr)r]rHr&r>rrGr)rIrr>rrrrQs  zMarkSafeIfAutoescape.as_constr)r(r)r*r+r.rrrUrVrArrrYrrrrrraGs rac@r%)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'rrrrrb]r,rbc@r%)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'rrrrrcor,rcc@r%)ContinuezContinue a loop.Nr'rrrrrdxr,rdc@r%)Breakz Break a loop.Nr'rrrrre|r,rec@r)ScopezAn artificial scope.rrNrrrrrrfs rfc@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 )r rr rN) r(r)r*r+r.rrrUrrrrrrrgs  rgc@r)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))]) )optionsriN) r(r)r*r+r.rUrrrrrrrrhs rhc@r)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`. rrNrrrrrrjs rjrrz te.NoReturncOr])Nzcan't create custom node typesr^)rrrrr _failing_newsrk)|r+r"rtypingrUcollections.abcr ImportError collections markupsaferutilsr TYPE_CHECKINGtyping_extensionsterBrTypeVarrmultruedivfloordivpowmodaddsubrr rWCallablerYrnot_posnegrrrrger ler$rr&r9r-rArVr]rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrr-rr.r4r5r<r=r@rCrErFrGrHrIrJrLrQrSrTrUrVrXrZr\r_rarbrcrdrerfrgrhrjrk staticmethodr:rrrrs    , (,  2           " 0