rWc# ^dZddlZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddl m Z d Z d d hZ d d he Zdddddddddef dZGddZGddZGddZejdZdZGddZdS)zVprovides functionality for rendering a parsetree constructing into module source code.N)ast) exceptions)filters) parsetree)util) PythonPrinter UNDEFINEDSTOP_RENDERINGcontextloopTFc tj} t| } t| t ||||||||| | | || S)zYGenerate module source code given a parsetree node, uri, and optional source filename)rFastEncodingBufferr_GenerateRenderMethod_CompileContextgetvalue)nodeurifilenamedefault_filtersbuffer_filtersimportsfuture_importssource_encodinggenerate_magic_commentstrict_undefined enable_loopreserved_namesbufprinters /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/mako/codegen.pycompiler"sw"  ! # #CC  G        "     " <<>>ceZdZdZdS)rc ||_||_||_||_||_||_||_||_| |_| |_ | |_ dSN) rrrrrrrrrrr) selfrrrrrrrrrrrs r!__init__z_CompileContext.__init__Hs_  ., ,.&<# 0&,r#N)__name__ __module__ __qualname__r(r#r!rrGs#-----r#rceZdZdZdZdZedZdZdZ dZ dZ d Z dd Z d ZdZ ddZ d dZdZdZdZdZdZdZdZdZdZdZdZdZd S)!rzZA template visitor object which generates the full module source for a template. c8||_||_||_dg|_t |t jt jf|_|jrd|j z}| }t|j j dk}t|jdd}t|jdd}d} d} |jr |js|dgz }n|} |jj} d}| | j }| jjs|dgz }t| jdd}|jjp't| jdd|j_ndg}d }d x}}|d g}nd d g|zD}|| p||||||| | D]}t3||||js|dSdS) Nz render_%srbufferedFalsecached **pageargs render_bodyrFr cg|]}|Sr,r,.0as r! z2_GenerateRenderMethod.__init__..s222!A222r#)r compilerridentifier_stack isinstancerDefTagBlockTagin_deffuncnameget_argument_expressionslen filter_argsargseval attributesgetis_block is_anonymouswrite_toplevelpagetag body_declkwargsrwrite_render_callablerwrite_metadata_struct) r'r r9rnamerCfilteredr/r1defsrJs r!r(z_GenerateRenderMethod.__init__jsU    !%  (8):L'MNN ; (.D0022D4+011A5HDO// GDDEEH$/--h@@AAFDG} 'T%6 '&&&((Dm+G D"(AACC(/+\N*Dg044XwGGHH,0M,E-&**='BBJJ ))%~"' 'Hx <;DD22 {T1222D "" OtT48V      ? ?%gx>>>>{ )  & & ( ( ( ( ( ) )r#c"t|jj|jj|jj<|jj|jj|jj|jjd}|jddtj |ddS)N)rrrline_mapz"""__M_BEGIN_METADATAz__M_END_METADATA """) maxr source_maplinenor9rrr writelinesjsondumps)r'structs r!rNz+_GenerateRenderMethod.write_metadata_structs7: L #8 8   34 .=$#}< /      Jv   &      r#c|jdS)N)r:r's r! identifiersz!_GenerateRenderMethod.identifierss$R((r#c0 g i g dj_G fdd}|}jjD]}|| j_t } D])}||}*tj}||_ jj r3jj r'j djj zjjr:j ddjjj dj dj d j d j d j d t"zj d t%jzj djjzj djjzj djjzj djj zjjrMd}jjD]$}||dzz }j |%t/j|dddd}nd}|j} |j} | | j|_|j t8|r|j |j|j_j dd| jDzj dtA r! tA r1" # dn$tA r" tI| jS)zxTraverse a template structure for module-level directives and generate the start of module-level code. Nc8eZdZfdZfdZfdZfdZdS):_GenerateRenderMethod.write_toplevel..FindTopLevelc2|dSr&)append)srinherits r!visitInheritTagzJ_GenerateRenderMethod.write_toplevel..FindTopLevel.visitInheritTagst$$$$$r#c||j<dSr&rO)rer namespacess r!visitNamespaceTagzL_GenerateRenderMethod.write_toplevel..FindTopLevel.visitNamespaceTags(, 49%%%r#c |j_dSr&)r9rJ)rerr's r! visitPageTagzG_GenerateRenderMethod.write_toplevel..FindTopLevel.visitPageTags(, %%%r#cD|jr|dSdSr&)ismodulerd)rer module_codes r! visitCodezD_GenerateRenderMethod.write_toplevel..FindTopLevel.visitCodes1=-&&t,,,,,--r#N)r)r*r+rgrkrmrq)rfrprjr'sr! FindTopLevelrbsy % % % % % - - - - - - - - - - - - - - - - -r#rrz# -*- coding:%s -*-zfrom __future__ import , z(from mako import runtime, filters, cachezUNDEFINED = runtime.UNDEFINEDz'STOP_RENDERING = runtime.STOP_RENDERINGz__M_dict_builtin = dictz__M_locals_builtin = localsz_magic_number = %rz_modified_time = %rz_enable_loop = %rz_template_filename = %rz_template_uri = %rz_source_encoding = %r rztemplate defined imports)sourcerWposrz _exports = %rcg|] }|j Sr,ri)r6ns r!r8z8_GenerateRenderMethod.write_toplevel..sFFF!qvFFFr#r])%r9rJrnodesaccept_visitorrjsetuniondeclared_identifiers _Identifiersdeclaredrrr writelinerjoin MAGIC_NUMBERtimerrrrr PythonCodebranch topleveldefsupdateTOPLEVEL_DECLAREDr_values write_blanksrAwrite_module_codewrite_namespaces write_inheritlist)r'rrfry module_identmodule_identifiersrimpimpcodemain_identifiersmitrfrprjs` @@@r!rIz$_GenerateRenderMethod.write_toplevels   $  - - - - - - - - - - - - - LNN  A  Q    #-  uu  H HA'--a.D.D.F.FGGLL)$-88&2# M 0  -  L " "% (EE    = '  L " " "99T]9:::=    IJJJ >??? HIII 8999 <=== 3lBCCC 4ty{{BCCC 2T]5NNOOO  % (> >    3dm6GGHHH  #dm&C C    = C}, , ,sTz! &&s++++n3 GGG-44TY?? -*-))  )+ + ' #**+<===  M  ' . .w/K L L L$6 !  FF/<CCEEFFF G    !!!$$$ {   0  " "; / / / w<< .  ! !* - - -   wr{ + + + + __ .  ! !* - - -$188::;;;r#c|jr&|j}|r|jd|z|j|j|jd|dd|ddd|s|s|r|jd|j |j j |j |jr |j jr)d |vr%|jd jd |js~t#|j jd kst#|j jd krD|jd dd|j jDz||j d|j jD]}||||j ||||jd|jd|r"||||||j ddSdS)znwrite a top-level render callable. this could be the main render() method or that of a top-level def.z@runtime._decorate_toplevel(%s)def (,):/__M_caller = context.caller_stack._push_frame()try:context._push_buffer()r2r]pageargsrz!__M_locals = __M_dict_builtin(%s)cg|] }|d| S)=r,r6xs r!r8z?_GenerateRenderMethod.write_render_callable..Bs3$%11aa(r#T)toplevelNrz)r> decoratorr r start_sourcerWrXrr:rdr9r_rrrGargument_declaredaddrAlocally_assignedwrite_variable_declaresr{r|write_def_finishrwrite_cache_decorator) r'rrOrCr/rPr1rrys r!rMz+_GenerateRenderMethod.write_render_callables ; I  &&5 A !!$+... !TT388D>>>> 2 =      =x =6 = L " "#; < < < $$ M % , ,TY 7 7     Hty1 H|t7K7K  !" % 7 ; ;J G G G{   1 2 2Q 6 64#566:: L " "3((!%!1!C    $$T%5$EEE # #A  T " " " " di8VDDD t$$$ !!!$$$    & &dD(D, tags in the template.starting_linenoN)r write_indented_blocktextrW)r'rprys r!rz'_GenerateRenderMethod.write_module_codeVsC P PA L - -afah - O O O O P Pr#c\|jddd|jdzddS)z:write the module-level inheritance-determination callable.z%def _mako_inherit(template, context):"_mako_generate_namespaces(context)z8return runtime._inherit_from(context, %s, _template_uri)fileN)r rXparsed_attributesr'rs r!rz#_GenerateRenderMethod.write_inherit\sD  3 0 F%f- /       r#c jddddddddjd|D]n}d|jvr d j_j|jt|j rЉjd gjj |d _ Gfd d }|}|j D]}||jd dzjdd_ d}nd}d|jvrCjd|jd|jddd|dnrd|jvrCjd|jd|d|jdddn&jd|jd|dt'|jddr"jd |jzjd!t)|jzjd"pt|sjd#jddS)$z5write the module-level namespace-generating callable.z'def _mako_get_namespace(context, name):rz+return context.namespaces[(__name__, name)]except KeyError:rNz'def _mako_generate_namespaces(context):importTzdef make_namespace():c*eZdZdZdZfdZdS)<_GenerateRenderMethod.write_namespaces..NSDefVisitorc0||dSr&visitDefOrBaserers r! visitDefTagzH_GenerateRenderMethod.write_namespaces..NSDefVisitor.visitDefTag((.....r#c0||dSr&rrs r! visitBlockTagzJ_GenerateRenderMethod.write_namespaces..NSDefVisitor.visitBlockTagrr#c|jrtj di|j|d|jdS)N.Can't put anonymous blocks inside <%namespace>Fnested)r)rHrCompileExceptionexception_kwargswrite_inline_defrdr?)rerexportr_r's r!rzK_GenerateRenderMethod.write_namespaces..NSDefVisitor.visitDefOrBasesq,","=!/###'"7## --dK-NNN dm44444r#Nr)r*r+rrr)rr_r'sr! NSDefVisitorrsV//////555555555r#r return [%s]rFzmake_namespace()Nonerzns = runtime.TemplateNamespace(z3, context._clean_inheritance_tokens(), templateuri=z , callables=z, calling_uri=_template_uri)modulezns = runtime.ModuleNamespace(z1, context._clean_inheritance_tokens(), callables=z$, calling_uri=_template_uri, module=)zns = runtime.Namespace(z, calling_uri=_template_uri) inheritabler0zcontext['self'].%s = nsz'context.namespaces[(__name__, %s)] = nspass)r rXrrrEr9has_ns_importsrrWrAr{r_rr>r|rrrOrFrDreprr) r'rjrrvisry callable_namerr_s ` @@r!rz&_GenerateRenderMethod.write_namespacesgsm  5  9  0 9    HIII%%''J )J )D4?**/3 , L % %dk 2 2 24: ' &&'>???"m7>>tDD " 555555555555"#lnn**A$$S)))) &&}8H8H'IJJJ &&t,,,# 2 & /// &&&  .2266BBBB%     T333 &&&  % .228VDDDD     &&&yyy---1 DO'' w??@@ P &&'@DI'NOOO L " "9DOOK    L % %a ( ( ( (: + L " "6 * * * t$$$$$r#FNc d|jD}t}||j}|d|jD}||j}||j}|j j rd|v}| dnd}|| |}|rt|j ddr|jdd|j _|j jD]M\}}d |jvr?|jd |d t)jd |jd d N|r|jd|D]}||vr||} | jr7| js|| |4|| |dM| r|| |x|| |d||j jvr!|j|d|d t|j ddrf|j jr5|j|d|dd|zd|d|ddd|zdd|j|d|d|d<|j jr)|jd|d|ddd|zdq|j|d|d|jddS)awrite variable declarations at the top of a function. the variable declarations are in the form of callable definitions for defs and/or name lookup within the function's context argument. the names declared are based on the names that are referenced in the function body, which don't otherwise have any explicit assignment operation. names that are assigned within the body are assumed to be locally-scoped variables and are not separately declared. for def callable definitions, if the def is a top-level callable then a 'stub' callable is generated which wraps the current Context into a closure. if the def is not top-level, it is fully rendered as a local closure. ci|] }|j| Sr,r?r6cs r! zA_GenerateRenderMethod.write_variable_declares..s???qz1???r#cg|] }|j Sr,rrs r!r8zA_GenerateRenderMethod.write_variable_declares..s B B BAQZ B B Br#r FNrz_import_ns = {}Trz_mako_get_namespace(context, z)._populate(_import_ns, z\s*,\s*rz%loop = __M_loop = runtime.LoopStack()rz = _mako_get_namespace(context, z = _import_ns.get(z , UNDEFINED)zif %s is UNDEFINED:rz = context[]rz&raise NameError("'%s' is not defined")z, context.get(z , UNDEFINED))z = context.get(z__M_writer = context.writer())rQr}r~ undeclared closuredefsr differencerlocally_declaredr9rdiscard intersectiongetattrr r has_importsrjitemsrEresplitrGrHwrite_def_declris_rootrrX) r'r_rlimit comp_identsto_writehas_loopidentnscomps r!rz-_GenerateRenderMethod.write_variable_declaress(@?k.>??? 55>>+"899>> B B!8!?!?!A!A B B B   &&{'DEE&&{'CDD = $ )H   V $ $ $ $H  ,,U33H   /?GG  L " "#4 5 5 5(,DM %!]5;;==   rr},,L***"EEHZx1HIIII   L L " "#J K K K2 2 E ##"5)= N,N++D+>>>>--dK-MMMM||~~N++D+>>>>--dK-MMMM$-222 &&?DuueeeL4=*:EBB}5 //$uueee-1E9"27%%?.FN       .. %uueeeUUU4 }5  //"27%%?.FN  ..AFN >?????r#cH|j}|}|d}|jsQt|jjdkst|jjdkr|ddn|dd|j d|dd |d |j d |dd |d |j d d S) z>write a locally-available callable referencing a top-level defTas_callrzcontext._locals(__M_locals)r rrrrzreturn render_rN) r?r@r>rAr_rrinsertr rr)r'rr_r? namedeclsnameargss r!rz$_GenerateRenderMethod.write_def_declBs%=1133 000>>{ *  1 2 2Q 6 64#566:: OOA< = = = = OOAy ) ) ) #((9:M:M:M:MNOOO &.hh0B0B0B0B C    t$$$$$r#c |}|j}|r|jd|z|jd|jdd|dt |jjdk}t|j dd}t|j d d}|j d d |s|s|r|j d | || }|||j||jD]} | ||j||||||jd|r#|||j|d|dddSdS)z?write a locally-available def callable inside an enclosing def.z&@runtime._decorate_inline(context, %s)rrrrrr/r0r1rrrrNFT)inliner)r@rr rr?rrArBrCrDrErFrXrrr:rdr{r|poprr) r'rr_rrrrPr/r1rys r!rz&_GenerateRenderMethod.write_inline_defUs,1133 N   L " "89D    !]]]CHHY,?,?,?,? @   t',--1++J@@AAdo))(G<<==  =     >x >6 > L # #$< = = =!((f(==  $$[111 $$[111 # #A  T " " " " !!### dHh??? t$$$    & &  '       r#Tc|s<|s:|s8|jd|r|jddd|s|s|r|s|r|jddn|jdd|r|jdd}|r!||jj|d}|jd|r#|s!||jj|d}|s|r|jd |zdS|jd |zddSdS) aJwrite the end section of a rendering function, either outermost or inline. this takes into account if the rendering function was filtered, buffered, etc. and closes the corresponding try: block if any, and writes code to retrieve captured content, apply filters, send proper return value. return ''finally:z!context.caller_stack._pop_frame()Nz__M_buf = context._pop_buffer()6__M_buf, __M_writer = context._pop_buffer_and_writer()__M_buf.getvalue()Fz return %s__M_writer(%s))r rrXcreate_filter_callablerBrCr9r)r'rr/rPr1 callstackres r!rz&_GenerateRenderMethod.write_def_finishs  x  L " "; / / /  '' CT  Kx K6 K 6   '' A ''L  L &&'JKKK$A //$)1e L " "4 ( ( (  //M0!U K6 K &&{Q77777 ''(81(z>_GenerateRenderMethod.write_cache_decorator..sj==**02[/@/@ABB.@DE/@/@/@/@r#c3|K|]6}|dr|dk|ddj|fV7dSr )rr)r6rnode_or_pagetags r!rz>_GenerateRenderMethod.write_cache_decorator..se  }}X&& ,.+<+<V_6r: ;+<+<+<+<  r#timeoutrrrrc^g|]*}d|vr"d|ddfdzzn|+S)rz%s=%srrz)rr5s r!r8z?_GenerateRenderMethod.write_cache_decorator..sM   FG#((G Q)A- . .   r#)rrz.context.get('local').cache._ctx_get_or_create(z , lambda:__M_z ), context, rtc$g|] \}}|d|dSrrsr,r6kvs r!r8z?_GenerateRenderMethod.write_cache_decorator..)KKK1aaa+KKKr#z __M_defname=rFzreturn z9__M_writer(context.get('local').cache._ctx_get_or_create(z ), context, c$g|] \}}|d|dSrr,rs r!r8z?_GenerateRenderMethod.write_cache_decorator..rr#z))r)r rrrFrr9rJrintrDrrundeclared_identifiersrrrrX) r'rrOrCr/r_rrcachekey cache_args pass_argsres `` r!rz+_GenerateRenderMethod.write_cache_decorators dd;<<<"488 d   = ,   -/A        %7       " "$'Z -B(C(C$D$DJy ! chhtnnnnEFFF  KO    $$ !88:: %   $ $  HHDDHHY''''GGKK 8H8H8J8JKKKDD  ++ ,aA L # #IM4 8 8 8 8 8 L # # # HHDDHHY''''GGKK 8H8H8J8JKKKDD      r#chd}d|vrF|rD|jjr|jjjj|z}|jjrd|vr|jj|z}|D]a}|dkr t jd|}|r*|dd\}}||} | |z}n||}|J|d|d}b|S) zwrite a filter-applying expression based on the filters present in the given filter names, adjusting for the global 'default' filter aliases as needed.cvtjd|rd|zStj||S)Nz decode\..+zfilters.)rmatchrDEFAULT_ESCAPESrFris r! locate_encodezC_GenerateRenderMethod.create_filter_callable..locate_encodes:x t,, ?!D((.224>>>r#ryz (.+?)(\(.*\))rrzNrr)r9rJrBrCrrr#group) r'rCtarget is_expressionr%emrfargsrs r!rz,_GenerateRenderMethod.create_filter_callable s  ? ? ? d?? @=(I=0<ADHD=0@S__=84?D , ,ACxx)1--A % wwq!}} u!M%((I!M!$$}}}!"FFF+FF r#c|j|jt|jsH|jj#t|jjjjst|jj rH| |j jd|j zd}|j d|zdS|j d|j zdS)Nz%sTr)r rrWrAescapesr9rJrBrCrr escapes_coderr)r'rres r!visitExpressionz%_GenerateRenderMethod.visitExpression)s !!$+...    A %1 -9>??24=0112 ++!&ty(8$A L " "#3a#7 8 8 8 8 8 L " "#3di#? @ @ @ @ @r#cjrs|jdjrP|jd|jd|jddSdS|jj|jjr!jdkrt|j}nj }|j| }|r4td|Dr7tfd|Dr|jddSdSdS)Nrzloop = __M_loop._exit()forc3bK|]*}t|tjtjfV+dSr&)r;rComment ControlLiners r!rz9_GenerateRenderMethod.visitControlLine..PsKq9#4i6K"LMMr#c3K|]?}t|tj|jp|jV@dSr&)r;rr4 is_ternarykeywordisend)r6rrs r!rz9_GenerateRenderMethod.visitControlLine..Ts_!!Y%:;;__QY//:17r#r) r8r rhas_loop_contextrrWr9rr7mangle_mako_loopr get_childrenall)r'rrchildrens ` r!visitControlLinez&_GenerateRenderMethod.visitControlLine;s : / L " "4 ( ( ($ - &&z222 &&'@AAA &&t,,,,, - - L % %dk 2 2 2}( !T\U-B-B'dl;;y L " "4 ( ( (((**H  /% / % / &&v..... / / / /r#c|j|j|jdt |jzdS)Nr)r rrWrrcontentrs r! visitTextz_GenerateRenderMethod.visitText\sF !!$+... /$t|2D2DDEEEEEr#c >t|jjdk}|r|jdd|jD]}|||rA|jddd||jjddzddSdS) Nrz#__M_writer = context._push_writer()rrrrrF)rArBrCr rXr{r|r)r'rrPrys r! visitTextTagz"_GenerateRenderMethod.visitTextTag`st',--1   L # #5v    # #A  T " " " "   L # #H --$)+?       r#c|js|j|j|j|jst |jjdkrl|j d|j dd d| DzdSdSdSdS)Nrrz0__M_locals_builtin_stored = __M_locals_builtin()z__M_locals.update(__M_dict_builtin([(__M_key, __M_locals_builtin_stored[__M_key]) for __M_key in [%s] if __M_key in __M_locals_builtin_stored]))rc,g|]}t|Sr,)rrs r!r8z3_GenerateRenderMethod.visitCode..sMMMAQMMMr#) ror rrrWr>rAr_rrrrrs r!rqz_GenerateRenderMethod.visitCodess}  L - - 4; .   ; 3t'7'H#I#IA#M#M  &&F &&GhhMM1J1J1L1LMMMNNO    #M#Mr#c(|j|j|jd}|r.|jd|jdd|ddS|jd|jdzdS)NrCzruntime._include_file(context, rz, _template_uri, rz1runtime._include_file(context, %s, _template_uri))r rrWrErFrr)r'rrCs r!visitIncludeTagz%_GenerateRenderMethod.visitIncludeTags !!$+...""6**   L " " ")&1114449      L " "C)&13     r#cdSr&r,rs r!rkz'_GenerateRenderMethod.visitNamespaceTag r#cdSr&r,rs r!rz!_GenerateRenderMethod.visitDefTagrIr#c~|jr$|jd|jzdS|d}|dgz }|jd|jz|jd|jdd|d |jd dS) Nz%s()Trr2zOif 'parent' not in context._data or not hasattr(context._data['parent'], '%s'):zcontext['self'].rrrru)rHr rr?r@r)r'rrs r!rz#_GenerateRenderMethod.visitBlockTags   ) L " "6DM#9 : : : : :44T4BBH  &H L " ">@D N    L " " ",0MMM388H;M;M;M;MN    L " "4 ( ( ( ( (r#c0||dSr& visitCallTagrs r!visitCallNamespaceTagz+_GenerateRenderMethod.visitCallNamespaceTags $r#c jddg j|d|ddjG fdd}|}|jD]}||j |j }jd d |zd}|rj d d j|jD]}|j ||ddd j ddd zdj dd j|jj dg|jdzddddS)Nzdef ccall(caller):bodyTrFcallerc,eZdZdZdZfdZdS)6_GenerateRenderMethod.visitCallTag..DefVisitorc0||dSr&rrs r!rzB_GenerateRenderMethod.visitCallTag..DefVisitor.visitDefTag  &&&&&r#c0||dSr&rrs r!rzD_GenerateRenderMethod.visitCallTag..DefVisitor.visitBlockTagrVr#c|d|js|j|jjvrj|j=dSdS)NFr)rrHrdr?r)rerbody_identifierscallable_identifiersrr's r!rzE_GenerateRenderMethod.visitCallTag..DefVisitor.visitDefOrBasesm%%d,@%OOO(1MM$-000=$4$@@@(4T]CCCA@r#Nr)rYrZrr'sr! DefVisitorrTse ' ' ' ' ' ' D D D D D D D D D Dr#r[z def body(%s):rrr)rrzccontext.caller_stack.nextcaller = runtime.Namespace('caller', context, callables=ccall(__M_caller))rrz&context.caller_stack.nextcaller = None)r rr_r add_declaredr:rdr{r|rrKr@rrXrrrrWr expression) r'rr[rrybodyargsr/rYrZrs ` @@@r!rNz"_GenerateRenderMethod.visitCallTags 3444#/66tD6II/66tE6JJ %%h/// $$%5666 D D D D D D D D D D D D D jll " "A  S ! ! ! ! !!###>::<< (1C1CCDDD  F L # #$rArCrqrGrkrrrOrNr,r#r!rrcs /)/)/)b   "))X)k<k<k.sHHHqAFHHHr#z'Reserved words declared in template: %srsr,)r;r NamespaceTagr}rr SetLikeDictrr~rrrrrr9rrr|rrrNameConflictErrorr)r'r9rparentr illegal_namess r!r(z_Identifiers.__init__s  $ 677 L # $($4$6$6!! ((UHHF,>,E,E,G,GHHHIIU6233U6344  K$(M$7$78I$J$JDM%)$4$K$Kv7J$K$K!!EEDM $ 0 2 2D   %% !$ !$"% +--      % % % 4AA  !    .9))M**+   r#c *t|j||fi|S)zUcreate a new Identifiers for a new Node, with this Identifiers as the parent.)rr9)r'rrLs r!rz_Identifiers.branch=s DM4@@@@@r#c~t|j|jSr&)r}rr~rrr^s r!rQz_Identifiers.defsCs04$**4+;<<CCEEFFFr#c &dt|jdt|jdt|jdd|jDdd|jDd|jd S) NzIdentifiers(declared=z, locally_declared=z , undeclared=z, topleveldefs=cg|] }|j Sr,rirs r!r8z)_Identifiers.__repr__..Ps<<.Qs;;;A;;;r#z, argumentdeclared=r)rrrrrrrrr^s r!__repr__z_Identifiers.__repr__Gs T]####T*++++T_%%%%<<!2!9!9!;!;<<<<<;;!1!8!8!:!:;;;;;&&&  r#c|D]C}|dkr;||j|jvr|j|D|D]}|j|dS)zlupdate the state of this Identifiers with the undeclared and declared identifiers of the given node.r N)rrr~rrrrr'rrs r!check_declaredz_Identifiers.check_declaredVs0022 + +E !!e4=3F3F%44''##E***..00 - -E  ! % %e , , , , - -r#c|j|||jvr|j|dSdSr&)rrrremove)r'rs r!r\z_Identifiers.add_declaredbsI %   DO # # O " "5 ) ) ) ) ) $ #r#c0||dSr&rqrs r!r/z_Identifiers.visitExpressiong D!!!!!r#c0||dSr&rurs r!r>z_Identifiers.visitControlLinejrvr#c|jsH|||j||_dSdSr&)rorqrr~rrs r!rqz_Identifiers.visitCodemsZ}     % % %$($9$?$?))++%%D ! ! !  r#cZ|j|ur|jD]}||dSdSr&)rr{r|r'rrys r!rkz_Identifiers.visitNamespaceTagtsK 9  Z ' '  &&&&   ' 'r#c||j}|||j<|1||ur/|js|jr#tjd|jzfi|jdSdSdS)Nz<%%def or %%block named '%s' already exists in this template.)rFr?rGrrr)r' collectionrexistings r!_check_name_existsz_Identifiers._check_name_exists|s>>$-00$( 4=!  $$%"*"3%-+-1];'  ! $$$$r#c"|r#|js||j|n$||jur||j||D]C}|dkr;||j|j vr|j |D||jurP| D]}|j ||jD]}||dSdSNr )rrHr~rrrrrr~rrrrrr{r|r'rrrys r!rz_Identifiers.visitDefTagsA <<>> <$"3 <  # #D$5t < < < <  " "  # #D$4d ; ; ;0022 + +E !!e4=3F3F%44''##E*** 49  2244 2 2&**51111Z ' '  &&&&   ' 'r#cp||jur|jst|jtjr-t jd|jd|jjdfi|jt|jtj tj fr t jd|jdfi|j| D]C}|dkr;||j |jvr|j|D|js;||j||j|jn$||jur||j||D]}|j||jD]}||dS)Nz Named block 'z' not allowed inside of def ''z#' not allowed inside of <%call> tagr )rrHr;rr<rrrOrCallTagCallNamespaceTagrrr~rrrr~rr?rrrr{r|rs r!rz_Identifiers.visitBlockTags ty ): $)Y%566  11yyy$)...2+  I-y/IJ !11yyy#+ 0022 + +E !!e4=3F3F%44''##E***  <  # #D$5t < < < O   . . . .  " "  # #D$4d ; ; ;..00 . .E  " & &u - - - - # #A  T " " " " # #r#c|D]C}|dkr;||j|jvr|j|DdSr)rrr~rrrrps r!rCz_Identifiers.visitTextTagsq0022 + +E !!e4=3F3F%44''##E***  + +r#c0||dSr&rurs r!rGz_Identifiers.visitIncludeTagrvr#c|D]}|j|||dSr&)rrrrqrps r!rmz_Identifiers.visitPageTagsQ..00 . .E  " & &u - - - - D!!!!!r#c0||dSr&rMrs r!rOz"_Identifiers.visitCallNamespaceTags $r#c||jur|D]C}|dkr;||j|jvr|j|D|D]}|j||j D]}| |dS|D]C}|dkr;||j|jvr|j|DdSr) rrrr~rrrrrr{r|rs r!rNz_Identifiers.visitCallTagsL 49  4466 / /I%%%t}7J7J)88++O''...2244 2 2&**51111Z ' '  &&&& ' '4466 / /I%%%t}7J7J)88++O''...  / /r#)NNF)r)r*r+r_r(rr`rQrnrqr\r/r>rqrkr~rrrCrGrmrOrNr,r#r!rrsEMMAAAAFAAA GGXG     - - -*** """"""'''   '''( # # #D+++""""""    /////r#rz^for\s+((?:\(?)\s*(?:\(?)\s*[A-Za-z_][A-Za-z_0-9]*(?:\s*,\s*(?:[A-Za-z_][A-Za-z_0-9]*),??)*\s*(?:\)?)(?:\s*,\s*(?:(?:\(?)\s*[A-Za-z_][A-Za-z_0-9]*(?:\s*,\s*(?:[A-Za-z_][A-Za-z_0-9]*),??)*\s*(?:\)?)),??)*\s*(?:\)?))\s+in\s+(.*):ct}|||jrd|jd_t |j}|rE|d| dzdd| dz}ntd|jz|j}|S) zconverts a for loop into a context manager wrapped around a for loop when access to the `loop` variable has been detected in the for loop body Tr]zloop = __M_loop._enter(%s)rzrzfor %s in loop:rzCouldn't apply loop context: %s) LoopVariabler|detectedr{r9 _FOR_LOOPr#rrXr& SyntaxError)rr loop_variabler#rs r!r:r:s!NNM &&& *. 2' **  M   ,u{{1~~=    %u{{1~~5DD?$)KLL Ly Kr#c0eZdZdZdZdZdZdZdZdS)rzQA node visitor which looks for the name 'loop' within undeclared identifiers.cd|_dS)NF)rr^s r!r(zLoopVariable.__init__ s  r#cd|vr d|_dS|D]}||dS)Nr T)rrr;r|rzs r!_loop_reference_detectedz%LoopVariable._loop_reference_detecteds` T0022 2 2 DMMM&&(( ' '  &&&& ' 'r#c0||dSr&rrs r!r>zLoopVariable.visitControlLine %%d+++++r#c0||dSr&rrs r!rqzLoopVariable.visitCoderr#c0||dSr&rrs r!r/zLoopVariable.visitExpressionrr#N) r)r*r+r_r(rr>rqr/r,r#r!rrsi''',,,,,,,,,,,r#r)r_rYrrmakorrrrr mako.pygenrrrr~RESERVED_NAMES frozensetr"rrrrr:rr,r#r!rs $$$$$$ !"23V$**+<==  9;;%%%%P--------8P P P P P P P P fl/l/l/l/l/l/l/l/^ BJ&   .,,,,,,,,,,r#