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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
3

U'ícö†ã	@s&UdZddlZddlZddlZddlmZddlmZddl	m
Z
ejr\ddlZ
ddlmZejdd	d
ZejejejejejejejdœZejeejejejgejffejejej dœZ!ejeejejgejff!ej"ej#ej$ej%ej&ej'd
d„dd„dœZ(ejeejejejgejff(Gdd„de)ƒZ*Gdd„de+ƒZ,Gdd„dƒZ-d	ej.e-e-dœdd„Z/Gdd	„d	e,dZ0Gdd„de0ƒZ1Gdd„de0ƒZ2Gd d!„d!e0ƒZ3Gd"d#„d#e1ƒZ4Gd$d%„d%e1ƒZ5Gd&d'„d'e1ƒZ6Gd(d)„d)e1ƒZ7Gd*d+„d+e1ƒZ8Gd,d-„d-e1ƒZ9Gd.d/„d/e1ƒZ:Gd0d1„d1e1ƒZ;Gd2d3„d3e1ƒZ<Gd4d5„d5e1ƒZ=Gd6d7„d7e1ƒZ>Gd8d9„d9e1ƒZ?Gd:d;„d;e1ƒZ@Gd<d=„d=e1ƒZAGd>d?„d?e1ƒZBGd@dA„dAe0ƒZCGdBdC„dCeCƒZDGdDdE„dEeCƒZEGdFdG„dGeCƒZFGdHdI„dIeCƒZGGdJdK„dKeCƒZHGdLdM„dMeHƒZIGdNdO„dOeHƒZJGdPdQ„dQeHƒZKGdRdS„dSeHƒZLGdTdU„dUeHƒZGdVdW„dWe2ƒZMGdXdY„dYe2ƒZNGdZd[„d[eCƒZOejPd«ej.e-ejKejLejejejejffd^œd_d`„ZQGdad\„d\eCƒZRGdbdc„dceRƒZSGddde„deeRƒZTGdfd]„d]eCƒZUGdgdh„dheCƒZVGdidj„djeCƒZWGdkdl„dleCƒZXGdmdn„dneCƒZYGdodp„dpeCƒZZGdqdr„dre2ƒZ[Gdsdt„dteDƒZ\Gdudv„dveDƒZ]Gdwdx„dxeDƒZ^Gdydz„dzeDƒZ_Gd{d|„d|eDƒZ`Gd}d~„d~eDƒZaGdd€„d€eDƒZbGdd‚„d‚eDƒZcGdƒd„„d„eDƒZdGd…d†„d†eEƒZeGd‡dˆ„dˆeEƒZfGd‰dŠ„dŠeEƒZgGd‹dŒ„dŒeCƒZhGddŽ„dŽeCƒZiGdd„deCƒZjGd‘d’„d’eCƒZkGd“d”„d”eCƒZlGd•d–„d–eCƒZmGd—d˜„d˜eCƒZnGd™dš„dšeCƒZoGd›dœ„dœe1ƒZpGddž„dže1ƒZqGdŸd „d e1ƒZrGd¡d¢„d¢e1ƒZsGd£d¤„d¤e1ƒZtGd¥d¦„d¦etƒZuejejd§d¨œd©dª„Zvewevƒe,_x[vdS)¬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**ú%ú+ú-)Únotrr
cCs||kS)N©)ÚaÚbrrú./tmp/pip-build-gk9425m9/Jinja2/jinja2/nodes.pyÚ<lambda>+srcCs||kS)Nr)rrrrrr,s)ÚeqÚneÚgtZgteqÚltZlteqÚinÚnotinc@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|d	D]t}g}|jt|r |dnt|fƒƒ|j|j|fƒƒt|ƒdksRtdƒ‚t|ƒtt|ƒƒksntdƒ‚t|ƒ||<qW|jddƒt	j
||||ƒS)
NÚfieldsÚ
attributesrrz multiple inheritance not allowedzlayout conflictÚabstractF)r r!)ÚextendÚgetattrÚobjectÚgetÚlenÚAssertionErrorÚsetÚtupleÚ
setdefaultÚtypeÚ__new__)ZmcsÚnameÚbasesÚdÚattrZstoragerrrr-9s
zNodeType.__new__N)rrrrr-rrrrr4src@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|j|ƒ|_n|j|_d|_dS)NF)r3ÚcallableÚ
autoescapeÚvolatile)Úselfr3r4rrrÚ__init__Js

zEvalContext.__init__)r5cCs
|jjƒS)N)Ú__dict__Úcopy)r9rrrÚsaveTszEvalContext.save)Úoldr5cCs|jjƒ|jj|ƒdS)N)r;ÚclearÚupdate)r9r>rrrÚrevertWs
zEvalContext.revert)N)rrrrÚtÚOptionalÚstrr:ÚMappingÚAnyr=rArrrrr2Es
r2)ÚnodeÚctxr5cCs(|dkr$|jdkrtdƒ‚t|jƒS|S)NzIif no eval context is passed, the node must have an attached environment.)r3ÚRuntimeErrorr2)rGrHrrrÚget_eval_context\s

rJc@sˆeZdZUdZfZejedfd'ZejedfdZ	e
ejd
ejejddœd	d
„Zd(ejejeejejeejejeejfdœdd
„Zd)ejejeejejeejddœdd„Zejeejedœdd„Zejejeejejedffejedœdd„Zeddœdd„Zd*e
eddœdd„Zdddœdd„Zejedœd d!„ZejZed"œd#d$„Z ed"œ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.
    .Úlinenor3TrN)r r!r5cOsÜ|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|||j	|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)r9r r!r.Úargr1rrrr:s4z
Node.__init__)ÚexcludeÚonlyr5c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)r9rUrVr.rrrÚiter_fields‘szNode.iter_fieldsccsXxR|j||ƒ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)rXÚ
isinstanceÚlistr)r9rUrVÚ_ÚitemÚnrrrÚiter_child_nodes§s	



zNode.iter_child_nodes)Ú	node_typer5cCsx|j|ƒD]}|SWdS)ziFind the first node of a given type.  If no such node exists the
        return value is `None`.
        N)Úfind_all)r9r_ÚresultrrrÚfind¸sz	Node.findccs6x0|jƒD]$}t||ƒr|V|j|ƒ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)r^rYr`)r9r_Úchildrrrr`Ás
z
Node.find_all)rHr5cCs>t|gƒ}x.|r8|jƒ}d|jkr(||_|j|jƒƒ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.
        rH)rÚpopleftr rHr#r^)r9rHÚtodorGrrrÚset_ctxÌs

zNode.set_ctxF)rKÚoverrider5cCsLt|gƒ}x<|rF|jƒ}d|jkr6|jdks0|r6||_|j|jƒƒqW|S)z.Set the line numbers of the node and children.rKN)rrdr!rKr#r^)r9rKrgrerGrrrÚ
set_linenoÚs

zNode.set_lineno)r3r5cCs4t|gƒ}x$|r.|jƒ}||_|j|jƒƒqW|S)z"Set the environment for all nodes.)rrdr3r#r^)r9r3rerGrrrÚset_environmentås
zNode.set_environment)Úotherr5cCs,t|ƒt|ƒk	rtSt|jƒƒt|jƒƒkS)N)r,ÚNotImplementedr*rX)r9rjrrrÚ__eq__îszNode.__eq__)r5cs0dj‡fdd„ˆjDƒƒ}tˆƒj›d|›dS)Nz, c3s$|]}|›dtˆ|dƒ›VqdS)ú=N)r$)Ú.0r)r9rrú	<genexpr>÷sz Node.__repr__.<locals>.<genexpr>ú(ú))Újoinr r,r)r9Úargs_strr)r9rÚ__repr__ösz
Node.__repr__cs8tjttjfddœ‡‡fdd„‰g‰ˆ|ƒdjˆƒS)N)rGr5csÚt|tƒsˆjt|ƒƒdSˆjdt|ƒj›dƒ|jsHˆjdƒdSx‚t|jƒD]t\}}|rjˆjdƒt||ƒ}t|t	ƒrÀˆjdƒx*t|ƒD]\}}|r¨ˆjdƒˆ|ƒq’WˆjdƒqTˆ|ƒqTWˆjdƒdS)Nznodes.rprqz, ú[ú])
rYrÚappendÚreprr,rr Ú	enumerater$rZ)rGÚidxÚfieldÚvaluer\)Ú_dumpÚbufrrr}ûs(






zNode.dump.<locals>._dumprM)rBÚUnionrrFrr)r9r)r}r~rÚdumpús"z	Node.dump)rKr3)NN)NN)F)"rrrrr rBÚTuplerDr!r"ÚintrKrCr3rFr:Ú	ContainerÚIteratorrXr^ÚTyperrbrr`rfÚboolrhrirlr%Ú__hash__rtr€rrrrrgs.

 

"		)Ú	metaclassc@seZdZdZdZdS)ÚStmtzBase node for all statements.TN)rrrrr"rrrrr‰sr‰c@seZdZdZdZdS)ÚHelperz,Nodes that exist in a specific context only.TN)rrrrr"rrrrrŠsrŠc@s eZdZUdZdZejedS)ÚTemplatezjNode that represents a template.  This must be the outermost node that
    is passed to the compiler.
    ÚbodyN)rŒ)	rrrrr rBÚListrrŒrrrrr‹$s
r‹c@s eZdZUdZdZejddS)Ú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ÚExprN)r)rrrrr rBrrrrrrrŽ-s
rŽc@seZdZUdZdZddS)ÚExtendsz Represents an extends statement.ÚtemplaterN)r’)rrrrr r’rrrrr‘6s
r‘c@s@eZdZUdZd	Zeeej	e
ej	eeje
edS)
Ú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`.
    ÚtargetrSrŒÚelse_ÚtestÚ	recursiveN)r”rSrŒr•r–r—)rrrrr rr”rSrBrrŒr•rCr–r†r—rrrrr“=s



r“c@s8eZdZUdZdZeeje	ejd
ejedS)ÚIfz4If `test` is true, `body` is rendered, else `else_`.r–rŒÚelif_r•N)r–rŒr™r•)rrrrr rr–rBrrŒr™r•rrrrr˜Os


r˜c@s8eZdZUdZd	Zeejd	ejd
ejedS)
Ú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.
    r.ÚargsÚdefaultsrŒÚNamerN)r.r›rœrŒ)
rrrrr rDr.rBrr›rœrrŒrrrrršYs


ršc@s8eZdZUdZd
Zdejdejd	eje
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N)rŸr›rœrŒ)rrrrr rŸrBrr›rœrrŒrrrrržfs


ržc@s$eZdZUdZdZejed	dS)ÚFilterBlockzNode for filter sections.rŒÚfilterÚFilterN)rŒr¢)
rrrrr rBrrrŒr¢rrrrr¡rs

r¡c@s4eZdZUdZdZejdejdeje	
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N)r¥r¦rŒ)rrrrr rBrr¥r¦rrŒrrrrr¤zs



r¤c@s,eZdZUdZdZeeje	
ee
dS)ÚBlockzkA node that represents a block.

    .. versionchanged:: 3.0.0
        the `required` field was added.
    r.rŒÚscopedÚrequiredN)r.rŒr¨r©)rrrrr rDr.rBrrrŒr†r¨r©rrrrr§‡s

r§c@s"eZdZUdZdZdeedS)ÚIncludez'A node that represents the include tag.r’Úwith_contextÚignore_missingrN)r’r«r¬)	rrrrr r’r†r«r¬rrrrrª•s

rªc@s"eZdZUdZdZdee	dS)ÚImportz&A node that represents the import tag.r’r”r«rN)r’r”r«)
rrrrr r’rDr”r†r«rrrrr­žs

r­c@s<eZdZUdZdZdejeje	ej
e	e	ffe
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N)r’r¯r«)rrrrr r’rBrrrDrr¯r†r«rrrrr®§s


r®c@seZdZUdZdZedS)ÚExprStmtzAA statement that evaluates an expression and discards the result.rGN)rG)rrrrr rrGrrrrr°¹s
r°c@seZdZUdZdZdedS)ÚAssignz"Assigns an expression to a target.r”rGrN)r”rG)rrrrr r”rrGrrrrr±Às
r±c@s.eZdZUdZdZdejdej	e
dS)	ÚAssignBlockzAssigns a block to a target.r”r¢rŒrr£N)r”r¢rŒ)rrrrr r”rBrCr¢rrrŒrrrrr²Ès


r²c@s<eZdZdZdZd
ejeejdœdd„Z	e
dœdd	„ZdS)rzBaseclass for all expressions.TN)Úeval_ctxr5cCs
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)r9r³rrrÚas_constÖsz
Expr.as_const)r5cCsdS)z8Check if it's possible to assign something to this node.Fr)r9rrrÚ
can_assignãszExpr.can_assign)N)rrrrr"rBrCr2rFr´r†rµrrrrrÑs
rc@s@eZdZUdZd	Zeee	dZ
d
eje
ejdœdd„ZdS)ÚBinExprz%Baseclass for all binary expressions.ÚleftÚrightTN)r³r5cCszt||ƒ}|jjr&|j|jjkr&tƒ‚t|j}y||jj|ƒ|j	j|ƒƒSt
k
rt}ztƒ|‚WYdd}~XnXdS)N)rJr3Ú	sandboxedÚoperatorZintercepted_binopsrÚ_binop_to_funcr·r´r¸Ú	Exception)r9r³ÚfÚerrrr´ñs

zBinExpr.as_const)r·r¸)N)rrrrr rr·r¸rDrºr"rBrCr2rFr´rrrrr¶ès
r¶c@s<eZdZUdZdZeedZ	d	e
jee
j
dœdd„ZdS)
Ú	UnaryExprz$Baseclass for all unary expressions.rGTN)r³r5cCspt||ƒ}|jjr&|j|jjkr&tƒ‚t|j}y||jj|ƒƒSt	k
rj}ztƒ|‚WYdd}~XnXdS)N)
rJr3r¹rºZintercepted_unopsrÚ
_uaop_to_funcrGr´r¼)r9r³r½r¾rrrr´	s

zUnaryExpr.as_const)rG)N)rrrrr rrGrDrºr"rBrCr2rFr´rrrrr¿s
r¿c@s,eZdZUdZdZeeedœdd„Z	dS)	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.
    r.rH)r5cCs
|jdkS)NÚtrueÚfalseÚnoneÚTrueÚFalseÚNone>rÂrÄrÁrÃrÆrÅ)r.)r9rrrrµ&szName.can_assignN)r.rH)
rrrrr rDr.rHr†rµrrrrrs

rc@s,eZdZUdZdZeeedœdd„Z	dS)	ÚNSRefz)Reference to a namespace value assignmentr.r1)r5cCsdS)NTr)r9rrrrµ1szNSRef.can_assignN)r.r1)
rrrrr rDr.r1r†rµrrrrrÇ*s

rÇc@seZdZdZdZdS)ÚLiteralzBaseclass for literals.TN)rrrrr"rrrrrÈ9srÈc@sXeZdZUdZdZejd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|N)r³r5cCs|jS)N)r|)r9r³rrrr´IszConst.as_constzt.Optional[Environment])r|rKr3r5cCs(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)rKr3)ÚcompilerrÊr)Úclsr|rKr3rÊrrrÚfrom_untrustedLszConst.from_untrusted)r|)N)NN)rrrrr rBrFr|rCr2r´Úclassmethodr‚rÍrrrrrÉ?s
rÉc@s2eZdZUdZdZedeje	edœdd„Z
dS)	ÚTemplateDatazA constant template string.ÚdataN)r³r5cCs,t||ƒ}|jrtƒ‚|jr&t|jƒS|jS)N)rJr8rr7rrÐ)r9r³rrrr´ds

zTemplateData.as_const)rÐ)N)rrrrr rDrÐrBrCr2r´rrrrrÏ^s
rÏc@sVeZdZUdZdZejee	
d
ejeej
ejdfdœ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.
    ÚitemsrHN.)r³r5cs"t|ˆƒ‰t‡fdd„|jDƒƒS)Nc3s|]}|jˆƒVqdS)N)r´)rnÚx)r³rrroysz!Tuple.as_const.<locals>.<genexpr>)rJr*rÑ)r9r³r)r³rr´ws
zTuple.as_const)r5cCs x|jD]}|jƒsdSqWdS)NFT)rÑrµ)r9r\rrrrµ{szTuple.can_assign)rÑrH)N)rrrrr rBrrrÑrDrHrCr2rrFr´r†rµrrrrrms

$rc@s@eZdZUdZdZejedej	e
ejejdœdd„ZdS)	rz&Any list literal such as ``[1, 2, 3]``rÑN)r³r5cst|ˆƒ‰‡fdd„|jDƒS)Ncsg|]}|jˆƒ‘qSr)r´)rnrÒ)r³rrú
<listcomp>Šsz!List.as_const.<locals>.<listcomp>)rJrÑ)r9r³r)r³rr´ˆs
z
List.as_const)rÑ)N)
rrrrr rBrrrÑrCr2rFr´rrrrr‚s

rc@sFeZdZUdZdZejdd	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ÑÚPairN)r³r5cs"t|ˆƒ‰t‡fdd„|jDƒƒS)Nc3s|]}|jˆƒVqdS)N)r´)rnrÒ)r³rrro™sz Dict.as_const.<locals>.<genexpr>)rJÚdictrÑ)r9r³r)r³rr´•s
z
Dict.as_const)rÑ)N)
rrrrr rBrrÑrCr2rÔrFr´rrrrrԍs



rÔc@sDeZdZUdZdZeed	ej	e
ejejejfdœdd„Z
dS)
rÕzA key, value pair for dicts.Úkeyr|N)r³r5cCs"t||ƒ}|jj|ƒ|jj|ƒfS)N)rJr×r´r|)r9r³rrrr´£s
z
Pair.as_const)r×r|)N)rrrrr rr×r|rBrCr2rrFr´rrrrr՜s

rÕc@sBeZdZUdZdZeed	e	j
ee	jee	j
fdœdd„ZdS)
ÚKeywordz>A key, value pair for keyword arguments where key is a string.r×r|N)r³r5cCst||ƒ}|j|jj|ƒfS)N)rJr×r|r´)r9r³rrrr´±s
zKeyword.as_const)r×r|)N)rrrrr rDr×rr|rBrCr2rrFr´rrrrrتs

rØc@sBeZdZUdZd	Zeeej	e
d
ej	eejdœdd„Z
dS)ÚCondExprzZA conditional expression (inline if expression).  (``{{
    foo if bar else baz }}``)
    r–Úexpr1Úexpr2N)r³r5cCs>t||ƒ}|jj|ƒr"|jj|ƒS|jdkr2tƒ‚|jj|ƒS)N)rJr–r´rÚrÛr)r9r³rrrr´Às

zCondExpr.as_const)r–rÚrÛ)N)rrrrr rr–rÚrBrCrÛr2rFr´rrrrrÙ¶s

rÙÚ_FilterTestCommonr )rGr³r5cṡfdd„|jDƒ}t‡fdd„|jDƒƒ}|jdk	rxy|j|jjˆƒƒWn*tk
rv}ztƒ|‚WYdd}~XnX|jdk	rÄy|j	|jjˆƒƒWn*tk
rÂ}ztƒ|‚WYdd}~XnX||fS)Ncsg|]}|jˆƒ‘qSr)r´)rnrÒ)r³rrrÓÏsz!args_as_const.<locals>.<listcomp>c3s|]}|jˆƒVqdS)N)r´)rnrÒ)r³rrroÐsz args_as_const.<locals>.<genexpr>)
r›rÖÚkwargsÚdyn_argsr#r´r¼rÚ
dyn_kwargsr@)rGr³r›rÝr¾r)r³rÚ
args_as_constÌs

ràc@sdeZdZUdZeeej	e
ej	eej
eej
edZdZd
ej
eejd	œd
d„ZdS)rÜrGr.r›rÝrÞrßTN)r³r5cCst||ƒ}|jrtƒ‚|jr&|jj}n|jj}|j|jƒ}t	j
|ƒ}|dksV|t	jkr\tƒ‚|jjr„t
|ddƒdks~tj|ƒr„tƒ‚t||ƒ\}}|jd|jj|ƒƒ|t	jkr¾|jd|ƒn|t	jkrÖ|jd|jƒy
|||ŽStk
r}ztƒ|‚WYdd}~XnXdS)NZjinja_async_variantFTr)rJr8rÚ
_is_filterr3ÚfiltersÚtestsr&r.rZfrom_objÚcontextZis_asyncr$ÚinspectÚiscoroutinefunctionràÚinsertrGr´Zeval_contextr¼)r9r³Zenv_mapÚfuncZpass_argr›rÝr¾rrrr´ìs0






z_FilterTestCommon.as_const)rGr.r›rÝrÞrß)N)rrrr rrGrDr.rBrr›rÕrÝrCrÞrßr"rár2rFr´rrrrrÜás




cs>eZdZUdZejedejeej	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.
    N)r³r5cs|jdkrtƒ‚tƒj|dS)N)r³)rGrÚsuperr´)r9r³)Ú	__class__rrr´s
zFilter.as_const)N)rrrrrBrCrrGr2rFr´Ú
__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)rrrrrárrrrrì"srìc@sBeZdZUdZdZeeje	eje
eje
ejedS)	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.
    rGr›rÝrÞrßN)rGr›rÝrÞrß)rrrrr rrGrBrr›rØrÝrCrÞrßrrrrr /s



c@s<eZdZUdZd	Zeee	d
e
jee
j
dœdd„ZdS)ÚGetitemz@Get an attribute or item from an expression and prefer the item.rGrTrHN)r³r5cCsh|jdkrtƒ‚t||ƒ}y|jj|jj|ƒ|jj|ƒƒStk
rb}ztƒ|‚WYdd}~XnXdS)NÚload)	rHrrJr3ÚgetitemrGr´rTr¼)r9r³r¾rrrr´Gs

zGetitem.as_const)rGrTrH)N)rrrrr rrGrTrDrHrBrCr2rFr´rrrrrí?s
ríc@s<eZdZUdZd	Zeee	d
e
jee
j
dœdd„ZdS)ÚGetattrznGet an attribute or item from an expression that is a ascii-only
    bytestring and prefer the attribute.
    rGr1rHN)r³r5cCsb|jdkrtƒ‚t||ƒ}y|jj|jj|ƒ|jƒStk
r\}ztƒ|‚WYdd}~XnXdS)Nrî)	rHrrJr3r$rGr´r1r¼)r9r³r¾rrrr´_s

zGetattr.as_const)rGr1rH)N)rrrrr rrGrDr1rHrBrCr2rFr´rrrrrðUs
rðc@sLeZdZUdZd	Zejeeje	eje
d
ejeedœdd„Z
dS)ÚSlicez_Represents a slice object.  This must only be used as argument for
    :class:`Subscript`.
    ÚstartÚstopÚstepN)r³r5csJt|ˆƒ‰tjttjtjdœ‡fdd„}t||jƒ||jƒ||jƒƒS)N)Úobjr5cs|dkrdS|jˆƒS)N)r´)rõ)r³rrÚconstxszSlice.as_const.<locals>.const)	rJrBrCrrFÚsliceròrórô)r9r³rör)r³rr´us
"zSlice.as_const)ròrórô)N)rrrrr rBrCrròrórôr2r÷r´rrrrrñks



rñc@s8eZdZUdZdZejedej	e
edœdd„ZdS)	ÚConcatzXConcatenates the list of expressions provided after converting
    them to strings.
    rN)r³r5cs$t|ˆƒ‰dj‡fdd„|jDƒƒS)NrMc3s|]}t|jˆƒƒVqdS)N)rDr´)rnrÒ)r³rrroŠsz"Concat.as_const.<locals>.<genexpr>)rJrrr)r9r³r)r³rr´ˆs
zConcat.as_const)r)N)
rrrrr rBrrrrCr2rDr´rrrrrø€s

røc@s>eZdZUdZd	Zeejd	d
ej
eejdœdd„Z
dS)ÚCompareziCompares an expression with some other expressions.  `ops` must be a
    list of :class:`Operand`\s.
    ÚexprÚopsÚOperandN)r³r5cCs†t||ƒ}|jj|ƒ}}y<x6|jD],}|jj|ƒ}t|j||ƒ}|sLdS|}q$WWn*tk
r€}ztƒ|‚WYdd}~XnX|S)NF)rJrúr´rûÚ_cmpop_to_funcÚopr¼r)r9r³rar|rþZ	new_valuer¾rrrr´–s
zCompare.as_const)rúrû)N)rrrrr rrúrBrrûrCr2rFr´rrrrrùs


rùc@seZdZUdZdZeedS)rüz$Holds an operator and an expression.rþrúN)rþrú)	rrrrr rDrþrrúrrrrrü©s
rüc@seZdZdZdZdS)ÚMulz(Multiplies the left with the right node.r	N)rrrrrºrrrrrÿ±srÿc@seZdZdZdZdS)ÚDivz#Divides the left by the right node.r
N)rrrrrºrrrrr·src@seZdZdZdZdS)ÚFloorDivzbDivides the left by the right node and converts the
    result into an integer by truncating.
    z//N)rrrrrºrrrrr½src@seZdZdZdZdS)ÚAddzAdd the left to the right node.rN)rrrrrºrrrrrÅsrc@seZdZdZdZdS)ÚSubz&Subtract the right from the left node.r
N)rrrrrºrrrrrËsrc@seZdZdZdZdS)ÚModzLeft modulo right.rN)rrrrrºrrrrrÑsrc@seZdZdZdZdS)ÚPowzLeft to the power of right.z**N)rrrrrºrrrrr×src@s.eZdZdZdZdejeejdœdd„Z	dS)ÚAndzShort circuited AND.ÚandN)r³r5cCs"t||ƒ}|jj|ƒo |jj|ƒS)N)rJr·r´r¸)r9r³rrrr´âs
zAnd.as_const)N)
rrrrrºrBrCr2rFr´rrrrrÝsrc@s.eZdZdZdZdejeejdœdd„Z	dS)ÚOrzShort circuited OR.ÚorN)r³r5cCs"t||ƒ}|jj|ƒp |jj|ƒS)N)rJr·r´r¸)r9r³rrrr´ìs
zOr.as_const)N)
rrrrrºrBrCr2rFr´rrrrrçsrc@seZdZdZdZdS)ÚNotzNegate the expression.rN)rrrrrºrrrrr
ñsr
c@seZdZdZdZdS)ÚNegzMake the expression negative.r
N)rrrrrºrrrrr÷src@seZdZdZdZdS)ÚPosz8Make the expression positive (noop for most expressions)rN)rrrrrºrrrrrýsrc@seZdZUdZdZedS)ÚEnvironmentAttributezLoads an attribute from the environment object.  This is useful for
    extensions that want to call a callback stored on the environment.
    r.N)r.)rrrrr rDr.rrrrr
s
r
c@seZdZUdZdZeedS)Ú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.
    Ú
identifierr.N)rr.)rrrrr rDrr.rrrrrs
rc@seZdZUdZdZedS)Ú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.
    Ú
importnameN)r)rrrrr rDrrrrrrs
rc@s(eZdZUdZdZeddœ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.N)r5cCstdƒ‚dS)NzKCan't create internal names.  Use the `free_identifier` method on a parser.)rN)r9rrrr:2szInternalName.__init__)r.)rrrrr rDr.r:rrrrr's
rc@s2eZdZUdZdZedeje	e
dœdd„ZdS)	ÚMarkSafez:Mark the wrapped expression as safe (wrap it as `Markup`).rúN)r³r5cCst||ƒ}t|jj|ƒƒS)N)rJrrúr´)r9r³rrrr´?s
zMarkSafe.as_const)rú)N)rrrrr rrúrBrCr2rr´rrrrr9s
rc@s>eZdZUdZdZedeje	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úN)r³r5cCs4t||ƒ}|jrtƒ‚|jj|ƒ}|jr0t|ƒS|S)N)rJr8rrúr´r7r)r9r³rúrrrr´Ns
zMarkSafeIfAutoescape.as_const)rú)N)rrrrr rrúrBrCr2rrrFr´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)rrrrrrrrrZsrc@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)rrrrrrrrrlsrc@seZdZdZdS)ÚContinuezContinue a loop.N)rrrrrrrrrusrc@seZdZdZdS)ÚBreakz
Break a loop.N)rrrrrrrrrysrc@s eZdZUdZdZejedS)ÚScopezAn artificial scope.rŒN)rŒ)	rrrrr rBrrrŒrrrrr}s
rc@s$eZdZUdZdZeeje	
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ŒN)rärŒ)rrrrr rrärBrrrŒrrrrr„s
rc@s eZdZUdZdZejedS)Ú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))])
    ÚoptionsN)r)	rrrrr rBrrØrrrrrr—s
rc@s eZdZUdZdZejedS)Ú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ŒN)rŒ)	rrrrr rBrrrŒrrrrr¤s
rzte.NoReturn)r›rÝr5cOstdƒ‚dS)Nzcan't create custom node types)rN)r›rÝrrrÚ_failing_new¯sr)rÜr )yrrårºÚtypingrBÚcollectionsrZ
markupsaferÚutilsrZ
TYPE_CHECKINGZtyping_extensionsÚter3rZTypeVarrÚmulÚtruedivÚfloordivÚpowÚmodÚaddÚsubr»rÔrDÚCallablerFÚnot_ÚposÚnegrÀrrrÚgerÚlerýr¼rr,rr2rCrJrr‰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ÿrrrrrrrrr
rrr
rrrrrrrrrrrrrrÚstaticmethodr-rrrrÚ<module>sÖ,(.2		


			.0