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
3

U'ícîˆã@s2dZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddl	mZdd	l
mZdd
l
mZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZejdƒZejdej dej!fdZ"ej#rNddl$Z$ddl%Z&ddl'm(Z(Gdd„de&j)ƒZ*dddd d!d"d#d$d%d&d'd(d)d*d+gZ+d,d-d.gZ,eed/œd0d'„Z-ej.ej!e/d1œd2d%„Z0ej.ej!e/d1œd3d&„Z1ej.ej!e/d1œd4d5„Z2dQd7ej3e/ej4e/ej d8gej5e/ffej3ej4e/ej!fe6ej3ej7e/ej!fej3ej8e/ej!fd8d9œd:d;„Z9Gd<d„dƒZ:e"e"d=œd>d?„Z;ej8j<Gd@d8„d8ƒƒZ=GdAdB„dBƒZ>GdCd„dƒZ?GdDd,„d,e?ƒZ@GdEd„dƒZAGdFd*„d*ƒZBdeBfej3dGejCeBejCeBdHœdIdJ„ZDGdKdL„dLeBƒZEGdMdN„dNeBƒZFGdOdP„dPeBƒZGeB`HeE`HeF`HeG`HdS)Rz;The runtime functions and state used by compiled templates.éN)Úabc)Úchain)Úescape)ÚMarkup)Úsoft_stré)Ú
auto_aiter)Ú
auto_await)ÚTemplateNotFound)ÚTemplateRuntimeError)ÚUndefinedError)ÚEvalContext)Ú_PassArg)Úconcat)Úinternalcode)Úmissing)Ú	Namespace)Úobject_type_repr)Úpass_eval_contextÚVÚF.)Zbound)ÚEnvironmentc@s(eZdZdejedeedœdd„ZdS)ÚLoopRenderFuncr)ÚreciterÚloop_render_funcÚdepthÚreturncCsdS)N©)Úselfrrrrrú0/tmp/pip-build-gk9425m9/Jinja2/jinja2/runtime.pyÚ__call__#szLoopRenderFunc.__call__N)r)	Ú__name__Ú
__module__Ú__qualname__ÚtÚIterablerÚintÚstrr rrrrr"srÚLoopContextÚTemplateReferenceÚMacrorrrrrÚmarkup_joinÚstr_joinÚidentityr
rÚ	UndefinedrÚAsyncLoopContextrr	)ÚxrcCs|S)zLReturns its argument. Useful for certain things in the
    environment.
    r)r0rrrr-Es)ÚseqrcCsLg}tt|ƒ}x4|D],}|j|ƒt|dƒrtdƒjt||ƒƒSqWt|ƒS)z?Concatenation that escapes if necessary and converts to string.Ú__html__Ú)ÚmaprÚappendÚhasattrrÚjoinrr)r1ÚbufÚiteratorÚargrrrr+Ls



cCsttt|ƒƒS)z3Simple args to string conversion and concatenation.)rr4r')r1rrrr,WscCs ddl}|jdtddt|ƒS)NrzWThis template must be recompiled with at least Jinja 3.0, or it will fail in Jinja 3.1.é)Ú
stacklevel)ÚwarningsÚwarnÚDeprecationWarningr,)r1r=rrrÚunicode_join\sr@FrÚContext)ÚenvironmentÚ
template_nameÚblocksÚvarsÚsharedÚglobalsÚlocalsrc
Csp|dkri}|r|}nt|pff|Ž}|r\|r6t|ƒ}x$|jƒD]\}}	|	tk	r@|	||<q@W|j|||||dS)z%Internal helper for context creation.N)rG)ÚdictÚitemsrZ
context_class)
rBrCrDrErFrGrHÚparentÚkeyÚvaluerrrÚnew_contexths
rNc@s@eZdZdZdddœdd„Zeejdœdd	„Zed
œdd„Z	dS)
r)zThe `self` in templates.rAN)ÚcontextrcCs
||_dS)N)Ú_TemplateReference__context)rrOrrrÚ__init__ˆszTemplateReference.__init__)ÚnamercCs|jj|}t||j|dƒS)Nr)rPrDÚBlockReference)rrRrDrrrÚ__getitem__‹szTemplateReference.__getitem__)rcCsdt|ƒj›d|jj›dS)Nú<ú ú>)Útyper!rPrR)rrrrÚ__repr__szTemplateReference.__repr__)
r!r"r#Ú__doc__rQr'r$ÚAnyrTrYrrrrr)…s)Údict_methodrcs,tjˆƒdtjdœ‡fdd„ƒ}tjt|ƒS)NrA)rrcsˆ|jƒƒS)N)Úget_all)r)r\rrÚf_all”sz_dict_method_all.<locals>.f_all)Ú	functoolsÚwrapsr$r[Úcastr)r\r^r)r\rÚ_dict_method_all“srbc
@sÆeZdZUdZdZejeddœdd„Zd)dej	e
ejfeje
ej	e
ej
dgeje
ffejeje
ejfdœd	d
„Ze
ej
dgeje
fejd*d
œdd„Zd+e
ejejdœdd„Ze
ejejdfdœdd„Ze
ejdœdd„Zej	e
ejfdœdd„Zej	e
ejfdœdd„Zeej
ejejejejdfdœdd„ƒZd,ejej	e
ejfddœd d!„ZeejƒZeejƒZeejƒZe
ed"œd#d$„Z e
ejdœd%d&„Z!e
dœd'd(„Z"dS)-rAaêThe template context holds the variables of a template.  It stores the
    values passed to the template and also the names the template exports.
    Creating instances is neither supported nor useful as it's created
    automatically at various stages of the template evaluation and should not
    be created by hand.

    The context is immutable.  Modifications on :attr:`parent` **must not**
    happen and modifications on :attr:`vars` are allowed from generated
    template code only.  Template filters and global functions marked as
    :func:`pass_context` get the active context passed as first argument
    and are allowed to access the context read-only.

    The template context supports read only dict operations (`get`,
    `keys`, `values`, `items`, `iterkeys`, `itervalues`, `iteritems`,
    `__getitem__`, `__contains__`).  Additionally there is a :meth:`resolve`
    method that doesn't fail with a `KeyError` but returns an
    :class:`Undefined` object for missing variables.
    FN)rcCsDd|jkrd|_n.d|jks"|jr@ddl}|jdtddd|_dS)	NÚresolve_or_missingFÚresolverzOverriding 'resolve' is deprecated and will not have the expected behavior in Jinja 3.1. Override 'resolve_or_missing' instead r;)r<T)Ú__dict__Ú_legacy_resolve_moder=r>r?)Úclsr=rrrÚ__init_subclass__²s
zContext.__init_subclass__r)rBrKrRrDrGcCs^||_i|_||_t|j|ƒ|_tƒ|_||_|dkr<tƒnt|ƒ|_dd„|j	ƒDƒ|_
dS)NcSsi|]\}}|g|“qSrr)Ú.0ÚkÚvrrrú
<dictcomp>Øsz$Context.__init__.<locals>.<dictcomp>)rKrErBr
Úeval_ctxÚsetÚ
exported_varsrRZglobals_keysrJrD)rrBrKrRrDrGrrrrQÅszContext.__init__rSr.)rRÚcurrentrc
Cs\y$|j|}|j|ƒd}||Wn(tk
rL|jjd|›dddSXt||||ƒS)zRender a parent block.rz there is no parent block called Ú.Úsuper)rR)rDÚindexÚLookupErrorrBÚ	undefinedrS)rrRrprDrsrrrrrÚs
z
Context.super)rLÚdefaultrcCs"y||Stk
r|SXdS)zÑLook up a variable by name, or return a default if the key is
        not found.

        :param key: The variable name to look up.
        :param default: The value to return if the key is not found.
        N)ÚKeyError)rrLrvrrrÚgetèszContext.get)rLrcCs`|jr<||jkr|j|S||jkr.|j|S|jj|dS|j|ƒ}|tkr\|jj|dS|S)aNLook up a variable by name, or return an :class:`Undefined`
        object if the key is not found.

        If you need to add custom behavior, override
        :meth:`resolve_or_missing`, not this method. The various lookup
        functions use that method, not this one.

        :param key: The variable name to look up.
        )rR)rfrErKrBrurcr)rrLÚrvrrrrdôs





zContext.resolvecCsN|jr"|j|ƒ}t|tƒrtS|S||jkr6|j|S||jkrJ|j|StS)aNLook up a variable by name, or return a ``missing`` sentinel
        if the key is not found.

        Override this method to add custom lookup behavior.
        :meth:`resolve`, :meth:`get`, and :meth:`__getitem__` use this
        method. Don't call this method directly.

        :param key: The variable name to look up.
        )rfrdÚ
isinstancer.rrErK)rrLryrrrrcs






zContext.resolve_or_missingcs‡fdd„ˆjDƒS)z+Get a new dict with the exported variables.csi|]}ˆj||“qSr)rE)rirj)rrrrl*sz(Context.get_exported.<locals>.<dictcomp>)ro)rr)rrÚget_exported(szContext.get_exportedcCs(|js|jS|js|jSt|jf|jŽS)z»Return the complete context as dict including the exported
        variables.  For optimizations reasons this might not return an
        actual copy so be careful with using it.
        )rErKrI)rrrrr],s
zContext.get_all)Ú
_Context__objÚargsÚkwargsrcOsæd}t|dƒr$tj|jƒdk	r$|j}tj|ƒ}|tjkrt|jdƒrP|j|dƒ}|jdƒrh|j|dƒ}|f|}n.|tjkrŒ|jf|}n|tj	kr¢|j	f|}|j
ddƒ|j
ddƒy
|||ŽStk
rà|j	jdƒSXdS)zéCall the callable with the arguments and keyword arguments
        provided but inject the active context or environment as first
        argument if the callable has :func:`pass_context` or
        :func:`pass_environment`.
        Tr NZ
_loop_varsZ_block_varszGvalue was undefined because a callable raised a StopIteration exception)
r6rZfrom_objr rOrxÚderivedZeval_contextrmrBÚpopÚ
StopIterationru)Z_Context__selfr|r}r~Z__traceback_hide__Zpass_argrrrÚcall7s,








zContext.call)rHrcCsDt|j|ji|jƒdd|ƒ}|j|_|jjdd„|jjƒDƒƒ|S)z¹Internal helper function to create a derived context.  This is
        used in situations where the system needs a new context in the same
        template that is independent.
        TNcss|]\}}|t|ƒfVqdS)N)Úlist)rirjrkrrrú	<genexpr>msz"Context.derived.<locals>.<genexpr>)rNrBrRr]rmrDÚupdaterJ)rrHrOrrrrds
zContext.derived)rRrcCs||jkp||jkS)N)rErK)rrRrrrÚ__contains__tszContext.__contains__cCs|j|ƒ}|tkrt|ƒ‚|S)zpLook up a variable by name with ``[]`` syntax, or raise a
        ``KeyError`` if the key is not found.
        )rcrrw)rrLÚitemrrrrTws
zContext.__getitem__cCs$dt|ƒj›d|jƒ›d|j›dS)NrUrVz of rW)rXr!r]rR)rrrrrY‚szContext.__repr__)N)rSr.)N)N)#r!r"r#rZrfr$ZClassVarÚboolrhÚDictr'r[ÚOptionalÚCallableÚIteratorÚMutableMappingrQÚUnionrrrxrdrcr{r]rr‚rrbrIÚkeysÚvaluesrJr†rTrYrrrrrA›s*
X*$


c@szeZdZdZedejejdgejefe	ddœdd„Z
eejddœd	d
„ƒZ
eedœdd„ƒZeedœd
d„ƒZdS)rSz"One block on a template reference.rAN)rRrOÚstackrrcCs||_||_||_||_dS)N)rRÚ_contextÚ_stackÚ_depth)rrRrOr‘rrrrrQ‰szBlockReference.__init__r.)rcCsJ|jdt|jƒkr0|jjjd|j›dddSt|j|j|j|jdƒS)zSuper the block.rz there is no parent block called rqrr)rR)r”Úlenr“r’rBrurRrS)rrrrrr•szBlockReference.supercÃs@tdd„|j|j|jƒ2dHƒIdHƒ}|jjjr<t|ƒS|S)Nc
Ós.g|y3dH}Wn
tk
s"X|‘qYS)N)ÚStopAsyncIteration)rir0rrrú
<listcomp>¡sz.BlockReference._async_call.<locals>.<listcomp>)rr“r”r’rmÚ
autoescaper)rryrrrÚ_async_callžs
(
zBlockReference._async_callcCs>|jjjr|jƒSt|j|j|jƒƒ}|jjjr:t	|ƒS|S)N)
r’rBÚis_asyncr™rr“r”rmr˜r)rryrrrr ©s

zBlockReference.__call__)rSr.)r!r"r#rZr'r$ÚListr‹rŒr&rQÚpropertyrŽrrrr™r rrrrrS†s
rSc@sàeZdZUdZd2ZdZejee	Z
ej
e	Zeje	Z
ej
e	Zejd3ejeejdejdeddœdd	„Zeejeejed
œdd„ƒZeed
œdd„ƒZed
œdd„Zeed
œdd„ƒZeed
œdd„ƒZeed
œdd„ƒZeed
œdd„ƒZeed
œdd„ƒZejd
œdd„Zeed
œdd„ƒZ eej!ejdfd
œd d!„ƒZ"eej!ejdfd
œd"d#„ƒZ#eed$œd%d&„Z$ejed'œd(d)„Z%dd
œd*d+„Z&ej'ejdfd
œd,d-„Z(e)ejee*d
œd.d/„ƒZ+e*d
œd0d1„Z,dS)4r(zeA wrapper iterable for dynamic ``for`` loops, with information
    about the loop and iteration.
    rNrr.r)ÚiterableruÚrecurseÚdepth0rcCs(||_|j|ƒ|_||_||_||_dS)a@
        :param iterable: Iterable to wrap.
        :param undefined: :class:`Undefined` class to use for next and
            previous items.
        :param recurse: The function to render the loop body when the
            loop is marked recursive.
        :param depth0: Incremented when looping recursively.
        N)Ú	_iterableÚ_to_iteratorÚ	_iteratorÚ
_undefinedÚ_recurserŸ)rrruržrŸrrrrQÄs
zLoopContext.__init__)rrcCst|ƒS)N)Úiter)rrrrr¡ÚszLoopContext._to_iterator)rcCsl|jdk	r|jSyt|jƒ|_WnDtk
rdt|jƒ}|j|ƒ|_t|ƒ|j|jt	k	|_YnX|jS)zšLength of the iterable.

        If the iterable is a generator or otherwise does not have a
        size, it is eagerly evaluated to get a size.
        N)
Ú_lengthr•r Ú	TypeErrorrƒr¢r¡rsÚ_afterr)rrrrrÚlengthÞs

 zLoopContext.lengthcCs|jS)N)r©)rrrrÚ__len__ñszLoopContext.__len__cCs
|jdS)zBHow many levels deep a recursive loop currently is, starting at 1.r)rŸ)rrrrrôszLoopContext.depthcCs
|jdS)z-Current iteration of the loop, starting at 1.r)Úindex0)rrrrrsùszLoopContext.indexcCs|j|jS)zrNumber of iterations from the end of the loop, ending at 0.

        Requires calculating :attr:`length`.
        )r©rs)rrrrÚ	revindex0þszLoopContext.revindex0cCs|j|jS)zrNumber of iterations from the end of the loop, ending at 1.

        Requires calculating :attr:`length`.
        )r©r«)rrrrÚrevindexszLoopContext.revindexcCs
|jdkS)z0Whether this is the first iteration of the loop.r)r«)rrrrÚfirstszLoopContext.firstcCs$|jtk	r|jSt|jtƒ|_|jS)aReturn the next element in the iterable, or :data:`missing`
        if the iterable is exhausted. Only peeks one item ahead, caching
        the result in :attr:`_last` for use in subsequent checks. The
        cache is reset when :meth:`__next__` is called.
        )r¨rÚnextr¢)rrrrÚ
_peek_nexts
zLoopContext._peek_nextcCs|jƒtkS)zÞWhether this is the last iteration of the loop.

        Causes the iterable to advance early. See
        :func:`itertools.groupby` for issues this can cause.
        The :func:`groupby` filter avoids that issue.
        )r°r)rrrrÚlastszLoopContext.lastcCs|jr|jdƒS|jS)zZThe item in the previous iteration. Undefined during the
        first iteration.
        zthere is no previous item)r®r£Ú_before)rrrrÚprevitem)s
zLoopContext.previtemcCs|jƒ}|tkr|jdƒS|S)a	The item in the next iteration. Undefined during the last
        iteration.

        Causes the iterable to advance early. See
        :func:`itertools.groupby` for issues this can cause.
        The :func:`jinja-filters.groupby` filter avoids that issue.
        zthere is no next item)r°rr£)rryrrrÚnextitem3s	
zLoopContext.nextitem)r}rcGs|stdƒ‚||jt|ƒS)z¤Return a value from the given args, cycling through based on
        the current :attr:`index0`.

        :param args: One or more values to cycle through.
        zno items for cycling given)r§r«r•)rr}rrrÚcycleCszLoopContext.cycle)rMrcGs|j|kr||_dSdS)z¿Return ``True`` if previously called with a different value
        (including when called for the first time).

        :param value: One or more values to compare to the last call.
        TF)Ú_last_changed_value)rrMrrrÚchangedNs
zLoopContext.changedcCs|S)Nr)rrrrÚ__iter__ZszLoopContext.__iter__cCsF|jtk	r|j}t|_n
t|jƒ}|jd7_|j|_||_||fS)Nr)r¨rr¯r¢r«Ú_currentr²)rryrrrÚ__next__]s

zLoopContext.__next__cCs&|jdkrtdƒ‚|j||j|jdS)zÄWhen iterating over nested data, render the body of the loop
        recursively with the given inner iterable data.

        The loop must have the ``recursive`` marker for this to work.
        NzCThe loop must have the 'recursive' marker to be called recursively.)r)r¤r§r)rrrrrr is
zLoopContext.__call__cCs"dt|ƒj›d|j›d|j›dS)NrUrVú/rW)rXr!rsr©)rrrrrYwszLoopContext.__repr__éÿÿÿÿ)Nr)-r!r"r#rZr«r¦r$rŠr&rr¨r[r¹r²r¶r%rÚTyperQÚstaticmethodrŒr¡rœr©rªrrsr¬r­rˆr®r°r±rŽr³r´rµr·r¸ÚTuplerºrr'r rYrrrrr(¶sN




		
c@sèeZdZUejejeejej	e
eje
feje
dœdd„ƒZe
edœdd„ƒZe
edœdd„ƒZe
edœd	d
„ƒZejdœdd„Ze
edœd
d„ƒZe
ejejdfdœdd„ƒZddœdd„Zejejdfdœdd„ZdS)r/)rrcCst|ƒS)N)r)rrrrr¡~szAsyncLoopContext._to_iterator)rcÃs||jdk	r|jSyt|jƒ|_WnTtk
rtdd„|j2dHƒIdH}|j|ƒ|_t|ƒ|j|jtk	|_YnX|jS)Nc
Ós.g|y3dH}Wn
tk
s"X|‘qYS)N)r–)rir0rrrr—Œsz+AsyncLoopContext.length.<locals>.<listcomp>)	r¦r•r r§r¢r¡rsr¨r)rrrrrr©„s
 zAsyncLoopContext.lengthcÃs|jIdH|jS)N)r©rs)rrrrr¬’szAsyncLoopContext.revindex0cÃs|jIdH|jS)N)r©r«)rrrrr­–szAsyncLoopContext.revindexcÃsH|jtk	r|jSy|jjƒIdH|_Wntk
r@t|_YnX|jS)N)r¨rr¢Ú	__anext__r–)rrrrr°šs
zAsyncLoopContext._peek_nextcÃs|jƒIdHtkS)N)r°r)rrrrr±¥szAsyncLoopContext.lastr.cÃs$|jƒIdH}|tkr |jdƒS|S)Nzthere is no next item)r°rr£)rryrrrr´©s
zAsyncLoopContext.nextitemcCs|S)Nr)rrrrÚ	__aiter__²szAsyncLoopContext.__aiter__cÃsL|jtk	r|j}t|_n|jjƒIdH}|jd7_|j|_||_||fS)Nr)r¨rr¢rÀr«r¹r²)rryrrrrÀµs
zAsyncLoopContext.__anext__N)r!r"r#r$Ú
AsyncIteratorr[r¢r¾rŽr%rÚ
AsyncIterabler¡rœr&r©r¬r­r°rˆr±r´rÁr¿rÀrrrrr/{s"

c
@s¤eZdZdZddejdefeejeeeeej	edœdd„Z
eeej
ej
edœd	d
„ƒƒZejej
eedœdd
„Zejej
eedœdd„Zedœdd„ZdS)r*zWraps a macro function.Nr.)rBÚfuncrRÚ	argumentsÚcatch_kwargsÚ
catch_varargsÚcallerÚdefault_autoescapec		Csl||_||_t|ƒ|_||_||_||_||_||_d|k|_	|dkrbt
|jƒr\|jdƒ}n|j}||_dS)NrÈ)
Ú_environmentÚ_funcr•Ú_argument_countrRrÅrÆrÇrÈÚexplicit_callerÚcallabler˜Ú_default_autoescape)	rrBrÄrRrÅrÆrÇrÈrÉrrrrQÅs


zMacro.__init__)r}r~rc
Os |r*t|dtƒr*|dj}|dd…}n|j}t|d|j…ƒ}t|ƒ}d}||jkr´x`|jt|ƒd…D]B}y|j|ƒ}Wnt	k
r–t
}YnX|dkr¤d}|j|ƒqlWn|j}|j
rô|rô|jddƒ}	|	dkrê|jjddd}	|j|	ƒ|jr|j|ƒn@|rHd|kr*td|j›d	ƒ‚td|j›d
tt|ƒƒ›ƒ‚|jrf|j||jd…ƒn.t|ƒ|jkr”td|j›dt|jƒ›dƒ‚|j||ƒS)
NrrFrÈTzNo caller defined)rRzmacro zX was invoked with two values for the special caller argument. This is most likely a bug.z takes no keyword argument z takes not more than z argument(s))rzr
r˜rÏrƒrÌr•rÅr€rwrr5rÍrÈrÊrurÆr§rRr¯r¥rÇÚ_invoke)
rr}r~r˜rÅÚoffZfound_callerrRrMrÈrrrr âsH




zMacro.__call__)rÅr˜rcÃs |j|ŽIdH}|rt|ƒS|S)N)rËr)rrÅr˜ryrrrÚ
_async_invoke0szMacro._async_invokecCs.|jjr|j||ƒS|j|Ž}|r*t|ƒ}|S)N)rÊršrÒrËr)rrÅr˜ryrrrrÐ8s
z
Macro._invoke)rcCs0|jdkrdnt|jƒ}dt|ƒj›d|›dS)NZ	anonymousrUrVrW)rRÚreprrXr!)rrRrrrrYCszMacro.__repr__)N)r!r"r#rZr$r‹r'r›rˆrŠrQrrr[r rÒrÐrYrrrrr*Âs4Lc@sŒeZdZdZd'Zdedefeje	ej
eje	ejeddœdd	„Z
ee	d
œdd„ƒZeej
ej
d
dœdd„ƒZee	ej
dœdd„ƒZeZZZZeZZZZeZZeZZeZZ eZ!Z"eZ#Z$eZ%Z&Z'Z(eZ)Z*Z+eZ,Z-ej
e.dœdd„Z/ej
e.dœdd„Z0e1d
œdd„Z2e	d
œdd„Z3e1d
œdd„Z4ej5ej
d
œdd „Z6ej7ej
d
œd!d"„Z8e.d
œd#d$„Z9e	d
œd%d&„Z:dS)(r.ahThe default undefined type.  This undefined type can be printed and
    iterated over, but every other access will raise an :exc:`UndefinedError`:

    >>> foo = Undefined(name='foo')
    >>> str(foo)
    ''
    >>> not foo
    True
    >>> foo + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    Ú_undefined_hintÚ_undefined_objÚ_undefined_nameÚ_undefined_exceptionN)ÚhintÚobjrRÚexcrcCs||_||_||_||_dS)N)rÔrÕrÖr×)rrØrÙrRrÚrrrrQ^szUndefined.__init__)rcCsZ|jr|jS|jtkr"|j›dSt|jtƒsDt|jƒ›d|j›St|jƒ›d|j›S)zXBuild a message about the undefined value based on how it was
        accessed.
        z
 is undefinedz has no element z has no attribute )rÔrÕrrÖrzr'r)rrrrÚ_undefined_messagejs
zUndefined._undefined_messagezte.NoReturn)r}r~rcOs|j|jƒ‚dS)zeRaise an :exc:`UndefinedError` when operations are performed
        on the undefined value.
        N)r×rÛ)rr}r~rrrÚ_fail_with_undefined_error€sz$Undefined._fail_with_undefined_error)rRrcCs |dd…dkrt|ƒ‚|jƒS)Nr;Ú__)ÚAttributeErrorrÜ)rrRrrrÚ__getattr__‰szUndefined.__getattr__)ÚotherrcCst|ƒt|ƒkS)N)rX)rràrrrÚ__eq__›szUndefined.__eq__cCs|j|ƒS)N)rá)rràrrrÚ__ne__žszUndefined.__ne__cCstt|ƒƒS)N)ÚidrX)rrrrÚ__hash__¡szUndefined.__hash__cCsdS)Nr3r)rrrrÚ__str__¤szUndefined.__str__cCsdS)Nrr)rrrrrª§szUndefined.__len__ccsfEdHdS)Nr)rrrrr¸ªszUndefined.__iter__cCsxfD]
}dVqWdS)Nr)rÚ_rrrrÁ­s
zUndefined.__aiter__cCsdS)NFr)rrrrÚ__bool__±szUndefined.__bool__cCsdS)Nr.r)rrrrrY´szUndefined.__repr__)rÔrÕrÖr×);r!r"r#rZÚ	__slots__rrr$rŠr'r[r½rrQrœrÛrrÜrßÚ__add__Ú__radd__Ú__sub__Ú__rsub__Ú__mul__Ú__rmul__Z__div__Z__rdiv__Ú__truediv__Ú__rtruediv__Ú__floordiv__Ú
__rfloordiv__Ú__mod__Ú__rmod__Ú__pos__Ú__neg__r rTÚ__lt__Ú__le__Ú__gt__Ú__ge__Ú__int__Ú	__float__Ú__complex__Ú__pow__Ú__rpow__rˆrárâr&rärårªrŒr¸rÂrÁrçrYrrrrr.HsH
 zlogging.Logger)ÚloggerÚbasercsZˆdkr,ddl}|jtƒ‰ˆj|jtjƒƒtddœ‡fdd„‰G‡‡fdd„d|ƒ}|S)akGiven a logger object this returns a new undefined class that will
    log certain failures.  It will log iterations and printing.  If no
    logger is given a default logger is created.

    Example::

        logger = logging.getLogger(__name__)
        LoggingUndefined = make_logging_undefined(
            logger=logger,
            base=Undefined
        )

    .. versionadded:: 2.8

    :param logger: the logger to use.  If not provided, a default logger
                   is created.
    :param base: the base class to add logging functionality to.  This
                 defaults to :class:`Undefined`.
    Nr)Úundefrcsˆjd|jƒdS)NzTemplate variable warning: %s)ÚwarningrÛ)r)rrrÚ_log_messageÔsz,make_logging_undefined.<locals>._log_messagecsteZdZfZejejddœ‡‡fdd„Zedœ‡‡fdd„Zej	ejdœ‡‡fdd	„Z
edœ‡‡fd
d„Z‡Z
S)z0make_logging_undefined.<locals>.LoggingUndefinedzte.NoReturn)r}r~rcsLytƒj||ŽWn4|jk
rF}zˆjd|ƒ|‚WYdd}~XnXdS)NzTemplate variable error: %s)rrrÜr×Úerror)rr}r~Úe)Ú	__class__rrrrÜÜs
zKmake_logging_undefined.<locals>.LoggingUndefined._fail_with_undefined_error)rcsˆ|ƒtƒjƒS)N)rrrå)r)rrrrrååsz8make_logging_undefined.<locals>.LoggingUndefined.__str__csˆ|ƒtƒjƒS)N)rrr¸)r)rrrrr¸ész9make_logging_undefined.<locals>.LoggingUndefined.__iter__csˆ|ƒtƒjƒS)N)rrrç)r)rrrrrçísz9make_logging_undefined.<locals>.LoggingUndefined.__bool__)r!r"r#rèr$r[rÜr'rårŒr¸rˆrçÚ
__classcell__r)rr)rrÚLoggingUndefinedÙsr	)ÚloggingÚ	getLoggerr!Ú
addHandlerÚ
StreamHandlerÚsysÚstderrr.)rrr
r	r)rrrÚmake_logging_undefined¸s
rc@s6eZdZdZfZedœdd„Zeddœdd„ZeZdS)	ÚChainableUndefinedaŒAn undefined that is chainable, where both ``__getattr__`` and
    ``__getitem__`` return itself rather than raising an
    :exc:`UndefinedError`.

    >>> foo = ChainableUndefined(name='foo')
    >>> str(foo.bar['baz'])
    ''
    >>> foo.bar['baz'] + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined

    .. versionadded:: 2.11.0
    )rcCst|ƒS)N)r')rrrrr2szChainableUndefined.__html__)rærcCs|S)Nr)rrærrrrß	szChainableUndefined.__getattr__N)	r!r"r#rZrèr'r2rßrTrrrrrôs
rc@s"eZdZdZfZedœdd„ZdS)ÚDebugUndefinedaAn undefined that returns the debug info when printed.

    >>> foo = DebugUndefined(name='foo')
    >>> str(foo)
    '{{ foo }}'
    >>> not foo
    True
    >>> foo + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    )rcCsL|jrd|j›}n,|jtkr&|j}ndt|jƒ›d|j›d}d|›dS)Nzundefined value printed: zno such element: ú[ú]z{{ z }})rÔrÕrrÖr)rÚmessagerrrrås
zDebugUndefined.__str__N)r!r"r#rZrèr'rårrrrrsrc@s:eZdZdZfZejZZZ	ejZ
ZZZ
ejZdS)ÚStrictUndefinedasAn undefined that barks on print and iteration as well as boolean
    tests and all kinds of comparisons.  In other words: you can do nothing
    with it except checking if it's defined using the `defined` test.

    >>> foo = StrictUndefined(name='foo')
    >>> str(foo)
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    >>> not foo
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    >>> foo + 42
    Traceback (most recent call last):
      ...
    jinja2.exceptions.UndefinedError: 'foo' is undefined
    N)r!r"r#rZrèr.rÜr¸rårªrárârçrär†rrrrr/s
r)NFNN)IrZr_rÚtypingr$ÚcollectionsrÚ	itertoolsrZ
markupsaferrrZasync_utilsrr	Ú
exceptionsr
rrZnodesr
ÚutilsrrrrrrrZTypeVarrr‹r[rZ
TYPE_CHECKINGr
Ztyping_extensionsÚterBrZProtocolrZexportedZasync_exportedr-r%r'r+r,r@rŠr‰rŒrˆrÚMappingrNr)rbÚregisterrArSr(r/r*r.r½rrrrrèrrrrÚ<module>s–
hl0FGq: