ó øÇšPc @s dZddlZddlZddlmZddlmZmZmZm Z m Z dZ e dddgƒZ eeeeeeeeefd „ Zd efd „ƒYZd efd „ƒYZdefd„ƒYZejdƒZd„Zdefd„ƒYZdS(sVprovides functionality for rendering a parsetree constructing into module source code.iÿÿÿÿN(t PythonPrinter(tutiltastt parsetreetfilterst exceptionsitcontexttloopt UNDEFINEDc Cstj r+t|tƒr+|j|ƒ}ntjƒ} t| ƒ} t| t||||||||| | | ƒ |ƒ| j ƒS(s[Generate module source code given a parsetree node, uri, and optional source filename( Rtpy3kt isinstancetunicodetencodetFastEncodingBufferRt_GenerateRenderMethodt_CompileContexttgetvalue(tnodeturitfilenametdefault_filterstbuffer_filterstimportstsource_encodingtgenerate_magic_commenttdisable_unicodetstrict_undefinedt enable_looptreserved_namestbuftprinter((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytcompiles$  RcBseZd„ZRS(c Csg||_||_||_||_||_||_||_||_| |_| |_ | |_ dS(N( RRRRRRRRRRR( tselfRRRRRRRRRRR((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt__init__As          (t__name__t __module__R!(((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR@sRcBseZdZd„Zed„ƒZd„Zd„Zd„Zd„Z d„Z e dd„Z d „Zd „Zd „Zed „Ze e d „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s]A template visitor object which generates the full module source for a template. c Cs7||_d|_||_||_dg|_t|tjtj fƒ|_ |j rðd|j }|j ƒ}t |jjƒdk}t|jjddƒƒ}t|jjddƒƒ}d} d} |jr©|j r©|dg7}q©n¹|jƒ} |jj} d}| dk r| jj ƒ}| jjsE|dg7}nt| jjddƒƒ}|jjp„t| jjd dƒƒ|j_ndg}t}t}}|dkrÁd g}n gd g|D] } | ^qÏ}|j| pð||||||ƒ| dk r3x!| D]}t|||ƒqWndS( Niÿÿÿÿs render_%sitbufferedtFalsetcacheds **pageargst render_bodyRR(Rtlast_source_linetcompilerRtNonetidentifier_stackR RtDefTagtBlockTagtin_deftfuncnametget_argument_expressionstlent filter_argstargstevalt attributestgettis_blockt is_anonymoustwrite_topleveltpagetagt body_decltkwargsRR%twrite_render_callableR( R RR)RtnameR3tfilteredR$R&tdefsR:ta((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR!^sP                      cCs |jdS(Niÿÿÿÿ(R+(R ((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt identifierssc seg‰i‰g‰dg}dˆj_dtf‡‡‡‡fd†ƒY}|ƒ}x!ˆjjD]}|j|ƒqbWˆˆj_tƒ}x#ˆD]}|j |j ƒƒ}q•Wt ˆjƒ}||_ ˆjj rˆjjrˆjjdˆjjƒnˆjjdƒˆjjdƒˆjjdƒˆjjdƒˆjjdtƒˆjjd tjƒƒˆjjd ˆjjƒˆjjd ˆjjƒˆjjd ˆjjƒˆjjd ˆjjƒˆjjrHd}x2ˆjjD]$}||d7}ˆjj|ƒqöWtj|ddddddddƒ} nd} |jˆjƒ} |jj | jƒ|_|j jdƒ| r¤|j j| j ƒn|ˆj_ˆjjdg| jjƒD]}|j^q̃ˆjj dƒt!ˆƒrˆj"ˆƒnt!ˆƒr<ˆj#ˆƒˆj$ˆdƒnt!ˆƒrXˆj#ˆƒn| jjƒS(sxTraverse a template structure for module-level directives and generate the start of module-level code. t FindTopLevelcsDeZ‡fd†Z‡fd†Z‡fd†Z‡fd†ZRS(csˆj|ƒdS(N(tappend(tsR(tinherit(s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytvisitInheritTag¡scs|ˆ|j(RER(t namespaces(s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytvisitNamespaceTag£scs|ˆj_dS(N(R)R:(RER(R (s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt visitPageTag¥scs|jrˆj|ƒndS(N(tismoduleRD(RER(t module_code(s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt visitCode§s (R"R#RGRIRJRM((RFRLRHR (s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRC ss# -*- encoding:%s -*-s(from mako import runtime, filters, cachesUNDEFINED = runtime.UNDEFINEDs__M_dict_builtin = dicts__M_locals_builtin = localss_magic_number = %rs_modified_time = %rs_enable_loop = %rs_template_filename = %rs_template_uri = %rs_source_encoding = %rts tsourcetlinenoitposRstemplate defined importsRs _exports = %rs iÿÿÿÿN(%R*R)R:tobjectRtnodestaccept_visitorRHtsettuniontdeclared_identifierst _IdentifierstdeclaredRRRt writelinet MAGIC_NUMBERttimeRRRRRt PythonCodetbrancht topleveldefstaddtupdateRBtvaluesR>twriteR1twrite_module_codetwrite_namespacest write_inherit( R tencodingRCtftnt module_identtmodule_identifiersRtimptimpcodetmain_identifiers((RFRLRHR s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR9”sz  %                $    c Csý|jr2|j}|r2|jjd|ƒq2n|jjd|dj|ƒfddƒ|sm|sm|r€|jjdƒn|jj|jj j |j ƒƒ|j s¸|j j rÞd|krÞ|jdj jd ƒn|j r[t|j jƒd kst|j j ƒd kr[|jjd djg|j j D]}d ||f^q7ƒƒn|j|j d tƒx!|j jD]} | j|ƒq~W|j|j |||ƒ|jjdƒ|jjdƒ|rù|j|||||j d tƒndS(snwrite a top-level render callable. this could be the main render() method or that of a top-level def.s@runtime._decorate_toplevel(%s)s def %s(%s):t,s/__M_caller = context.caller_stack._push_frame()stry:scontext._push_buffer()s **pageargsiÿÿÿÿtpageargsis!__M_locals = __M_dict_builtin(%s)s%s=%sttoplevels N(R.t decoratorRRZt writelinestjoinR+RDR)RBR^RR7targument_declaredR`R1tlocally_assignedtwrite_variable_declarestTrueRSRTtwrite_def_finishR*Rctwrite_cache_decorator( R RR>R3R$R?R&RrtxRi((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR=ñsB     "  .cCs5x.|D]&}|j|ƒ|jj|jƒqWdS(sewrite module-level template code, i.e. that which is enclosed in <%! %> tags in the template.N(twrite_source_commentRtwrite_indented_blockttext(R RLRi((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRd#s  cCs(|jjddd|jddƒdS(s:write the module-level inheritance-determination callable.s%def _mako_inherit(template, context):s"_mako_generate_namespaces(context)s8return runtime._inherit_from(context, %s, _template_uri)tfileN(RRstparsed_attributesR*(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRf*s   c s‚ˆjjddddddddƒˆjjdƒx|jƒD] }|jjdƒritˆj_ nˆj |ƒt |j ƒrDˆjjdƒg‰ˆjj j|ƒ‰tˆ_d tf‡‡‡fd †ƒY}|ƒ}x|j D]}|j|ƒqîWˆjjd d jˆƒƒˆjjdƒtˆ_d }nd}d|jkr‹ˆjjd|j|jjddƒ|fƒn^d|jkr̈jjd|j||jjddƒfƒnˆjjd|j|fƒt|jjddƒƒrˆjjd|jƒnˆjjdt|jƒƒˆjjdƒqBWt |ƒsnˆjjdƒnˆjjdƒdS(s5write the module-level namespace-generating callable.s'def _mako_get_namespace(context, name):stry:s+return context.namespaces[(__name__, name)]sexcept KeyError:s"_mako_generate_namespaces(context)s'def _mako_generate_namespaces(context):timportsdef make_namespace():t NSDefVisitorcs/eZd„Zd„Z‡‡‡fd†ZRS(cSs|j|ƒdS(N(tvisitDefOrBase(RER((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt visitDefTagMscSs|j|ƒdS(N(Rƒ(RER((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt visitBlockTagPscsK|jr!tjd|j‚nˆj|ˆdtƒˆj|jƒdS(Ns.Can't put anonymous blocks inside <%namespace>tnested(R8RtCompileExceptiontexception_kwargstwrite_inline_defR%RDR/(RER(texportRBR (s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRƒSs  (R"R#R„R…Rƒ((RŠRBR (s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR‚Ls  s return [%s]Rosmake_namespace()R*Rsns = runtime.TemplateNamespace(%r, context._clean_inheritance_tokens(), templateuri=%s, callables=%s, calling_uri=_template_uri)tmodulesyns = runtime.ModuleNamespace(%r, context._clean_inheritance_tokens(), callables=%s, calling_uri=_template_uri, module=%s)shns = runtime.Namespace(%r, context._clean_inheritance_tokens(), callables=%s, calling_uri=_template_uri)t inheritableR%scontext['self'].%s = nss'context.namespaces[(__name__, %s)] = nss tpassN(RRsR*RZRbR5thas_keyRxR)thas_ns_importsR|R1RSRBR^R.RRRTRtR%R€R>R6R4treprRc(R RHRR‚tvisRit callable_name((RŠRBR s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRe5sf    "         c CsTtg|jD]}|j|f^q ƒ}tƒ}|j|jƒ}|jg|jjƒD]}|j^q\ƒ}|j|j ƒ}|j|j ƒ}|j j rÀd|k}|j dƒnt}|dk rä|j|ƒ}n|rƒt|j dtƒrƒ|jjdƒt|j _xe|j jjƒD]N\}} | jjdƒr.|jjd|tjd| jdƒfƒq.q.Wn|rœ|jjdƒnx¡|D]™}||kr5||} | jrý| jsä|j| |ƒq2|j| |dtƒq<| j ƒr|j| |ƒq<|j| |dtƒq£||j jkrd|jjd ||fƒq£t|j dtƒré|j j!rÉ|jj"d ||fd |d d ||fdd|ddƒq<|jjd|||fƒq£|j j!r"|jj"d d ||fdd|dƒq£|jjd||fƒq£W|jjdƒdS(swrite 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. RRs_import_ns = {}Rs:_mako_get_namespace(context, %r)._populate(_import_ns, %r)s\s*,\s*s%loop = __M_loop = runtime.LoopStack()R†s%%s = _mako_get_namespace(context, %r)s"%s = _import_ns.get(%r, UNDEFINED)sif %s is UNDEFINED:stry:s%s = context[%r]sexcept KeyError:s&raise NameError("'%s' is not defined")s3%s = _import_ns.get(%r, context.get(%r, UNDEFINED))s%s = context.get(%r, UNDEFINED)s__M_writer = context.writer()N(#tdictR@R/RURVt undeclaredt closuredefsRbt differenceRutlocally_declaredR)RtdiscardR%R*t intersectiontgetattrRRZRxt has_importsRHt iteritemsR5RŽtretsplitR7R8twrite_def_declR‰tis_rootRRs( R RBRqtlimittct comp_identstto_writethas_looptidenttnstcomp((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRw’s‚+ (     (                    cCs<|j|jkr8|jjd|jƒ|j|_ndS(s]write a source comment containing the line number of the corresponding template line.s# SOURCE LINE %dN(R(RPRRZ(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR|scCsÞ|j}|jƒ}|jdtƒ}|j rtt|jjƒdksat|jjƒdkrt|jddƒn|jddƒ|j j d|dj |ƒfƒ|j j d|dj |ƒfƒ|j j dƒdS( s>write a locally-available callable referencing a top-level deftinclude_defaultsiscontext.locals_(__M_locals)Rs def %s(%s):Rosreturn render_%s(%s)N( R/R0R%R.R1RBRvRutinsertRRZRtR*(R RRBR/t namedeclstnameargs((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRŸs   # c Cs™|jƒ}|j}|r2|jjd|ƒn|jjd|jdj|ƒfƒt|jjƒdk}t |j j ddƒƒ}t |j j ddƒƒ}|jj dd ƒ|sË|sË|rÞ|jj d ƒn|j |d |ƒ}|j|ƒ|jj|ƒx|jD]} | j|ƒqW|jjƒ|j||||ƒ|jjdƒ|r•|j||j|t|d td tƒndS(s?write a locally-available def callable inside an enclosing def.s&@runtime._decorate_inline(context, %s)s def %s(%s):RoiR$R%R&s/__M_caller = context.caller_stack._push_frame()stry:scontext._push_buffer()R†tinlineRqN(R0RrRRZR/RtR1R2R3R4R5R6RsR^RwR+RDRSRTtpopRyR*RzR%Rx( R RRBR†R«RrR?R$R&Ri((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR‰(s8          c CsM| rG| rG| rG|jjdƒ|rG|jjddd ƒqGn|sY|sY|rI|se|r{|jjddƒn|jjddƒ|r§|jjdƒnd}|rÑ|j|jj|tƒ}n|jjd ƒ|r | r |j|jj |tƒ}n|s|r/|jjd|ƒqI|jjd|dƒnd S( sJwrite 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.s return ''sfinally:s!context.caller_stack._pop_frame()s__M_buf = context._pop_buffer()s6__M_buf, __M_writer = context._pop_buffer_and_writer()s__M_buf.getvalue()s return %ss__M_writer(%s)N( RRZRsR*tcreate_filter_callableR2R3R%R)R(R RR$R?R&t callstackRE((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRyPs<           c s;ˆjjd||fƒˆjjdt|ƒƒ}i} ˆjjdk rv| j‡fd†ˆjjjDƒƒn| j‡fd†ˆjDƒƒd| kr¿t t | dƒƒ| d“sc3sA|]7}|jdƒr|dkr|dˆj|fVqdS(R²R±iN(R³R€(R´Rµ(tnode_or_pagetag(s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pys ›sttimeouts def %s(%s):Rot=s%s=%siiRqR¡s`context.get('local').cache._ctx_get_or_create(%s, lambda:__M_%s(%s), context, %s__M_defname=%r)RNs%s=%s, sreturn sk__M_writer(context.get('local').cache._ctx_get_or_create(%s, lambda:__M_%s(%s), context, %s__M_defname=%r))s return ''N(RRZR€R6RR)R:R*RatintR4RtRžRwtundeclared_identifierstitemsR¯RR%Rs(R R¶R>R3R$RBR­Rqtcachekeyt cache_argsRAt pass_argstktvRE((R¶R s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRz†sJ    #@  ,    ,c s‡fd†}d|krk|rkˆjjrFˆjjjj|}nˆjjrhˆjj|}qhqknx|D]•}|dkrŠqrntjd|ƒ}|rÓ|jddƒ\}}||ƒ} | |}n$|} ||ƒ}|dk s÷t ‚d||f}qrW|S(s§write a filter-applying expression based on the filters present in the given filter names, adjusting for the global 'default' filter aliases as needed.csPtjd|ƒrd|Sˆjjr9tjj||ƒStjj||ƒSdS(Ns decode\..+sfilters.(RtmatchR)RRtNON_UNICODE_ESCAPESR6tDEFAULT_ESCAPES(R>(R (s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt locate_encodeÑs  Ris (.+?)(\(.*\))iis%s(%s)N( R)R:R2R3RRRÁtgroupR*tAssertionError( R R3ttargett is_expressionRÄtetmR¦tfargsRhR{((R s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR¯Ìs(        cCs¬|j|ƒt|jƒsX|jjdk rFt|jjjjƒsXt|jjƒr‘|j |j jd|j t ƒ}|j jd|ƒn|j jd|j ƒdS(Ns%ss__M_writer(%s)(R|R1tescapesR)R:R*R2R3RR¯t escapes_codeR~RxRRZ(R RRE((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytvisitExpressionïs csˆjrX|jjdƒˆjr |jjdƒ|jjdƒ|jjdƒq n´|jˆƒ|jjr•ˆjdkr•t ˆ|jƒ}n ˆj }|jj|ƒˆj ƒ}| sùt j d„|Dƒƒr t j ‡fd†|Dƒƒr |jjdƒndS(Nsfinally:sloop = __M_loop._exit()tforcss*|] }t|tjtjfƒVqdS(N(R RtCommentt ControlLine(R´R¢((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pys sc3s<|]2}t|tjƒrˆj|jƒp3|jVqdS(N(R RRÑt is_ternarytkeywordtisend(R´R¢(R(s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pys sR(RÔRRZR*thas_loop_contextR|R)RRÓtmangle_mako_loopR~t get_childrenRtall(R RR~tchildren((Rs=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytvisitControlLineþs$        cCs.|j|ƒ|jjdt|jƒƒdS(Ns__M_writer(%s)(R|RRZRtcontent(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt visitTexts cCs”t|jjƒdk}|r4|jjddƒnx|jD]}|j|ƒq>W|r|jjddd|j|jjdtƒdƒndS(Nis#__M_writer = context._push_writer()stry:sfinally:s6__M_buf, __M_writer = context._pop_buffer_and_writer()s__M_writer(%s)s__M_buf.getvalue()( R1R2R3RRsRSRTR¯R%R*(R RR?Ri((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt visitTextTags"    cCs¡|js|j|ƒ|jj|jƒ|j rt|jjƒdkr|jj dƒ|jj ddj g|j ƒD]}t |ƒ^qzƒƒqndS(Nis0__M_locals_builtin_stored = __M_locals_builtin()s__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]))Ro( RKR|RR}R~R.R1RBRvRZRtRWR(R RR{((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRM4s  "  cCsh|j|ƒ|jjdƒ}|rI|jjd|jd|fƒn|jjd|jdƒdS(NR3s5runtime._include_file(context, %s, _template_uri, %s)Rs1runtime._include_file(context, %s, _template_uri)(R|R5R6RRZR€(R RR3((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytvisitIncludeTagFs   cCsdS(N((R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRIRscCsdS(N((R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR„UscCs“|jr#|jjd|jƒnl|jdtƒ}|dg7}|jjd|jƒ|jjd|jdj|ƒfƒ|jjdƒdS(Ns%s()R©s **pageargssOif 'parent' not in context._data or not hasattr(context._data['parent'], '%s'):scontext['self'].%s(%s)Ros (R8RRZR/R0R%Rt(R RR¬((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR…Xs     cCs|j|ƒdS(N(t visitCallTag(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytvisitCallNamespaceTagescsêˆjjdƒdg‰ˆjj|dtƒ‰ˆj|dtƒ‰ˆjdƒˆjjˆƒdt f‡‡‡‡fd†ƒY}|ƒ}x|j D]}|j |ƒq›Wˆjj ƒ|j jƒ}ˆjjddj|ƒƒt}|r ˆjjd d ƒnˆjˆƒˆjjˆƒx|j D]}|j ˆƒq4Wˆjj ƒˆj||ttd tƒˆjjdd djˆƒdƒˆjjd d ƒˆj|ƒˆjjdˆjg|jtƒdddƒdS(Nsdef ccall(caller):tbodyR†tcallert DefVisitorcs2eZd„Zd„Z‡‡‡‡fd†ZRS(cSs|j|ƒdS(N(Rƒ(RER((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR„xscSs|j|ƒdS(N(Rƒ(RER((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR…{scsXˆj|ˆdtƒ|js2ˆj|jƒn|jˆjkrTˆj|j=ndS(NR†(R‰R%R8RDR/R•(RER(tbody_identifierstcallable_identifiersRŠR (s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRƒ~s  (R"R#R„R…Rƒ((RäRåRŠR (s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRãws  s def body(%s):Roscontext._push_buffer()stry:R°s return [%s]sccontext.caller_stack.nextcaller = runtime.Namespace('caller', context, callables=ccall(__M_caller))s__M_writer(%s)sfinally:s&context.caller_stack.nextcaller = None(RRZRBR^RxR%t add_declaredR+RDRRRSRTR®R;R0RtRsRwRyR*R|R¯t expression(R RRãR‘RitbodyargsR$((RäRåRŠR s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRßksL  %           N( R"R#t__doc__R!tpropertyRBR9R=RdRfReR%R*RwR|RŸR‰RxRyRzR¯RÎRÚRÜRÝRMRÞRIR„R…RàRß(((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRYs4 2 ] 2  ]~   ) 7D #        RXcBs¿eZdZdded„Zd„Zed„ƒZd„Z d„Z d„Z d„Z d„Z d „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„ZRS(sCtracks the status of identifier names as template code is rendered.cCs|dk rÇt|tjƒr<tƒ|_tjƒ|_qât|jƒj g|j j ƒD]}|j ^q[ƒj |j ƒj |jƒ|_|r¯|jj |jƒ|_ntj|j|_ntƒ|_tjƒ|_||_tƒ|_tƒ|_ tƒ|_tƒ|_tjƒ|_ ||_|dk rO|j|ƒn|jjj|j ƒ}|rŒtjddj|ƒƒ‚ndS(Ns'Reserved words declared in template: %ss, (R*R Rt NamespaceTagRURYRt SetLikeDictR_RVR•RbR>R—RuR”R)RvRRTRR™RtNameConflictErrorRt(R R)RtparentR†R¢t illegal_names((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR!·s8  (           cKst|j|||S(sWcreate a new Identifiers for a new Node, with this Identifiers as the parent.(RXR)(R RR<((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR^÷scCst|jj|jƒjƒƒS(N(RUR_RVR•Rb(R ((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR@ýscCsvdt|jƒt|jƒt|jƒg|jjƒD]}|j^q7g|jjƒD]}|j^qY|jfS(NsrIdentifiers(declared=%r, locally_declared=%r, undeclared=%r, topleveldefs=%r, closuredefs=%r, argumentdeclared=%r)( tlistRYR—R”R_RbR>R•Ru(R R¢((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt__repr__s   ""cCs|xN|jƒD]@}|dkr ||jj|jƒkr |jj|ƒq q Wx$|jƒD]}|jj|ƒq^WdS(spupdate the state of this Identifiers with the undeclared and declared identifiers of the given node.RN(RºRYRVR—R”R`RW(R RR¦((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pytcheck_declared s  cCs6|jj|ƒ||jkr2|jj|ƒndS(N(RYR`R”tremove(R R¦((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRæscCs|j|ƒdS(N(Rò(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRÎscCs|j|ƒdS(N(Rò(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRÚ scCs8|js4|j|ƒ|jj|jƒƒ|_ndS(N(RKRòRvRVRW(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRM#s   cCs7|j|kr3x!|jD]}|j|ƒqWndS(N(RRSRT(R RRi((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRI)scCsl|j|jƒ}|||j<|dk rh||k rh|jsI|jrhtjd|j|j‚ndS(Ns<%%def or %%block named '%s' already exists in this template.(R6R/R*R7RR‡Rˆ(R t collectionRtexisting((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt_check_name_exists1s   cCs|jƒr,|j r,|j|j|ƒn%||jk rQ|j|j|ƒnxN|jƒD]@}|dkr^||jj|j ƒkr^|j j |ƒq^q^W||jkrüx$|j ƒD]}|j j |ƒq¾Wx!|jD]}|j|ƒqâWndS(NR(R R8RöR_RR•RºRYRVR—R”R`RWRuRSRT(R RR¦Ri((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR„<s cCs||jk rœ|j rœt|jtjƒrYtjd|j|jjf|j‚qœt|jtj tj fƒrœtjd|jf|j‚qœnxN|j ƒD]@}|dkr©||j j |jƒkr©|jj|ƒq©q©W|js|j|j|ƒ|jj|jƒn%||jk rD|j|j|ƒnx$|jƒD]}|jj|ƒqQWx|jD]}|j|ƒquWdS(Ns/Named block '%s' not allowed inside of def '%s's3Named block '%s' not allowed inside of <%%call> tagR(RR8R RR,RR‡R>RˆtCallTagtCallNamespaceTagRºRYRVR—R”R`RöR_R/R•RWRuRSRT(R RR¦Ri((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR…Os0 "   cCsUxN|jƒD]@}|dkr ||jj|jƒkr |jj|ƒq q WdS(NR(RºRYRVR—R”R`(R RR¦((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRÝls cCs|j|ƒdS(N(Rò(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRÞrscCs8x$|jƒD]}|jj|ƒq W|j|ƒdS(N(RWRuR`Rò(R RR¦((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRJuscCs|j|ƒdS(N(Rß(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRàzscCs||jkr«xN|jƒD]@}|dkr||jj|jƒkr|jj|ƒqqWx$|jƒD]}|jj|ƒqmWxr|j D]}|j |ƒq‘WnQxN|jƒD]@}|dkr¸||jj|jƒkr¸|jj|ƒq¸q¸WdS(NR( RRºRYRVR—R”R`RWRuRSRT(R RR¦Ri((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRß}s  N(R"R#RéR*R%R!R^RêR@RñRòRæRÎRÚRMRIRöR„R…RÝRÞRJRàRß(((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRX´s&@            si^for\s+((?:\(?)\s*[A-Za-z_][A-Za-z_0-9]*(?:\s*,\s*(?:[A-Za-z_][A-Za-z0-9_]*),??)*\s*(?:\)?))\s+in\s+(.*):cCstƒ}|j|ƒ|jrt|jd_tj|jƒ}|rz|j d|j dƒdƒd|j dƒ}q™t d|jƒ‚n |j}|S(s—converts 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 iÿÿÿÿsloop = __M_loop._enter(%s)istry:sfor %s in loop:isCouldn't apply loop context: %s( t LoopVariableRTtdetectedRxRSRÕt _FOR_LOOPRÁR~RsRÅt SyntaxError(RRt loop_variableRÁR~((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRÖ“s    RùcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sQA node visitor which looks for the name 'loop' within undeclared identifiers.cCs t|_dS(N(R%Rú(R ((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyR!®scCsFd|jƒkrt|_n$x!|jƒD]}|j|ƒq+WdS(NR(RºRxRúR×RT(R RRi((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyt_loop_reference_detected±s cCs|j|ƒdS(N(Rþ(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRÚ¸scCs|j|ƒdS(N(Rþ(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRM»scCs|j|ƒdS(N(Rþ(R R((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRξs(R"R#RéR!RþRÚRMRÎ(((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyRùªs     (RéR\Rt mako.pygenRtmakoRRRRRR[RUtRESERVED_NAMESR*RxR%RRRRRRXRûRÖRù(((s=/opt/alt/python27/lib/python2.7/site-packages/mako/codegen.pyts4  ( ÿÿÿ^Ú