1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
U
Þ=®dö†ã    @s2UdZddlZddlZddlZddlmZddlmZddl    m
Z
ej r\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)Úbound)Ú*ú/ú//ú**ú%ú+ú-Ú_binop_to_func)ÚnotrrÚ _uaop_to_funccCs||kS©N©©ÚaÚbrrúCd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\jinja2/nodes.pyÚ<lambda>+órcCs||kSrrrrrrr,r)ÚeqÚneÚgtZgteqÚltZlteqÚinÚnotinÚ_cmpop_to_funcc@seZdZdZdS)Ú
Impossiblez8Raised if the node could not perform a requested action.N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrr#0sr#c@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–dD]t}g}| t|r|dnt|dƒ¡| | |d¡¡t|ƒdksPtdƒ‚t|ƒtt|ƒƒksltdƒ‚t|ƒ||<q| 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ÚattrZstoragerrrr79s zNodeType.__new__N)r%r&r'r(r7rrrrr)4sr)c@s`eZdZdZd dejeddœdd„Zejeej    fdœdd    „Z
ejeej    fdd
œd d „Z dS)Ú 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)r=ÚcallableÚ
autoescapeÚvolatile)Úselfr=r>rrrÚ__init__Js
 
zEvalContext.__init__©r?cCs
|j ¡Sr)Ú__dict__Úcopy©rDrrrÚsaveTszEvalContext.save)Úoldr?cCs|j ¡|j |¡dSr)rGÚclearÚupdate)rDrKrrrÚrevertWs
zEvalContext.revert)N) r%r&r'r(ÚtÚOptionalÚstrrEÚMappingÚAnyrJrNrrrrr<Esÿþ
r<)ÚnodeÚctxr?cCs(|dkr$|jdkrtdƒ‚t|jƒS|S)NzIif no eval context is passed, the node must have an attached environment.)r=Ú RuntimeErrorr<)rTrUrrrÚget_eval_context\s
ÿ
rWc@s˜eZdZUdZdZejedfed<dZ    ejedfed<dZ
e ed<ej d    ed
<ej ej d d œd d„Zd+ej ejeej ejeejejeej fdœdd„Zd,ej ejeej ejeejddœdd„Zejeej edœdd„Zejejeejejedffejedœdd„Zeddœdd„Zd-e eddœdd„Zd    dd œd!d"„Zej ed#œd$d%„ZejZed&œd'd(„Zed&œd)d*„Z d S).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*©Úlinenor=r+TrYrr=N)r*r+r?cOsÔ|jrtdƒ‚|r–t|ƒt|jƒkrt|js>tt|ƒj›dƒ‚tt|ƒj›dt|jƒ›dt|jƒdkrjdnd›ƒ‚t|j|ƒD]\}}t|||ƒq€|jD]}t|||     |d¡ƒqœ|rÐtdt
t |ƒƒ›ƒ‚dS)    Nz#abstract nodes are not instantiablez takes 0 argumentsz  takes 0 or z     argumentrÚsÚzunknown attribute ) r,Ú    TypeErrorr1r*r6r%ÚzipÚsetattrr+ÚpopÚnextÚiter)rDr*r+r8Úargr;rrrrEs0ÿ
z Node.__init__)ÚexcludeÚonlyr?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_fields‘s"
ÿÿþþýýzNode.iter_fieldsccsP| ||¡D]>\}}t|tƒr:|D]}t|tƒr"|Vq"q t|tƒr |Vq dS)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)rfÚ
isinstanceÚlistr)rDrcrdÚ_ÚitemÚnrrrÚiter_child_nodes§s    
 
 
 
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)rDrmÚresultrrrÚfind¸sz    Node.findccs2| ¡D]$}t||ƒr|V| |¡EdHqdS)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)rlrgrn)rDrmÚchildrrrrnÁs 
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)rÚpopleftr*rUr-rl)rDrUÚtodorTrrrÚset_ctxÌs
 
z Node.set_ctxF)rYÚoverrider?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_linenoÚs
 
zNode.set_lineno)r=r?cCs0t|gƒ}|r,| ¡}||_| | ¡¡q
|S)z"Set the environment for all nodes.)rrrr=r-rl)rDr=rsrTrrrÚset_environmentås 
zNode.set_environment)Úotherr?cCs,t|ƒt|ƒk    rtSt| ¡ƒt| ¡ƒkSr)r6ÚNotImplementedr4rf)rDrxrrrÚ__eq__îsz Node.__eq__rFcs0d ‡fdd„ˆjDƒ¡}tˆƒj›d|›dS)Nú, c3s$|]}|›dtˆ|dƒ›VqdS)ú=N)r.)Ú.0rrIrrÚ    <genexpr>÷sz Node.__repr__.<locals>.<genexpr>ú(ú))Újoinr*r6r%)rDÚargs_strrrIrÚ__repr__ösz Node.__repr__cs8tjttjfddœ‡‡fdd„ ‰g‰ˆ|ƒd ˆ¡S)N)rTr?csÒt|tƒsˆ t|ƒ¡dSˆ dt|ƒj›d¡|jsHˆ d¡dSt|jƒD]p\}}|rhˆ d¡t||ƒ}t|t    ƒrºˆ d¡t|ƒD]\}}|r¤ˆ d¡ˆ|ƒqŽˆ d¡qRˆ|ƒqRˆ d¡dS)Nznodes.rr€r{ú[ú])
rgrÚappendÚreprr6r%r*Ú    enumerater.rh)rTÚidxÚfieldÚvaluerj©Ú_dumpÚbufrrrûs(
 
 
 
 
 
 
 
 
zNode.dump.<locals>._dumpr[)rOÚUnionrrSrrIrrŒrÚdumpús"z    Node.dump)NN)NN)F)!r%r&r'r(r*rOÚTuplerQÚ__annotations__r+r,ÚintrPrSrEÚ    ContainerÚIteratorrfrlÚTyperrprrnrtÚboolrvrwrzr/Ú__hash__rƒrrrrrrgs@
ýü ýü 
"þ      )Ú    metaclassc@seZdZdZdZdS)ÚStmtzBase node for all statements.TN©r%r&r'r(r,rrrrršsršc@seZdZdZdZdS)ÚHelperz,Nodes that exist in a specific context only.TNr›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©    r%r&r'r(r*rOÚ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)r%r&r'r(r*rOr¡r’rrrrr¢-s
r¢c@seZdZUdZdZded<dS)ÚExtendsz Represents an extends statement.)Útemplater¥r§N)r%r&r'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`.
    )ÚtargetrarŸÚelse_ÚtestÚ    recursiver©rarŸrªr«r¬N) r%r&r'r(r*rr’rOr¡rPr—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)    r%r&r'r(r*rr’rOr¡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.
    )r8ÚargsÚdefaultsrŸr8ÚNamer°r¥r±rŸN)
r%r&r'r(r*rQr’rOr¡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)    r%r&r'r(r*r’rOr¡rrrrrr³fs
r³c@s,eZdZUdZdZejeed<ded<dS)Ú FilterBlockzNode for filter sections.)rŸÚfilterrŸÚFilterr·Nr 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)    r%r&r'r(r*rOr¡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.
    )r8rŸÚscopedÚrequiredr8rŸr½r¾N) r%r&r'r(r*rQr’rOr¡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)r%r&r'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)r%r&r'r(r*r’rQr—rrrrržs
 
rÂc@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.
    )r§ÚnamesrÀr¥r§rÄrÀN) r%r&r'r(r*r’rOr¡rrQr‘r—rrrrrçs
 
 "rÃc@seZdZUdZdZeed<dS)ÚExprStmtzAA statement that evaluates an expression and discards the result.©rTrTN)r%r&r'r(r*rr’rrrrrŹs
rÅc@s&eZdZUdZdZded<eed<dS)ÚAssignz"Assigns an expression to a target.)r©rTr¥r©rTN)r%r&r'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)
r%r&r'r(r*r’rOrPr¡rrrrrrÈÈs
 
rÈc@s<eZdZdZdZd
ejeejdœdd„Z    e
dœdd    „Z dS) r¥zBaseclass for all expressions.TN©Úeval_ctxr?cCs
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#©rDrÊrrrÚas_constÖs z Expr.as_constrFcCsdS)z8Check if it's possible to assign something to this node.FrrIrrrÚ
can_assignãszExpr.can_assign)N) r%r&r'r(r,rOrPr<rSrÌr—rÍrrrrr¥Ñs r¥c@sLeZdZUdZdZeed<eed<eed<dZd e    j
e e    j dœd    d
„Z dS) ÚBinExprz%Baseclass for all binary expressions.)ÚleftÚrightrÏrÐÚoperatorTNrÉc
Cs|t||ƒ}|jjr&|j|jjkr&tƒ‚t|j}z||j |¡|j     |¡ƒWSt
k
rv}z tƒ|‚W5d}~XYnXdSr) rWr=Ú    sandboxedrÑZintercepted_binopsr#rrÏrÌrÐÚ    Exception©rDrÊÚfÚerrrrÌñs
ÿ þ
zBinExpr.as_const)N©r%r&r'r(r*r¥r’rQr,rOrPr<rSrÌrrrrrÎès
rÎc@sDeZdZUdZdZeed<eed<dZd
e    j
e e    j dœdd    „Z dS) Ú    UnaryExprz$Baseclass for all unary expressions.rÆrTrÑTNrÉc
Csrt||ƒ}|jjr&|j|jjkr&tƒ‚t|j}z||j |¡ƒWSt    k
rl}z tƒ|‚W5d}~XYnXdSr)
rWr=rÒrÑZintercepted_unopsr#rrTrÌrÓrÔrrrrÌ    s
ÿ þ
zUnaryExpr.as_const)Nr×rrrrrØs
rØc@s4eZdZUdZdZeed<eed<edœdd„ZdS)    r²a 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>ÚfalseÚTrueÚFalseÚnoneÚNoneÚtrue©r8rIrrrrÍ&szName.can_assignN©    r%r&r'r(r*rQr’r—rÍrrrrr²s
 
r²c@s4eZdZUdZdZeed<eed<edœdd„ZdS)    ÚNSRefz)Reference to a namespace value assignment)r8r;r8r;rFcCsdS)NTrrIrrrrÍ1szNSRef.can_assignNràrrrrrá*s
 
rác@seZdZdZdZdS)ÚLiteralzBaseclass for literals.TNr›rrrrrâ9srâc@s\eZdZUdZdZejed<d eje    ejdœdd„Z
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).
    ©r‹r‹NrÉcCs|jSrrärËrrrrÌIszConst.as_constzt.Optional[Environment])r‹rYr=r?cCs(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_reprrX)Úcompilerrår#)Úclsr‹rYr=rårrrÚfrom_untrustedLs zConst.from_untrusted)N)NN)r%r&r'r(r*rOrSr’rPr<rÌÚ classmethodr“rèrrrrrã?s
 
üûrãc@s6eZdZUdZdZeed<deje    edœdd„Z
dS)    Ú TemplateDatazA constant template string.)ÚdatarëNrÉcCs,t||ƒ}|jrtƒ‚|jr&t|jƒS|jSr)rWrCr#rBrrërËrrrrÌds 
 
zTemplateData.as_const)N) r%r&r'r(r*rQr’rOrPr<rÌrrrrrê^s
rêc@s^eZdZUdZdZejeed<e    ed<d ej
e ej ej dfdœdd    „Zed
œd d „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.
    )ÚitemsrUrìrUN.rÉcs"t|ˆƒ‰t‡fdd„|jDƒƒS)Nc3s|]}| ˆ¡VqdSr©rÌ©r}Úx©rÊrrr~ysz!Tuple.as_const.<locals>.<genexpr>)rWr4rìrËrrðrrÌws
zTuple.as_constrFcCs|jD]}| ¡sdSqdS)NFT)rìrÍ)rDrjrrrrÍ{s
zTuple.can_assign)N)r%r&r'r(r*rOr¡r¥r’rQrPr<r‘rSrÌr—rÍrrrrr‘ms
$r‘c@sDeZdZUdZdZejeed<dej    e
ejej dœdd„Z dS)    r¡z&Any list literal such as ``[1, 2, 3]``©rìrìNrÉcst|ˆƒ‰‡fdd„|jDƒS)Ncsg|]}| ˆ¡‘qSrrírîrðrrÚ
<listcomp>Šsz!List.as_const.<locals>.<listcomp>)rWrìrËrrðrr̈s
z List.as_const)N) r%r&r'r(r*rOr¡r¥r’rPr<rSrÌrrrrr¡‚s
r¡c@sJeZdZUdZdZejded<d    eje    ej
ej ej fdœdd„Z dS)
ÚDictzeAny dict literal such as ``{1: 2, 3: 4}``.  The items must be a list of
    :class:`Pair` nodes.
    rñÚPairrìNrÉcs"t|ˆƒ‰t‡fdd„|jDƒƒS)Nc3s|]}| ˆ¡VqdSrrírîrðrrr~™sz Dict.as_const.<locals>.<genexpr>)rWÚdictrìrËrrðrr̕s
z Dict.as_const)N) r%r&r'r(r*rOr¡r’rPr<rórSrÌrrrrrós
ÿþróc@sLeZdZUdZdZeed<eed<d    eje    ej
ej ej fdœdd„Z dS)
rôzA key, value pair for dicts.©Úkeyr‹r÷r‹NrÉcCs"t||ƒ}|j |¡|j |¡fSr)rWr÷rÌr‹rËrrrrÌ£s
z Pair.as_const)N) r%r&r'r(r*r¥r’rOrPr<r‘rSrÌrrrrrôœs
ÿþrôc@sJeZdZUdZdZeed<eed<d    ej    e
ej eej fdœdd„Z dS)
ÚKeywordz>A key, value pair for keyword arguments where key is a string.rör÷r‹NrÉcCst||ƒ}|j|j |¡fSr)rWr÷r‹rÌrËrrrṟs
zKeyword.as_const)N)r%r&r'r(r*rQr’r¥rOrPr<r‘rSrÌrrrrrøªs
 
røc@sNeZdZUdZdZeed<eed<ejeed<d
eje    ej
dœdd    „Z dS) ÚCondExprzZA conditional expression (inline if expression).  (``{{
    foo if bar else baz }}``)
    )r«Úexpr1Úexpr2r«rúrûNrÉcCs>t||ƒ}|j |¡r"|j |¡S|jdkr2tƒ‚|j |¡Sr)rWr«rÌrúrûr#rËrrrrÌÀs 
 
zCondExpr.as_const)N) r%r&r'r(r*r¥r’rOrPr<rSrÌrrrrrù¶s
rù)Ú_FilterTestCommonrµ)rTrÊr?c
ṡfdd„|jDƒ}t‡fdd„|jDƒƒ}|jdk    rxz| |j ˆ¡¡Wn*tk
rv}z tƒ|‚W5d}~XYnX|jdk    rÄz|     |j ˆ¡¡Wn*tk
rÂ}z tƒ|‚W5d}~XYnX||fS)Ncsg|]}| ˆ¡‘qSrrírîrðrrròÏsz!args_as_const.<locals>.<listcomp>c3s|]}| ˆ¡VqdSrrírîrðrrr~Ðsz args_as_const.<locals>.<genexpr>)
r°rõÚkwargsÚdyn_argsr-rÌrÓr#Ú
dyn_kwargsrM)rTrÊr°rýrÖrrðrÚ args_as_constÌs
 
rc@s|eZdZUdZeed<eed<ejeed<eje    ed<ej
eed<ej
eed<dZ dZ d ej
e ejd
œd d „Zd    S)rü)rTr8r°rýrþrÿrTr8r°rýrþrÿTNrÉc
Cst||ƒ}|jrtƒ‚|jr&|jj}n|jj}| |j¡}t     
|¡}|dksV|t    j kr\tƒ‚|jj r„t |ddƒdks~t |¡r„tƒ‚t||ƒ\}}| d|j |¡¡|t    jkr¾| d|¡n|t    jkrÖ| d|j¡z |||ŽWStk
r}z tƒ|‚W5d}~XYnXdS)NZjinja_async_variantFTr)rWrCr#Ú
_is_filterr=ÚfiltersÚtestsr0r8rZfrom_objÚcontextZis_asyncr.ÚinspectÚiscoroutinefunctionrÚinsertrTrÌZ eval_contextrÓ)rDrÊZenv_mapÚfuncZpass_argr°rýrÖrrrrÌìs4
 
 
ÿþ
 
 z_FilterTestCommon.as_const)N)r%r&r'r*r¥r’rQrOr¡rôrPr,rr<rSrÌrrrrrüás
rücsBeZdZUdZejeed<dejeej    dœ‡fdd„ Z
‡Z S)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.
    rTNrÉcs|jdkrtƒ‚tƒj|dS)Nrð)rTr#ÚsuperrÌr˩ڠ   __class__rrrÌs
zFilter.as_const)N) r%r&r'r(rOrPr¥r’r<rSrÌÚ __classcell__rrr
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)r%r&r'r(rrrrrr "s    r 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.
    )rTr°rýrþrÿrTr°rýrþrÿN) r%r&r'r(r*r¥r’rOr¡rørPrrrrrµ/s
rµc@sHeZdZUdZdZeed<eed<eed<d
ej    e
ej dœdd    „Z dS) ÚGetitemz@Get an attribute or item from an expression and prefer the item.)rTrbrUrTrbrUNrÉc
Csj|jdkrtƒ‚t||ƒ}z |j |j |¡|j |¡¡WStk
rd}z tƒ|‚W5d}~XYnXdS©NÚload)    rUr#rWr=ÚgetitemrTrÌrbrÓ©rDrÊrÖrrrrÌGs
 
 
 
ÿzGetitem.as_const)N© r%r&r'r(r*r¥r’rQrOrPr<rSrÌrrrrr?s
rc@sHeZdZUdZdZeed<eed<eed<d
ej    e
ej dœdd    „Z dS) ÚGetattrznGet an attribute or item from an expression that is a ascii-only
    bytestring and prefer the attribute.
    )rTr;rUrTr;rUNrÉc
Csd|jdkrtƒ‚t||ƒ}z|j |j |¡|j¡WStk
r^}z tƒ|‚W5d}~XYnXdSr)    rUr#rWr=r.rTrÌr;rÓrrrrrÌ_s
 
zGetattr.as_const)NrrrrrrUs
rc@sXeZdZUdZdZejeed<ejeed<ejeed<d
eje    e
dœdd    „Z dS) ÚSlicez_Represents a slice object.  This must only be used as argument for
    :class:`Subscript`.
    )ÚstartÚstopÚsteprrrNrÉcsJt|ˆƒ‰tjttjtjdœ‡fdd„ }t||jƒ||jƒ||jƒƒS)N)Úobjr?cs|dkr dS| ˆ¡Srrí)rrðrrÚconstxszSlice.as_const.<locals>.const)    rWrOrPr¥rSÚslicerrr)rDrÊrrrðrrÌus
"zSlice.as_const)N) r%r&r'r(r*rOrPr¥r’r<rrÌrrrrrks
rc@s<eZdZUdZdZejeed<dej    e
e dœdd„Z dS)    ÚConcatzXConcatenates the list of expressions provided after converting
    them to strings.
    r£r¤NrÉcs$t|ˆƒ‰d ‡fdd„|jDƒ¡S)Nr[c3s|]}t| ˆ¡ƒVqdSr)rQrÌrîrðrrr~Šsz"Concat.as_const.<locals>.<genexpr>)rWrr¤rËrrðrr̈s
zConcat.as_const)N) r%r&r'r(r*rOr¡r¥r’rPr<rQrÌrrrrr€s
rc@sFeZdZUdZdZeed<ejded<d
ej    e
ej dœdd    „Z dS) ÚCompareziCompares an expression with some other expressions.  `ops` must be a
    list of :class:`Operand`\s.
    )ÚexprÚopsrÚOperandrNrÉc
Cs†t||ƒ}|j |¡}}z<|jD]0}|j |¡}t|j||ƒ}|sNWdS|}q"Wn*tk
r€}z tƒ|‚W5d}~XYnX|Sr@)rWrrÌrr"ÚoprÓr#)rDrÊror‹r!Ú    new_valuerÖrrrr̖s
 
 
zCompare.as_const)N) r%r&r'r(r*r¥r’rOr¡rPr<rSrÌrrrrrs
 
rc@s&eZdZUdZdZeed<eed<dS)r z$Holds an operator and an expression.)r!rr!rN)r%r&r'r(r*rQr’r¥rrrrr ©s
r c@seZdZdZdZdS)ÚMulz(Multiplies the left with the right node.r
N©r%r&r'r(rÑrrrrr#±sr#c@seZdZdZdZdS)ÚDivz#Divides the left by the right node.r Nr$rrrrr%·sr%c@seZdZdZdZdS)ÚFloorDivzbDivides the left by the right node and converts 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.eZdZdZdZdejeejdœdd„Z    dS)ÚAndzShort circuited AND.ÚandNrÉcCs"t||ƒ}|j |¡o |j |¡Sr©rWrÏrÌrÐrËrrrrÌâs
z And.as_const)N©
r%r&r'r(rÑrOrPr<rSrÌrrrrr+Ýsr+c@s.eZdZdZdZdejeejdœdd„Z    dS)ÚOrzShort circuited OR.ÚorNrÉcCs"t||ƒ}|j |¡p |j |¡Srr-rËrrrrÌìs
z Or.as_const)Nr.rrrrr/çsr/c@seZdZdZdZdS)ÚNotzNegate the expression.rNr$rrrrr1ñsr1c@seZdZdZdZdS)ÚNegzMake the expression negative.rNr$rrrrr2÷sr2c@seZdZdZdZdS)ÚPosz8Make the expression positive (noop for most expressions)rNr$rrrrr3ýsr3c@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.
    rßr8N©r%r&r'r(r*rQr’rrrrr4s
r4c@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.
    )Ú
identifierr8r7r8Nr5rrrrr6s
r6c@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.
    )Ú
importnamer9Nr5rrrrr8s
r8c@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.
    rßr8NrFcCs tdƒ‚dS)NzKCan't create internal names.  Use the `free_identifier` method on a parser.©r\rIrrrrE2sÿzInternalName.__init__)r%r&r'r(r*rQr’rErrrrr:'s
r:c@s6eZdZUdZdZeed<deje    e
dœdd„Z dS)    ÚMarkSafez:Mark the wrapped expression as safe (wrap it as `Markup`).©rrNrÉcCst||ƒ}t|j |¡ƒSr)rWrrrÌrËrrrrÌ?s
zMarkSafe.as_const)N) r%r&r'r(r*r¥r’rOrPr<rrÌrrrrr<9s
r<c@sBeZdZUdZdZeed<deje    ej
e ej 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=rNrÉcCs4t||ƒ}|jrtƒ‚|j |¡}|jr0t|ƒS|Sr)rWrCr#rrÌrBr)rDrÊrrrrrÌNs
 zMarkSafeIfAutoescape.as_const)N)r%r&r'r(r*r¥r’rOrPr<rrrSrÌrrrrr>Ds
ÿþ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?Zsr?c@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
    Nr$rrrrr@lsr@c@seZdZdZdS)ÚContinuezContinue a loop.Nr$rrrrrAusrAc@seZdZdZdS)ÚBreakz Break a loop.Nr$rrrrrBysrBc@s$eZdZUdZdZejeed<dS)ÚScopezAn artificial scope.ržrŸNr rrrrrC}s
rCc@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
    )rrŸrrŸN)
r%r&r'r(r*r¥r’rOr¡rrrrrrD„s
 rDc@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))])
    )ÚoptionsrFN)    r%r&r'r(r*rOr¡rør’rrrrrE—s
rEc@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ŸNr rrrrrG¤s
rGz te.NoReturn)r°rýr?cOs tdƒ‚dS)Nzcan't create custom node typesr;)r°rýrrrÚ _failing_new¯srH)zr(rrÑÚtypingrOÚ collectionsrZ
markupsaferÚutilsrÚ TYPE_CHECKINGZtyping_extensionsÚter=rÚTypeVarrÚmulÚtruedivÚfloordivÚpowÚmodÚaddÚsubrrórQÚCallablerSr’Únot_ÚposÚnegrrrrÚgerÚler"rÓr#r6r)r<rPrWrrš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ùrrrür¸r rµrrrrrr r#r%r&r'r(r)r*r+r/r1r2r3r4r6r8r:r<r>r?r@rArBrCrDrErGrHÚ staticmethodr7rrrrÚ<module>sà    ù, ý(ø,  2        
                 "þ 0