RL i! dZddlZddlmZddlmZddlmZddl m Z ddl m Z ddlmZdd lmZd d lmZd d lmZd d lmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlm Z d dl!m"Z"ejFr ddl$Z%d dl&m'Z'ejPdejRdejTfZ+dddddd d!d"d#Z,d$e+d%e+fd&Z-d'e.d%ejRd(ej^d)gdffd*Z0d'e.d%ejRd(ejbd)gdffd+Z2 dFd,ejfd-d.d/ejhe.d0ejhe.d1ejhejjd2e6d3e6d%ejhe.fd4Z7d5ejTd%e6fd6Z8d7ejrejtd8ejre.d%ejve.fd9Z<Gd:d;Z=Gd<d)Z>Gd=d>e?Z@Gd?d@e"ZAGdAdBe"ZBGdCdDeCZDGdEd(e"ZEy)Gz0Compiles nodes from the parser into Python code.N)contextmanager)update_wrapper)StringIO)chain) iskeyword)escape)Markup)nodes)TemplateAssertionError)Symbols)VAR_LOAD_ALIAS)VAR_LOAD_PARAMETER)VAR_LOAD_RESOLVE)VAR_LOAD_UNDEFINED) EvalContext) Optimizer)_PassArg)concat) NodeVisitor) EnvironmentF.)boundz==z!=>z>=.new_func.sb >> %enn.E.E~~++D%..AH4zz(E22tU-f--)r ExprtAnyr)r$r5s` r4 optimizeconstr:-sK . .%*ZZ .8? .KL55 .  . (A &&r6opr(r+c Ztdddtjdtddffd }|S)Nr'r(r)r*r%c|jjrw|jjvr_|jdd|j |j ||jd|j |j |n^|jd|j |j ||jdd|j |j ||jdy)Nz environment.call_binop(context, , ( )) environment sandboxedintercepted_binopswriter2leftrightr'r)r*r;s r4visitorz_make_binop..visitor>s    & &21A1A1T1T+T JJ9"rB C JJtyy% ( JJt  JJtzz5 ) JJsO JJtyy% ( JJ2$ay ! JJtzz5 ) 3r6)r:r BinExprr+r;rIs` r4 _make_binoprL=s<oU]]5T Nr6c Ztdddtjdtddffd }|S)Nr'r(r)r*r%cH|jjrJ|jjvr2|jdd|j |j |n0|jdz|j |j ||jdy)Nzenvironment.call_unop(context, r>r?rA)rBrCintercepted_unopsrEr2r)rHs r4rIz_make_unop..visitorUs|    & &21A1A1S1S+S JJ8bA B JJtyy% ( JJsRx JJtyy% ( 3r6)r:r UnaryExprr+rKs` r4 _make_unoprQRs> o U__ U t   Nr6r)rBrnamefilenamestream defer_init optimizedct|tjs td|j ||||||}|j |||j jSy)z+Generate the python source for a node tree.z Can't compile non template nodesN) isinstancer Template TypeErrorcode_generator_classr2rTgetvalue)r)rBrRrSrTrUrV generators r4generater^esf dENN +:;;00T8VZIOOD ~((** r6valuecT||tus|turyt|ttt t ttthvryt|tttthvrtd|DSt|tur td|j!DSy)z)Does the node have a safe representation?Tc32K|]}t|ywr. has_safe_repr).0vs r4 z has_safe_repr..s3=#3sc3RK|]\}}t|xr t|!ywr.rbrdkres r4rfz has_safe_repr..s&STQ=#8 a(88Ss%'F)NotImplementedEllipsistypeboolintfloatcomplexrangestrr tuplelistset frozensetalldictitemsr_s r4rcrc}s }/5H3D E{tS%%fEE E{udC333U333 E{dSU[[]SSS r6r namesct|} |D]}|j| |jS#t$rY|jSwxYw)zCheck if the names passed are accessed undeclared. The return value is a set of all the undeclared names from the sequence of names found. )UndeclaredNameVisitorr2 VisitorExit undeclared)r r{rIr)s r4find_undeclaredrs\ $E*G  D MM$           s2 A A cbeZdZdejej ejfddfdZy)MacroRefr)r%Nc<||_d|_d|_d|_yNF)r)accesses_calleraccesses_kwargsaccesses_varargsr'r)s r4__init__zMacroRef.__init__s! $$ %r6) __name__ __module__ __qualname__r8Unionr Macro CallBlockrr6r4rrs+&QWWU[[%//%AB&t&r6rc eZdZdZ d dedej ddej eddfdZd dZ dd e ddfd Z d d Z e Z y)r+z&Holds compile time information for us.Nr0parentlevelr%cV||_||_|'t||_d|_d|_d|_nOt|j||_|j|_|j |_|j |_d|_d|_d|_ d|_ d|_ y)NrF) r0rr symbolsrequire_output_checkbufferblocktoplevel rootlevel loop_frame block_frame soft_frame)r'r0rrs r4rzFrame.__init__s !  >"/DL).D % ,0DK+/DJ#6>>?DL(.(C(CD % --DKDJ     r6ctj|j}|jj |j|j j |_|S)z!Create a copy of the current one.)object__new__ __class____dict__updatercopyr'rvs r4rz Frame.copysC ^^DNN + 4==)\\&&(  r6isolatedc|r.t|j|jjdzSt|j|S)zReturn an inner frame.r r)r+r0rr)r'rs r4innerz Frame.inners6 dll.@.@1.DE ET]]D))r6cB|j}d|_d|_|S)a&Return a soft frame. A soft frame may not be modified as standalone thing as it shares the resources with the frame it was created of, but it's not a rootlevel frame any longer. This is only used to implement if-statements and conditional expressions. FT)rrrrs r4softz Frame.softs"YY[   r6)NN)r%zte.SelfF)rrr__doc__rr8Optionalrnrrrmrr__copy__rr6r4r+r+sn0 '+!% 1 1  7#1 zz# 1  1 f*d*w* Hr6ceZdZdZy)r~z?Exception used by the `UndeclaredNameVisitor` to signal a stop.Nrrrrrr6r4r~r~sIr6r~ceZdZdZd dZdej ddfdZdejddfdZ dejddfdZ y) DependencyFinderVisitorz.A visitor that collects filter and test calls.r%Nc@t|_t|_yr.)rufilterstestsr's r4rz DependencyFinderVisitor.__init__s#&5 !$ r6r)cp|j||jj|jyr.) generic_visitraddrRrs r4 visit_Filterz$DependencyFinderVisitor.visit_Filters& 4  #r6cp|j||jj|jyr.)rrrrRrs r4 visit_Testz"DependencyFinderVisitor.visit_Tests$ 4  tyy!r6cy)zStop visiting at blocks.Nrrs r4 visit_Blockz#DependencyFinderVisitor.visit_Block r6r%N) rrrrrr FilterrTestrBlockrrr6r4rrsO8'$$$$"uzz"d"' ''r6rceZdZdZdej eddfdZdejddfdZ dejddfdZ y) r}zA visitor that checks if a name is accessed without being declared. This is different from the frame visitor as it will not stop at closure frames. r{r%NcBt||_t|_yr.)rur{r)r'r{s r4rzUndeclaredNameVisitor.__init__sZ &)er6r)c.|jdk(ra|j|jvrI|jj |j|j|jk(r t y|jj |jy)Nload)ctxrRr{rrr~discardrs r4 visit_Namez UndeclaredNameVisitor.visit_Namesh 88v $))tzz"9 OO   *$**,!m#- JJ  tyy )r6cy)zStop visiting a blocks.Nrrs r4rz!UndeclaredNameVisitor.visit_Block!rr6) rrrrr8Iterablerrrr Namerrrrr6r4r}r}sP ,ajjo,$,*uzz*d*& &&r6r}ceZdZdZy) CompilerExitzRaised if the compiler encountered a situation where it just doesn't make sense to further process the code. Any block that raises such an exception is not further processed. Nrrr6r4rr%sr6rcZeZdZU ddddejedejedejej deded dfd Ze d efd Z d ed e d dfdZ d efdZ ded dfdZ ddeded dfdZddZdde d dfdZddedejej(d dfdZded dfdZ ddededejej(d dfdZdej0ej(ded dfdZded dfd Z ddedejej(d!e d dfd"Zddejej(d!e d dfd#Z ddej:ej<ej>ej@fded$ejejBeejDfd dfd%Z#dej0ej(d dfd&Z$ded dfd'Z%dded(ed dfd)Z&dd*ed+ed efd,Z'ded efd-Z(dej:ejRejTfded ejVee,ffd.Z-d/e,ded dfd0Z.dej(d efd1Z/ded efd2Z0dd3Z1ded dfd4Z2dd5Z3d6ed dfd7Z4d6ed dfd8Z5dd9Z6d efd:Z7d efd;Z8ded efd<Z9d6ed efd=Z:dd>Z;ded dfd?Z< ddejzdejed dfd@Z>dej~ded dfdAZ@dejded dfdBZBdejded dfdCZDdej:ejejfded dfdDZGdejded dfdEZHdejded dfdFZIdejded dfdGZKdejded dfdHZMdejRded dfdIZNdejTded dfdJZOdejded dfdKZQdejded dfdLZSdejded dfdMZUGdNdOejZWeXdPejDd ejDfdQZYdZZejeWe[dR<d eWfdSZ\dTej0ejDd efdUZ]dejdedVeWd efdWZ_dejdedVeWd dfdXZ`dejdedVeWd dfdYZadejded dfdZZcdejded dfd[Zedejded dfd\Zgdejded dfd]Zidejded dfd^Zkdejded dfd_Zmdejded dfd`ZodejVded dfdaZpdejded dfdbZrdejded dfdcZteuddZveudeZweudfZxeudgZyeudhZzeudiZ{eudjZ|eudkZ}eudlZ~eddZedeZedmZedejded dfdnZedej ded dfdoZdejded dfdpZedejded dfdqZedejded dfdrZdejded dfdsZedej:ej>ej@fdedted ej"dfduZedej>ded dfdvZedej@ded dfdwZedej*ded dfdxZe ddej<dedyed dfdzZdej0ded dfd{Zdej4ded dfd|Zdej8ded dfd}Zdej<ded dfd~Zdej@ded dfdZdejDded dfdZdejHded dfdZdejLded dfdZdejPded dfdZdejTded dfdZdejXded dfdZdej\ded dfdZdej`ded dfdZdejdded dfdZdejhded dfdZy)r(NrBrrRrSrTrUrVr%c| t}||_||_||_||_d|_||_d|_|rt||_i|_ i|_ d|_ d|_ d|_ i|_i|_g|_d|_d|_d|_d|_d|_d|_g|_g|_dg|_y)NFrr Tcontext)rrBrRrSrTcreated_block_contextrUr/rimport_aliasesblocksextends_so_farhas_known_extends code_linenorr debug_info_write_debug_info _new_lines _last_line _first_write_last_identifier _indentation _assign_stack_param_def_block_context_reference_stack)r'rBrRrSrTrUrVs r4rzCodeGenerator.__init__-s >ZF&    %*"$04 &{3DN1313   "'(* )+ 6826!!"2457*3 %r6c|jduSr.)r/rs r4rVzCodeGenerator.optimizedvs~~T))r6msglinenoz te.NoReturncFt|||j|j)z*Fail with a :exc:`TemplateAssertionError`.)r rRrS)r'rrs r4failzCodeGenerator.fail|s$S&$))T]]KKr6cJ|xjdz c_d|jS)zGet a new unique identifier.r t_)rrs r4temporary_identifierz"CodeGenerator.temporary_identifiers' "D))*++r6r*cj|j|_|j|jdy)z7Enable buffering for the frame from that point onwards.z = []N)rr writeliner'r*s r4rzCodeGenerator.buffers)002  %,,u-.r6force_unescapedc |s|jjr|jd|j|jd|jd|j |jd|j|jd|jd|j y|jj r |jd|jdy|jd|jdy)z(Return the buffer contents of the frame.zif context.eval_ctx.autoescape:zreturn Markup(concat())else:zreturn concat(rAN)r0r1rindentroutdent autoescape)r'r*rs r4return_buffer_contentsz$CodeGenerator.return_buffer_contentss~~&&@A !6u||nBGH w'  ~Q?@ **!6u||nBGH  ~Q78r6c.|xjdz c_y)zIndent by one.r Nrrs r4rzCodeGenerator.indents Qr6stepc.|xj|zc_y)zOutdent by step.Nr)r'rs r4rzCodeGenerator.outdents T!r6r)c|j|jd|y|j|jd|y)z%Yield or write into the frame buffer.Nyield .append()rr)r'r*r)s r4 start_writezCodeGenerator.start_writes3 <<  NN8T * NNell^84d ;r6c@|j|jdyy)z1End the writing process started by `start_write`.NrA)rrErs r4 end_writezCodeGenerator.end_writes << # JJsO $r6scl|j|||j||j|y)z4Simple shortcut for start_write + write + end_write.N)rrEr)r'rr*r)s r4 simple_writezCodeGenerator.simple_writes+ % 1  ur6r cx |jd|D]}|j||y#t$rYywxYw)zVisit a list of nodes as block in a frame. If the current frame is no buffer a dummy ``if 0: yield None`` is written automatically. passN)rr2r)r'r r*r)s r4 blockvisitzCodeGenerator.blockvisitsB  NN6 " ( 4' (   s *- 99xc|jr|js|jjd|jz|xj|jz c_|j 8|j j|j |jfd|_d|_|jjd|jzd|_|jj|y)z&Write a string into the output stream. NFz r) rrrTrErrrappendr)r'rs r4rEzCodeGenerator.writes ??$$ !!$"89  DOO3 ))5OO**D,B,BDDTDT+UV-1D* %D  KK  ft'8'88 9DO !r6extracJ|j|||j|y)z!Combination of newline and write.N)newlinerE)r'rr)r s r4rzCodeGenerator.writelines T5! 1 r6ct|jd|z|_|=|j|jk7r#|j|_|j|_yyy)z/Add one or more newlines before the next write.r N)maxrrrr)r'r)r s r4rzCodeGenerator.newlinesLdooq5y9   t >%)[[D ""kkDO!? r6 extra_kwargsctdtd|jD|xsdD}|jD]%}|j d|j ||'|se|jD]%}|j d|j ||'|/|j D]\}}|j d|d||jr-|j d|j |j||r|j|j dn|j d |jD]M}|j |jd |j |j||j dO|/|j D]\}}|j |d |d|j?|j d |j |j||j d y|j d y|j.|j d|j |j|yy)a+Writes a function call to the stream for the current node. A leading comma is added automatically. The extra keyword arguments may not include python keywords otherwise a syntax error could occur. The extra keyword arguments should be given as python dict. c3bK|]'}ttjt|)ywr.)is_python_keywordr8castrr)rdris r4rfz*CodeGenerator.signature..s'  affS!n - s-/c34K|]}|jywr.)keyrdrs r4rfz*CodeGenerator.signature..s7aAEE7rr>N=z, *z , **dict({z, **{: z}, **rA}z, **) anyrr,argsrEr2rydyn_args dyn_kwargsrr_) r'r)r*rkwarg_workaroundargkwargrr_s r4 signaturezCodeGenerator.signatures  74;;79KL   99 #C JJt  JJsE " #  ) 4  5%( )'"."4"4"63JCJJC5%123 == JJu  JJt}}e , * <( 7# ! eii]"-. 5;;. 4  !'"."4"4"66JCJJ#5'456* 7# 4??E2 3 3 __ ( JJv  JJt .)r6c t}|D]}|j||j|jdf|j|jdffD]\}}}t |D]}||vr|j ||<|j d|j|j ||d|d|d|j|j d|j|j d|j d ||d |j|j d |d d d|d|j|jy )aFind all filter and test names used in the template and assign them to variables in the compiled namespace. Checking that the names are registered with the environment is done when compiling the Filter and Test nodes. If the node is in an If or CondExpr node, the check is done at runtime instead. .. versionchanged:: 3.0 Filters and tests in If and CondExpr nodes are checked at runtime instead of compile time. rrtry:z = environment.[]zexcept KeyError:z @internalcodedef z (*unused):zraise TemplateRuntimeError("No N named z found.")) rr2rrsortedrrrr)r'r rIr)id_mapr{ dependencyrRs r4pull_dependencieszCodeGenerator.pull_dependenciess\*+ D MM$  \\7??I 6   *   %FE:u  v%#'#<#<#>F4Lv& &,zl!D8STUV 12 /fTl^:>? 5j"o5FdXY0  )  r6c g}|jjjD]\}\}}|tk(r|tk(r)|j |d|j d|dE|tk(r|j |d|e|tk(r|j|td|r$|j dj|dyy)N = r?rAzunknown load instruction = missing) rloadsryrrrget_resolve_funcrrr NotImplementedErrorjoin)r'r*undefstargetactionparams r4 enter_framezCodeGenerator.enter_frameHs',}}':':'@'@'B F #FOVU++++&T-B-B-D,EQuiqQR>)&UG45-- f%)*DEE F  NNejj01< = r6with_python_scopec|sUg}|jjD]}|j||r$|jdj |dyyy)Nr1r2)rr3r rr6)r'r*r<r7r8s r4 leave_framezCodeGenerator.leave_frameXsY F---- & f% &%**V"4!5Z@A !r6 async_value sync_valuec6|jjr|S|Sr.)rBis_async)r'r?r@s r4 choose_asynczCodeGenerator.choose_async`s"..77{GZGr6c,|jd|S)Nr))rC)r'rRs r4funczCodeGenerator.funccs##%&d4&11r6c |j}|jj|t|}d}t }g}t |j D]s\}}|jdk(r|}|jdvr|j|j|j|jj|jut|jd} d| vrZ|' |j|t|j z n*|j|jj%dd|_d| vr5d|vr1|j|jj%dd|_d| vr5d|vr1|j|jj%dd|_d |_|jj||j/|j1d d d j3|d ||j5|j7||j9||j;|t |j D]\}}|jj|j} |j/d| d|j5 |j|t|j z } |j/| d|j=| ||j?| |jA|jC|jE|j||jG|d|jI|d|jA||fS#t$r |j!d|j"YvwxYw#t$r1|j/| d|jd|jdYwxYw)z/Dump the function def of a macro or call block.Ncaller)r,varargs)rGr,rHzhWhen defining macros or call blocks the special "caller" argument must be omitted or be given a default.Tr,rHFmacror?r>):if is missing:r1z = undefined("parameter z was not provided", name=rA)rr<)%rr analyze_noderru enumeraterrRrr refrbodydefaultslen IndexErrorrrdeclare_parameterrrrrrrEr6rrr;push_parameter_definitionsr2mark_parameter_storedrpop_parameter_definitionsrrr>) r'r)r* macro_refexplicit_callerskip_special_paramsridxr"rrPdefaults r4 macro_bodyzCodeGenerator.macro_bodyfsb  ""4(TN !e!$)), 5HCxx8#"%xx00#''1 KK ))#((3 4  5%TYY0OP z !*MM/C N"BC EMM;;HEF(,I % z !h6I&I KK 77A B(,I %  "y8K'K KK 77 B C)-I &&+" ""4( $))G,-Qtyy.?rBDI  E  ''.!$)), HC--##CHH-C NNS\2 3 KKM +--c$))n(<=#c{+ 7E*  & &s + LLN  &&(  5) ##E4#@ $7 ie"II1 B e3CHH<@ XXL+ s$-%N 7%N7 %N43N477O10O1rYc Vdjd|jjD}t|jdd}t |jjdk(r|dz }|j d|d|d |j d|jd|jd y) zc3FK|]}t|jywr.)reprrRrs r4rfz*CodeGenerator.macro_def..sHqd166lHs!rRNr ,zMacro(environment, macro, z, (z), z, context.eval_ctx.autoescape)) r6r)rgetattrrSrErrr)r'rYr* arg_tuplerRs r4 macro_defzCodeGenerator.macro_defsIIHINN4G4GHH y~~vt4 y~~"" #q (  I (I;?)),By/I/I.LM)),,J L r6c^d|j}|j|d|j}|S)z.Return a human readable position for the node.zline  in )rrR)r'r)rs r4positionzCodeGenerator.positions5T[[M " 99 4tDII=)B r6cdjd|jjjD}d|dS)Nr>c30K|]\}}|d|ywrNr)rdrRr8s r4rfz3CodeGenerator.dump_local_context..s' fhb ! {r)r6r dump_storesry)r'r*items_kvs r4dump_local_contextz CodeGenerator.dump_local_contextsD99 % 9 9 ; A A C  H:R  r6c|jd|jd|jd|jd|jdy)zWrites a common preamble that is used by root and block functions. Primarily this sets up common local helpers and enforces a generator through a dead branch. z$resolve = context.resolve_or_missingz!undefined = environment.undefinedzconcat = environment.concatzcond_expr_undefined = Undefinedzif 0: yield NoneNrrs r4 write_commonszCodeGenerator.write_commonssG => :; 45 89 )*r6cj|jj|jjy)aQPushes all parameter targets from the given frame into a local stack that permits tracking of yet to be assigned parameters. In particular this enables the optimization from `visit_Name` to skip undefined expressions for parameters in macros as macros can reference otherwise unbound parameters. N)rr rdump_param_targetsrs r4rVz(CodeGenerator.push_parameter_definitionss% $$U]]%E%E%GHr6c8|jjy)z+Pops the current parameter definitions set.N)rpoprs r4rXz'CodeGenerator.pop_parameter_definitionss !!#r6r8cZ|jr|jdj|yy)zMarks a parameter in the current parameter definitions as stored. This will skip the enforced undefined checks. r*N)rrr'r8s r4rWz#CodeGenerator.mark_parameter_storeds+   ! !" % - -f 5 !r6c:|jj|yr.)rr rys r4push_context_referencez$CodeGenerator.push_context_references %%,,V4r6c8|jjyr.)rrwrs r4pop_context_referencez#CodeGenerator.pop_context_references %%))+r6c |jdS)Nr*rrs r4get_context_refzCodeGenerator.get_context_refs,,R00r6c6|jd}|dk(ry|dS)Nr*rresolvez.resolverrys r4r4zCodeGenerator.get_resolve_funcs*..r2 Y ""r6cL|jd|j|dS)Nz .derived(rA)rrprs r4derive_contextzCodeGenerator.derive_contexts,&&()43J3J53Q2RRSTTr6c>|jsy||jdvS)z4Checks if a given target is an undeclared parameter.Fr*)rrys r4parameter_is_undeclaredz%CodeGenerator.parameter_is_undeclareds$$$..r222r6cJ|jjty)z+Pushes a new layer for assignment tracking.N)rr rurs r4push_assign_trackingz"CodeGenerator.push_assign_tracking s !!#%(r6cx|jj}|js|js |jr|sy|Dcgc] }|dddk7s |}}t |dk(rt t|}|jj|}|jr|jd|d|y|jr|jd|d|y|jd|d|n|jr|jdn/|jr|jd n|jd tt|D]I\}}|r|jd |jj|}|j|d |K|jd |jsu|jsh|ret |dk(r|jd|ddyd jtt t|}|jd|dyyyycc}w)zoPops the topmost level for assignment tracking and updates the context variables if necessary. Nr _z _loop_vars[] = z _block_vars[ context.vars[z_loop_vars.update({z_block_vars.update({context.vars.update({r>r})context.exported_vars.add(rrAzcontext.exported_vars.update((r)rrwrrrrSnextiterrrPrrOr,rEr6mapra) r'r*varsr public_namesrRrPr\ names_strs r4pop_assign_trackingz!CodeGenerator.pop_assign_trackings!!%%'!!$$NN #'8a1Ra5C<8 8 t9>T #D--##D)CTHD>?  dXT#?@ NN]4($se< =45""5667&vd|4 / TJJt$mm''- dXRu-.  / JJt   )9)9l< A%!;LO;NaPQ IIc$|0D&EF !? {"MN ?K)9 19s  H7H7c  |Jdt|j|j}ddlm}ddlm}|jj rt||z}n t|}|jddj|z|jrdnd}|jtjdu}|jtjD]]} | j|j vr*|j#d | jd | j$| |j | j<_|jtj&D]} | j(|j*vs| j(} |j-x|j*| <} d | vr0| j/d d\} }|jd | d |d| {|jd| d| |jd|j|j|j1dd|dd|j3|j5t7|}dt9|j:dvr/|j<j?d}|j|d|j<jA|dx|_!|_"|xr |jF |_$|r|jd|jK||jM|j:|jO|j:||jQ|d|jS|r|jFs!|j3|jd|j3|jj s|jdn|jd|jd|j3|jd|j3|jd |jS|jS|jd!|jSd|jF z|j jUD]\}} |j|j1d"|zd|d| d|j3|j5t7|}d|_+t9| j:d#}d|vr/|j<j?d}|j|dd$|vr5|j<j?d$}|j|d%|d&|d'|j<jA| ||_,|jd(|jK||jM| j:|jO| j:||jQ|d|jSdjd)|j D}|jd*|d+dd,jd-|jZD}|jd.|y)/Nzno root frame allowedr )async_exported)exportedzfrom jinja2.runtime import r>z, environment=environmentzblock z defined twice.zfrom z import z as zimport zname = rootz(context, missing=missingrJ)r r'rz = TemplateReference(context)Tzparent_template = NonerMif parent_template is not None:z4yield from parent_template.root_render_func(context)z0agen = parent_template.root_render_func(context)r&zasync for event in agen:z yield eventzfinally: await agen.aclose()block_)r'superrz = context.super(z, block_rAz_block_vars = {}c3*K|] }|d| yw)z: block_Nrrs r4rfz/CodeGenerator.visit_Template..s!K!QE!"5!Ksz blocks = {r&c30K|]\}}|d|yw)rNrrhs r4rfz/CodeGenerator.visit_Template..sGtq!1#Qqc Grlz debug_info = ).rrBrRruntimerrrBr,rr6rUfindr Extendsfind_allrrrr ImportedName importnamerrrsplitrErrsr+rrQrrUrNrrrrr;r/rr>rryrrr)r'r)r*r0rrexported_namesenvenv have_extendsrimport_impaliasmoduleobjrPrRrr blocks_kv_str debug_kv_strs r4visit_TemplatezCodeGenerator.visit_Template=s}555}t//;+%    $ $#H~$=>N#H-N 4tyy7PPQ,Gyy/t; ]]5;;/ ,EzzT[[( F5::.?N&+DKK # , }}U%7%78 ?G!!)<)<<((373L3L3NN##C(5#:"%**S!"4KFCNNU6((3%tE7#KLNNWSEeW#=> ?  ./ yy !!:6(" EQ    h _TYY : :--11&9C NNcU"?@ A ""4(+//%1%P$:P:P6P"  NN3 4  tyy)  5) $7  )) @A KKM##,,UVQRv& 9: }-  => LL$"8"889 : ;;,,. KD% NN99X_-..GxrR  KKM     /K&*K #(5FGJ#!));;FC#&CDE*$!));;GD#&7xxvQOP    , ,U 3 $K  NN- .   [ )  " "5:: . OOEJJ 4   [D  A LLN7 : !Kt{{!KK  ]O26a@xxGtGG  |&678r6cd}|jrB|jry|jdkDr&|jd|j |dz }|j r|j |}n|j}|jr`|jd|jd||j |jd|jd||j|jjs0|j$|jd |jd |d |n|jd |jd |d |jd |j |j|jd||j |jd||j|j|jd|jdd|j|y)z.Call a block and register it for the template.rNif parent_template is None:r zif len(context.blocks[z]) <= 1:z+raise TemplateRuntimeError("Required block z not found")zyield from context.blocks[z][0](rAzgen = context.blocks[r&for event in gen:event finally: await gen.aclose() gen.close())rrrrrscopedrrrequiredrRrrBrBrrCr)r'r)r*rrs r4rzCodeGenerator.visit_Blocks >>%%""Q&<=   ;;))%0G**,G == NN3DII=I4 P KKM NN=dii],W  LLN((U\\-A NN,TYYMwiqI4  NN2499-uWIQO P NN6 " KKM NN$$&''89  KKM   gu - LLN LLN NND--.BMRST  Ur6c|js|jd|j|jdkDrd|js!|j d|j |j d|jr t|j|j d||j|j||jd|jd|j d|j |j d |j|jrd |_|xjd z c_y ) zCalls the extender.z,cannot use extend from a non top-level scoperrz5raise TemplateRuntimeError("extended multiple times")z+parent_template = environment.get_template(r>rAz9for name, parent_block in parent_template.blocks.items():z8context.blocks.setdefault(name, []).append(parent_block)Tr N)rrrrrrrrrr2templaterErRrr'r)r*s r4 visit_ExtendszCodeGenerator.visit_Extendss~~ IIDdkk R    " ))@A NNR S%%"n$  DdK 4==%( R }A&' RS  QR  ??%)D " q r6c|jr!jdjd}t|jt j rTt|jjtrd}nct|jjttfr9d}n6t|jt jt jfrd}jd|d|j|jjdjd|jrsj!jd jjd j!jd jdfd }|j"rjdj%djdjjj'd|j!jdj'ddn@j(j*rjd|njd|jrj!y y )zHandles includes.r&get_or_select_template get_templateselect_templateztemplate = environment.r?r>rAzexcept TemplateNotFound:rrNcjjjdjy)Nr)rrr)r*r'sr4 loop_bodyz.CodeGenerator.visit_Include..loop_body-s% KKM   gu - LLNr6zNgen = template.root_render_func(template.new_context(context.get_all(), True, rrrrrzGfor event in (await template._get_default_module_async())._body_stream:z6yield from template._get_default_module()._body_streamr)ignore_missingrrrXrr Constr_rrrsrtTupleListr2rErRr with_contextrprCrBrB)r'r)r* func_namers` ` r4 visit_IncludezCodeGenerator.visit_Includes    NN6 " KKM, dmmU[[ 1$----s3* DMM//%?-   UZZ'@ A)I 0 1=tD 4==%( R }A&'    LLN NN5 6 KKM NN6 " LLN NN7 # KKM     NN++E2327  NN6 " KKM NNd//122CD E K LLN NND--.BMRST    & & NN!  K NNS T    LLN r6c|j|jdd|j|j||jd|jd|j r;d|jd}|j|d|j |dy|jd |jdd y) Nawait zenvironment.get_template(r>z). make_module_asyncz(context.get_all(), True, rA_get_default_modulez (context))rErCr2rrRrrp)r'r)r*f_names r4_import_commonzCodeGenerator._import_commonLs d''122KLM 4==%( R }B'(   "4#4#4X#>"?@F JJ(4T5L5LU5S4TTUV  JJ,T->->x-H,IS Tr6c~|j|jj|jd||jr|j d|jd|j |||jr<|jjds |jd|jdyyy)zVisit regular imports.r1rrrcontext.exported_vars.discard(rAN)rrrPr8rrEr startswithrs r4 visit_ImportzCodeGenerator.visit_Import[s %--++DKK89=tD >> JJt{{oT: ; D%( >>$++"8"8"= NN;DKK?!L M#>>r6c |j||jd|j|g}g}|jD]H}t |t r|\}}n|}|j jj|d|d|j djj|d|j|j|jddjdd }d |d |}|j jj|d |d |d|jjs|j||jdr8|j|K|rst!|dk(r6|d}|j d|djj|n/dj#fd|D} |j d| d|r\t!|dk(r|j d|ddydj#t%t&|} |j d| dyy)zVisit named imports.zincluded_template = z = getattr(included_template, z , missing)rKrLrmz{{rz}}z9the template {included_template.__name__!r} (imported on z%) does not export the requested name z = undefined(fz, name=rArr rrrr>c3^K|]$}|djj|&ywrk)rrP)rdrRr*s r4rfz1CodeGenerator.visit_FromImport..s1%?Cthb!2!24!8 9:%s*-rrrz)context.exported_vars.difference_update((rN)rrErr{rXrsrrrPrrhreplacerrr rrSr6rra) r'r)r* var_namesdiscarded_namesrRrrhmessagenames_kvrs ` r4visit_FromImportzCodeGenerator.visit_FromImportfsT T )* D%( JJ 2D$&" e NN==$$U+,-//3hjB  NNS!2!25!9 :,G H KKM }}T*223=EEc4PH!!) +77;h@  NN==$$U+,N7+WTHTUV  LLN~~  ''',#**519 2< 9~" |thd5==;L;LT;R:STU99%GP%!7zEF ?#q(!?PQ@R?UUVWX IIc$&@A ? {"M r6c"|j}d|_|j}|j}|jxsOdt|j ddvxs/t d|j tjD}d}|r|jjd}|jj|d|jr|jj|d |jr|j}|jj|d |j|j!|d |j|j#|j%||j|j'd d |j)|j*||j-d|j-|j'dd|j-d|j#|jd|j|j)|j||j-d|j#|jd|j)|j*||j/d|j1|d|jrV|j|j!dd||j#|j3||j2|_|r|j|d|j tj4D]>} | j6dk(s| j8dk(s#|j;d| j<@|jr$|j} |j| d|j|j'd d ||j)|j*||r(|j-d|d|j'ddn|j-d|jr|j-d|jr|j-dnn|j>j@r|s|j-d |j)|jB||j>j@r|s|j-d!|jr|j-d!|jr|j-d"n|j-|rd#nd|j#|j%||jd$|jE|jF||jr|j d%|j/|j1||jxr |j |jrs|jd d|j#|j%||jE|j||j1||j/|jr|jI||j/|jK|||j-|j'd&d'|j>j@r|j-d |j)|jB||j>j@r|j-d!|j-d(|jM||jNr3|jNd)jQ|jjRyy)*NTloop)rQ)only)rc34K|]}|jywr.)r)rdrs r4rfz*CodeGenerator.visit_For..sHE5<<HrrQ) for_branchelsetestz(fiter):z async for zfor rgzauto_aiter(fiter)fiter:rKrrMz%(reciter, loop_render_func, depth=0):r2storez8Can't assign to special loop variable in for-loop targetz = 1r>Asyncz LoopContext(r?reciterz auto_aiter(rAz&, undefined, loop_render_func, depth):z , undefined):z_loop_vars = {}z = 0rzloop(z, loop)r*)*rr recursiveriter_child_nodesrrr rrrUrNelse_rrrrErr;rCr2r8rErr>rrrrRrrrBrBrrrQrrrrdifference_updatestores) r'r)r*r test_frame else_frame extended_looploop_refloop_filter_funcrRiteration_indicators r4 visit_ForzCodeGenerator.visit_Fors[[] $ [[] [[] NN It44)4DiPQ IHT]]5;;-GHH  !));;FCH'''@ ::    + +DV + D 99#88:     + +DV + D NNdii(89:(CTYY O KKM   Z ( NN4,,\6B C JJt{{J / JJv  JJt(()> NN99V$%%JKT  KKM KK #!+ 1 1J   NNhZz2 3MM%**- Dxx7"tyyF': NKK  ::"&";";"=  NN12$7 8 t((v>E 4;; +  JJH:T$*;*;G*D)E\R S JJv  99 JJ*+1- . >> JJy !(( =) JJtyy% ((( 3 99 JJsO >> JJ? @ JJ-S A  $ ()  :. :: NN12$7 8   $..*K^   :: NNS!4 5Q7 8 KKM   Z ( OODJJ 3   Z ( LLN >>  ' ' 3 LLN   UD ) JJ$++H56e< =(( =) JJtyy% ((( 3 JJy ! NN5 !      r " 4 4Z5G5G5N5N O r6c|j}|jd||j|j||j d|j |j |j||j|jD]}}|jd||j|j||j d|j |j |j||j|jrN|jd|j |j |j||jyy)NrKrzelif r) rrr2rrErrrQrelif_r)r'r)r*if_framers r4visit_IfzCodeGenerator.visit_If(s::< ud# 499h' 3   8, ZZ E NN7E * JJuzz8 , JJsO KKM OOEJJ 1 LLN   :: NN7 # KKM OODJJ 1 LLN r6c|j||\}}|j|jrY|jj ds|j d|jd|j d|jd|j |jj|jd|j||y)NrrrArrr1) r^rrrRrrErrrPre)r'r)r* macro_framerYs r4 visit_MacrozCodeGenerator.visit_Macro=s!%u!= Y  >>99'', 7 }AFG NN]499-t< = emm'' 23378 y+.r6c|j||\}}|jd|j|||j|||j |j |d|j |y)Nz caller = T)forward_caller)r^rrer visit_Callcallr)r'r)r* call_framerYs r4visit_CallBlockzCodeGenerator.visit_CallBlockGsc $e < I {# y*- %  5> ur6cv|j}|jj||j||j ||j |j ||j|||j|j||j||j|yr.) rrrNr;rrrQrrfilterrr>)r'r)r* filter_frames r4visit_FilterBlockzCodeGenerator.visit_FilterBlockOs{{} ))$/ & L!  <0 % $++|4 u &r6c|j}|jj||j|t |j |j D]J\}}|j|j|||jd|j||L|j|j||j|y)Nr1) rrrNr;ziptargetsvaluesrr2rErrQr>)r'r)r* with_framer8exprs r4 visit_WithzCodeGenerator.visit_WithZs[[] ''- $ dkk: $LFD LLN JJvz * JJu  JJtU #  $  :. $r6c^|j||j|j|yr.)rr2r)rs r4visit_ExprStmtzCodeGenerator.visit_ExprStmtfs  T 499e$r6cteZdZUejej defed<ejeed<y)CodeGenerator._FinalizeInfo.constsrcN)rrrr8rCallablerr__annotations__rr6r4 _FinalizeInforjs,zz!**S#X.// ZZ_r6rr_ct|S)zThe default finalize function if the environment isn't configured with one. Or, if the environment has one, this is called on that function's output for constants. )rrrzs r4_default_finalizezCodeGenerator._default_finalizens 5zr6 _finalizecbj jSjx}d}jjrd}jjtj dtj dtjdijt j}d}|(dtjdtjffd }n4||d }|dk(r(dtjdtjffd }j||_jS) aBuild the finalize function to be used on constants and at runtime. Cached so it's only created once for all output nodes. Returns a ``namedtuple`` with the following attributes: ``const`` A function to finalize constant data at compile time. ``src`` Source code to output around nodes to be evaluated at runtime. Nzenvironment.finalize(rcontext.eval_ctxrBr_r%c |Sr.r)r_r] env_finalizes r4finalizez.CodeGenerator._make_finalize..finalizes"<#677r6r>c6j|Sr.)rB)r_r]r"r's r4r#z.CodeGenerator._make_finalize..finalizes&|D4D4De'LMMr6) rrrBr#rr eval_contextgetfrom_objr8r9r)r'r#rpass_argr]r"s` @@r4_make_finalizezCodeGenerator._make_finalizexs >> %>> !"3337    $ $)C++44L  )%%'9$$mc!!,/ H8AEE8aee8hZr*},NN!%%N++Hc:~~r6groupc*tt|S)zGiven a group of constant values converted from ``Output`` child nodes, produce a string to write to the template module source. )rar)r'r*s r4_output_const_reprz CodeGenerator._output_const_reprs F5M""r6r#c|j|j}|jjr t|}t |t j r t|S|j|S)aCTry to optimize a child of an ``Output`` node by trying to convert it to constant, finalized data at compile time. If :exc:`Impossible` is raised, the node is not constant and will be evaluated at runtime. Any other exception will also be evaluated at runtime for easier debugging. ) as_constr0rrrXr TemplateDatarrr)r'r)r*r#rs r4_output_child_to_constz$CodeGenerator._output_child_to_constsW enn- >> $ $5ME dE.. /u: ~~e$$r6c|jjr|jdn9|jjr|jdn|jd|j|j|jyy)zXOutput extra source code before visiting a child of an ``Output`` node. z1(escape if context.eval_ctx.autoescape else str)(zescape(zstr(N)r0r1rErrr'r)r*r#s r4_output_child_prezCodeGenerator._output_child_presb >> " " JJJ K ^^ & & JJy ! JJv  << # JJx|| $ $r6cb|jd|j|jdyy)zWOutput extra source code after visiting a child of an ``Output`` node. rAN)rErr2s r4_output_child_postz CodeGenerator._output_child_posts) 3 << # JJsO $r6c~|jr.|jry|jd|j|j }g}|j D]} |j s.t|t jst j|j|||}|r(t|dtr|dj|{|j|g|j[t|dk(r|j|jdn|j|jd|j|D]}t|trG|j!|}|j|jd|zE|j|dzZ|j|jd|n|j#||j%||||j'|||j)||||j|j+d|j1|j-|jt|dk(rdnd |jr|j-yy#t jtf$r|j|YbwxYw) Nrr*r rz .extend((rrbrAr)rrrrr)r rrXr/ Impossibler0 Exceptionr rtrrSr,rr3r2r5rEr) r'r)r*r#rQchildritemvals r4 visit_OutputzCodeGenerator.visit_OutputsH  % %%% NN8 9 KKM&&(;= ZZ %E NN"%););<**,,33E5(K 48T2R& UG$/ %2 << #4yA~%,,x89%,,y9: KKM $D$%--d3<<'NN8c>2NN39-<<'NN8T2LL&&&tUH= 4'''eX><<+JJsO+ $. << # LLN NN#d)q.3d ;  % % LLN &_$$i0  E"  sA J*J<;J<c|jt}|jtjD]}|j |vr|j |j |jj|j }|jd|d|j|jd|j|j||j|j||jd|j|j ||j#|y)Nzif not isinstance(z , Namespace):zMraise TemplateRuntimeError("cannot assign attribute on non-namespace object")r1)rrurr NSRefrRrrrPrrrrr2r8rEr)r)r'r)r* seen_refsnsrefrPs r4 visit_AssignzCodeGenerator.visit_Assign.s !!# !$ ]]5;;/ EzzY& MM%** %--##EJJ/C NN/uMB C KKM NNF  LLN  T 4;;& 5 499e$   'r6cv|j|j}d|_|jj ||j ||j ||j|j||j||j|j||jd|j|j|j|n|jd|j d|jd|j||j!|y)NFz9 = (Markup if context.eval_ctx.autoescape else identity)(concat(rA)rrrrrNr;rrrQrr2r8rEr rrr>)r'r)r*rs r4visit_AssignBlockzCodeGenerator.visit_AssignBlockMs !!#kkm ,1 (((. % K   ;/ T 4;;& NO ;; "   dkk; 7 JJ!3!3 4A6 7 3   ' %r6c |jdk(rX|js|js |jr4|jr(|jdj |j |jj|j }|jdk(r`|jj|}||dtk(r|j|r&|jd|j d|d|dy|j|y) Nrr*rrz(undefined(name=z) if z is missing else rA) rrrrrrrRrrP find_loadrrrE)r'r)r*rPrs r4rzCodeGenerator.visit_Namees 88w  NNe..%2C2C!!""2&**4995mm * 88v ==**3/D G1144S9 &tyym5=NseSTU 3r6c|jj|j}|j|d|jdy)Nr'r()rrPrRrattr)r'r)r*rPs r4 visit_NSRefzCodeGenerator.visit_NSRef~s9 mm * #a }A./r6c|j|j}t|tr|j t |y|j t |yr.)r.r0rXrorErrra)r'r)r*r;s r4 visit_ConstzCodeGenerator.visit_Consts>mmENN+ c5 ! JJs3x JJtCy !r6c |jt|j|jy#tj $r"|jd|j dYywxYwNz6(Markup if context.eval_ctx.autoescape else identity)(rA)rErar.r0r r7datars r4visit_TemplateDataz CodeGenerator.visit_TemplateDatasW  JJtDMM%..9: ;  JJH UVW  s362A+*A+c|jdd}t|jD]*\}}|r|jd|j||,|j|dk(rdydy)Nr?r*r>rz,)rArErOryr2r'r)r*r\r:s r4 visit_TuplezCodeGenerator.visit_Tuplesd 3"4::. $IC 4 JJtU # $ 3!84--r6c|jdt|jD]*\}}|r|jd|j||,|jdy)Nr'r>r(rQrRs r4 visit_ListzCodeGenerator.visit_ListsS 3"4::. $IC 4 JJtU # $ 3r6c:|jdt|jD]a\}}|r|jd|j|j||jd|j|j |c|jdy)Nrmr>rr)rErOryr2rr_rRs r4 visit_DictzCodeGenerator.visit_Dictsu 3"4::. *IC 4 JJtxx ' JJt  JJtzz5 )  * 3r6+-*/z//z**%andorznot c|jjrd}n|jjrd}nd}|j|d|jD]%}|j |||jd'|jdy)Nz8(markup_join if context.eval_ctx.volatile else str_join) markup_joinstr_joinz((r>r)r0r1rrEr r2)r'r)r*rr"s r4 visit_ConcatzCodeGenerator.visit_Concatsy >> " "RI ^^ & &%I"I i[#$:: C JJsE " JJt   4r6c|jd|j|j||jD]}|j|||jdy)Nr?rA)rEr2ropsrHs r4 visit_ComparezCodeGenerator.visit_ComparesK 3 499e$(( "B JJr5 ! " 3r6c|jdt|jd|j|j|y)Nr@)rE operatorsr;r2rrs r4 visit_OperandzCodeGenerator.visit_Operands3 Qy)*!,- 499e$r6c:|jjr|jd|jd|j|j||jd|j d|jjr|jdyy)N(await auto_await(zenvironment.getattr(r>rAr)rBrBrEr2r)rHrs r4 visit_GetattrzCodeGenerator.visit_Getattrsv    $ $ JJ+ , )* 499e$ R }A&'    $ $ JJt  %r6cvt|jtjr[|j |j ||j d|j |j||j dy|jjr|j d|j d|j |j ||j d|j |j||j d|jjr|j dyy)Nr'r(rjzenvironment.getitem(r>rAr) rXr"r Slicer2r)rErBrBrs r4 visit_GetitemzCodeGenerator.visit_Getitems dhh , JJtyy% ( JJsO JJtxx ' JJsO(( /0 JJ- . JJtyy% ( JJt  JJtxx ' JJsO(( 4 )r6c:|j|j|j||jd|j|j|j||j.|jd|j|j|yy)Nr)startr2rEstoprrs r4 visit_SlicezCodeGenerator.visit_Slicesq :: ! JJtzz5 ) 3 99 JJtyy% ( 99 JJsO JJtyy% ( !r6 is_filterc#K|jjr|jd|r[|j|j|jd|jjj |j}nZ|j|j |jd|jj j |j}|?|js3|rdnd}|jd|d|jd|jtjdtjd tjd ij tj|}||j|d d|j|||jd |jjr|jd yyw)Nrjr?r rzNo r+rrr rBr>rAr)rBrBrErrRr&rrrrrrr%r'r$)r'r)r*rsrE type_namer(s r4_filter_test_commonz!CodeGenerator._filter_test_commons    $ $ JJ+ ,  JJ$,,tyy12!4 5##++// :D JJ$**TYY/02 3##))--dii8D < 0 0$-6I III;gdii]!<= WU\\N!45 6 6 6s CCC(c|j||d5|j|j|dddy#1swYyxYwr)rvr2r)rs r4rzCodeGenerator.visit_Test=s;  % %dE5 9 ) JJtyy% ( ) ) )s :Ac@jdfd }jdjjjdjjjd|jdy)Ncjjjyjdjdy)Nz1cond_expr_undefined("the inline if-expression on z6 evaluated to false and no else section was defined."))expr2r2rErh)r*r)r'sr4 write_expr2z1CodeGenerator.visit_CondExpr..write_expr2FsLzz% 4::u- JJMM$'()*+ r6r?z if z else rAr)rrEr2expr1r)r'r)r*r|s``` r4visit_CondExprzCodeGenerator.visit_CondExprBsl   3 4::u% 6 499e$ 8  3r6rc8|jjr|jd|jjr|jdn|jd|j |j ||rddind}|j rddini}|jrddini}|r|j|fi|n|s|r t|fi|}|j||||jd|jjr|jdyy) Nrjzenvironment.call(context, z context.call(rG _loop_vars _block_varsrAr) rBrBrErCr2r)rrrrxr$)r'r)r*rr loop_kwargs block_kwargss r4rzCodeGenerator.visit_CallYs    $ $ JJ+ ,    % % JJ3 4 JJ ' 499e$/=(+4 6;6F6F|\2B 9>9J9J }5PR  L   <| < L <|" 4::u%r6c|jd|j|j||jdy)NzMarkup(rArEr2rrs r4visit_MarkSafezCodeGenerator.visit_MarkSafevs+ 9 499e$ 3r6c|jd|j|j||jdyrMrrs r4visit_MarkSafeIfAutoescapez(CodeGenerator.visit_MarkSafeIfAutoescape{s. KL 499e$ 3r6c@|jd|jzy)Nz environment.rErRrs r4visit_EnvironmentAttributez(CodeGenerator.visit_EnvironmentAttributes >DII-.r6cZ|jd|jd|jy)Nzenvironment.extensions[z].)rE identifierrRrs r4visit_ExtensionAttributez&CodeGenerator.visit_ExtensionAttributes' ,T__,?r$))MNr6cT|j|j|jyr.)rErrrs r4visit_ImportedNamez CodeGenerator.visit_ImportedNames 4&&t78r6c:|j|jyr.rrs r4visit_InternalNamez CodeGenerator.visit_InternalNames 499r6c&|jdy)Nr)rErs r4visit_ContextReferencez$CodeGenerator.visit_ContextReferences 9r6cD|j|j|yr.)rErrs r4visit_DerivedContextReferencez+CodeGenerator.visit_DerivedContextReferences 4&&u-.r6c(|jd|y)Ncontinuerrrs r4visit_ContinuezCodeGenerator.visit_Continues z4(r6c(|jd|y)Nbreakrrrs r4 visit_BreakzCodeGenerator.visit_Breaks w%r6c|j}|jj||j||j |j ||j |yr.)rrrNr;rrQr>)r'r)r* scope_frames r4 visit_ScopezCodeGenerator.visit_ScopesOkkm ((. %  ;/ %r6c|j}|j|d|j||j|d|j|j||j ||j d}|jj||j||j|j||j||jy)Nr1z.vars = T)r)rrrr2rr{rrrNr;rrQr>r})r'r)r*rrs r4visit_OverlayScopez CodeGenerator.visit_OverlayScopes'') #c$"5"5e"? #h'( 4<<' ##C(kk4k0 ((. %  ;/ % ""$r6c~|jD]}|jd|jd|j|j| |jj |j }t|j |j|y#tj$rd|j _ YwxYw)Nzcontext.eval_ctx.r1T) optionsrrr2r_r.r0setattrr r7r1)r'r)r*keywordr;s r4visit_EvalContextModifierz'CodeGenerator.visit_EvalContextModifiers|| :G NN.w{{m3? @ JJw}}e , :mm,,U^^< S9 : ## /*.' /s %B$B<;B<cJ|j}|jj}|j|d|j |||j D]}|j |||jj||jd|dy)Nz = context.eval_ctx.save()zcontext.eval_ctx.revert(rA)rr0saverrrQr2revert)r'r)r* old_ctx_name saved_ctxr9s r4visit_ScopedEvalContextModifierz-CodeGenerator.visit_ScopedEvalContextModifiers002 NN'')  ,'ABC &&tU3YY %E JJue $ % i( 1,qABr6NFTrr)r r.)Nr)zasync r)rrrr8rrrTextIOrmrpropertyrVrnrrr+rrrrr NoderrrrrrErrrCallrrMappingr9r$r/r;r>rCrErrrrr^rerhrprsrVrXrWr{r}rr4rrrrrYrrrrrIncluderImport FromImportrrrForrIfrrr FilterBlockr WithrExprStmtr NamedTupler staticmethodrrrr)r,r7r0r3r5Outputr<AssignrA AssignBlockrDrrr>rIrrKr/rOrSrrUDictrWrL visit_Add visit_Sub visit_Mul visit_Divvisit_FloorDiv visit_Pow visit_Mod visit_Andvisit_OrrQ visit_Pos visit_Neg visit_Notr:ConcatrbComparereOperandrhGetattrrkGetitemrnrmrrrIteratorrvrrCondExprr~rKeywordrMarkSaferMarkSafeIfAutoescaperEnvironmentAttributerExtensionAttributerrr InternalNamerContextReferencerDerivedContextReferencerContinuerBreakrScoper OverlayScoperEvalContextModifierrScopedEvalContextModifierrrr6r4r(r(,s (, G4"G4jjoG4**S/ G4  188$ G4  G4G4 G4R*4** LLSL]L,c, /E/d/ 5:99-19 9("C""<>4> BB4BDBHHCHQTH222Q GGEKK89Q BGQ  !Q f  8  E  d  UZZC!!#! +II$I$6C6D65S5T5,11### UEUcU3c3d3 ))O)O4)O\@Dx9NNx9+,::e+<x9 x9t/ /E/d/b(!%--(!(!$(!T8%--88$8t UGGELL%*:*::; UDI U  U N Ne N N5U%5%55e55nIPeiiIPIP$IPVUXXe*/ /E/d/EOOEd 'e&7&7 ' '$ ' %uzz %% %D %%5>>%%%D% 155,0Iqzz-(/. .`# 155(9#c#%JJ%',%8E% %*%JJ%',%8E% % JJ ', 8E   MMeMM^((e((>&e&7&7&&$&0uzz%D20 0E0d0" "E"d"u'9'9%D. .E.d.uzz%Duzz%DC IC IC IC I &ND!IC IE"I4 H3I3I6"I  e   %--$%%--%%$% %--  $  !%--!!$!!() )E)d)'GGELL%**45'>C'PT' D ''R66e666 )uzz)%)D))5>>%D,EJJJ',>B ,&%--&&$& 5>>%D ..7< /../7</ / O,,O5:O O 9u'9'99%9D9u'9'9%D**38  /11/:?/ / )5>>)%)D)& &E&d&& &E&d& %u'9'9 %% %D % :-- :6; :  : C33 Crs26%$2.&*(*  ??"( AIIcCJ/0         'Q '1 ' CAJJ'PRV'VW* ZZ%//7;TAB0$( .. **S/jjo  JJqxx   ZZ_04"  ::ejj ! *+**S/ UU3Z &&PPfJ,J'k'&&K&,9bCKbCr6