Ñò -!Lc @sºdZddkZddkZddklZddklZlZlZl Z dZ e e e e e e e d„Zdefd„ƒYZd efd „ƒYZd efd „ƒYZdS( sVprovides functionality for rendering a parsetree constructing into module source code.iÿÿÿÿN(t PythonPrinter(tutiltastt parsetreetfiltersic Cs{ti o#t|tƒo|i|ƒ}ntiƒ} t| ƒ} t| t||||||||ƒ|ƒ| i ƒ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_unicodetbuftprinter((s0/usr/lib/python2.6/site-packages/mako/codegen.pytcompiles  R cBseZd„ZRS(c CsL||_||_||_||_||_||_||_||_dS(N(RRRRRRRR( tselfRRRRRRRR((s0/usr/lib/python2.6/site-packages/mako/codegen.pyt__init__5s       (t__name__t __module__R(((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR 4sR cBsûeZdZd„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„ZRS(seA template visitor object which generates the full module source for a template. c Csô||_d|_||_||_dg|_t|tiƒ|_ |i ozd|i }|i i ƒ}t |iiƒdj}t|iiddƒƒ}t|iiddƒƒ}d} d} n‘|iƒ} |ii} d}| dj oL| ii ƒ}| iip|dg7}nt| iiddƒƒ}ndg}t}t}}|djo d g}n)g} d g|D] } | | q…~ }|i| p||||||ƒ| dj o%x"| D]}t|||ƒqÒWndS( Niÿÿÿÿtrender_itbufferedtFalsetcachedt render_bodys **pageargstcontext(Rtlast_source_linetcompilerR tNonetidentifier_stackRRtDefTagtin_deftnamet function_decltget_argument_expressionstlent filter_argstargstevalt attributestgettwrite_topleveltpagetagt body_decltkwargsRtwrite_render_callableR ( RRR$R R)R.tfilteredRR tdefsR3t_[1]ta((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRLsH                (   cCs |idS(Niÿÿÿÿ(R&(R((s0/usr/lib/python2.6/site-packages/mako/codegen.pyt identifiersxsc sjg‰h‰g‰dg}dˆi_dtf‡‡‡‡fd†ƒY}|ƒ}x!ˆiiD]}|i|ƒqbWˆˆi_tƒ}x#ˆD]}|i |i ƒƒ}q•Wt ƒ}||_ ˆii o+ˆiioˆiidˆiiƒnˆiidƒˆiidƒˆiidƒˆiidƒˆiidtƒˆiid tiƒƒˆiid ˆiiƒˆiid ˆiiƒˆiid ƒˆiid ˆiiƒˆiiofd}x2ˆiiD]$}||d7}ˆii|ƒqêWti|ddddddddƒ} nd} |iˆiƒ} |ii | iƒ|_|i idƒ| o|i i| i ƒn|ˆi_ˆiidg} | iiƒD]}| |iqÇ~ ƒˆiidƒt ˆƒoˆi!ˆƒnt ˆƒo"ˆi"ˆƒˆi#ˆdƒnt ˆƒoˆi"ˆƒn| iiƒS(s€Traverse 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ˆi|ƒdS(N(tappend(tsR (tinherit(s0/usr/lib/python2.6/site-packages/mako/codegen.pytvisitInheritTag‰scs|ˆ|iR (t namespaces(s0/usr/lib/python2.6/site-packages/mako/codegen.pytvisitNamespaceTag‹scs|ˆi_dS(N(R$R3(R>R (R(s0/usr/lib/python2.6/site-packages/mako/codegen.pyt visitPageTagscs|ioˆi|ƒndS(N(tismoduleR=(R>R (t module_code(s0/usr/lib/python2.6/site-packages/mako/codegen.pyt visitCodes (RRR@RBRCRF((RERR?RA(s0/usr/lib/python2.6/site-packages/mako/codegen.pyR<ˆ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_template_filename=%rs_template_uri=%rs5_template_cache=cache.Cache(__name__, _modified_time)s_source_encoding=%rts tsourcetlinenoitposRstemplate defined importst UNDEFINEDs _exports = %rs iÿÿÿÿN($R%R$R3tobjectR tnodestaccept_visitorRAtsettuniontdeclared_identifierst _IdentifierstdeclaredRRRt writelinet MAGIC_NUMBERttimeRRRRt PythonCodetbrancht topleveldefstaddtupdateR;tvaluesR)twriteR,twrite_module_codetwrite_namespacest write_inherit( RtencodingR<tftnt module_identtmodule_identifiersRtimptimpcodetmain_identifiersR9((RARERR?s0/usr/lib/python2.6/site-packages/mako/codegen.pyR2|s‚  %                   (    c Cs |io,|i}|o|iid|ƒq6n|iid|di|ƒfddƒ|p|p|o|iidƒn|ii|ii i |i ƒƒ|i o(d|jo|idi i d ƒn|i o~t|i iƒd jpt|i i ƒd joL|iid dig}|i i D]} |d | | fq=~ƒƒn|i|i d tƒx!|i iD]} | i|ƒq‰W|i|i |||ƒ|iidƒ|iidƒ|o&|i|||||i d tƒndS(svwrite 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"context.caller_stack._push_frame()stry:scontext._push_buffer()s **pageargsiÿÿÿÿtpageargsis!__M_locals = __M_dict_builtin(%s)s%s=%sttoplevels N(R(t decoratorRRTt writelinestjoinR&R=R$R;RXR targument_declaredRZR,tlocally_assignedtwrite_variable_declarestTrueRMRNtwrite_def_finishR%R]twrite_cache_decorator( RR R)R.RR7R RlR9txRc((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR6Ús@   "  3 cCs5x.|D]&}|i|ƒ|ii|iƒqWdS(sfwrite module-level template code, i.e. that which is enclosed in <%! %> tags in the template.N(twrite_source_commentRtwrite_indented_blockttext(RRERc((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR^s cCs(|iiddd|iddƒ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(RRmtparsed_attributesR%(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR`s   c s,ˆiiddddddddƒˆiidƒx¿|iƒD]±}|iidƒotˆi_ nˆi |ƒt |i ƒoÀˆiidƒg‰ˆii i|ƒ‰tˆ_d tf‡‡‡fd †ƒY}|ƒ}x|i D]}|i|ƒqñWˆiid d iˆƒƒˆiidƒtˆ_d }nd}ˆiid|i|iiddƒ||iiddƒfƒt|iiddƒƒoˆiid|iƒnˆiidt|iƒƒˆiidƒqBWt |ƒpˆiidƒnˆiidƒ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 NSDefVisitorcseZ‡‡‡fd†ZRS(cs*ˆi|ˆdtƒˆi|iƒdS(Ntnested(twrite_inline_defRR=R)(R>R (RR;texport(s0/usr/lib/python2.6/site-packages/mako/codegen.pyt visitDefTag2s(RRR€((RR;R(s0/usr/lib/python2.6/site-packages/mako/codegen.pyR|1ss return [%s]Rismake_namespace()R%sƒns = runtime.Namespace(%r, context._clean_inheritance_tokens(), templateuri=%s, callables=%s, calling_uri=_template_uri, module=%s)Rytmodulet inheritableRscontext['self'].%s = nss'context.namespaces[(__name__, %s)] = nss tpassN(RRmR%RTR\R0thas_keyRrR$thas_ns_importsRvR,RMR;RXR(RLRNRnRR)RzR1R/treprR](RRAR R|tvisRct callable_name((RR;Rs0/usr/lib/python2.6/site-packages/mako/codegen.pyR_sT     "      c Csetg}|iD]}||i|fq~ƒ}tƒ}|i|iƒ}|ig}|iiƒD]}||iqh~ƒ}|i|i ƒ}|i|i ƒ}|d j o|i |ƒ}n|ot |idtƒo‡|iidƒt|i_xh|iiiƒD]P\} } | iidƒo1|iid| tid| idƒfƒqqWnxâ|D]Ú} | |joE|| } | iƒo|i| |ƒqM|i| |dtƒqs| |iijo|iid| | fƒqst |idtƒo!|iid| | | fƒqs|iid | | fƒqsW|iid ƒd S( s write 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. R…s_import_ns = {}R{s:_mako_get_namespace(context, %r)._populate(_import_ns, %r)s\s*,\s*R}s%%s = _mako_get_namespace(context, %r)s3%s = _import_ns.get(%r, context.get(%r, UNDEFINED))s%s = context.get(%r, UNDEFINED)s__M_writer = context.writer()N(tdictR8R)RORPt undeclaredt closuredefsR\t differenceRotlocally_declaredR%t intersectiontgetattrR$RRRTRrt has_importsRAt iteritemsR0R„tretsplittis_roottwrite_def_declR~( RR;RktlimitR9tct comp_identstto_writet_[2]tidenttnstcomp((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRqPsF3 6    *     cCs>|i|ijo'|iid|iƒ|i|_ndS(sUwrite a source comment containing the line number of the corresponding template line.s# SOURCE LINE %dN(R#RIRRT(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRv¡scCsë|ii}|iiƒ}|iidtƒ}|i oFt|iiƒdjpt|iiƒdjo|i ddƒn|i ddƒ|i i d|di |ƒfƒ|i i d|di |ƒfƒ|i i dƒdS( s>write a locally-available callable referencing a top-level deftinclude_defaultsiscontext.locals_(__M_locals)R"s def %s(%s):Risreturn render_%s(%s)N(R*tfuncnameR+RR(R,R;RpRotinsertRRTRnR%(RR R;RŸt namedeclstnameargs((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR•§s  ##c Cs¤|iiƒ}|i}|o|iid|ƒn|iid|idi|ƒfƒt|ii ƒdj}t |i i ddƒƒ}t |i i ddƒƒ}|ii dd ƒ|p|p|o|ii d ƒn|i|d |ƒ}|i|ƒ|ii|ƒx|iD]} | i|ƒq#W|iiƒ|i||||ƒ|iidƒ|o,|i||i|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):RiiRRR s"context.caller_stack._push_frame()stry:scontext._push_buffer()R}tinlineRkN(R*R+RlRRTR)RnR,R-R.R/R0R1RmRXRqR&R=RMRNtpopRsR%RtRRr( RR R;R}R¡RlR7RR Rc((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR~·s6 &       cCsd| oE| o=| o5|iidƒ|o|iiddd ƒqMn|p|p|oþ|p|o|iiddƒn|iiddƒ|o|iidƒnd}|o|i|ii|tƒ}n|iid ƒ|o'| o|i|ii |tƒ}n|p|o|iid|ƒq`|iid|dƒnd S( sBwrite 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( RRTRmR%tcreate_filter_callableR-R.RR$R(RR RR7R t callstackR>((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRsÜs8     cCsß|iid||fƒ|iidt|ƒƒ}h} x ddddfD]õ} |ii| d dƒ} | dj oA| d djott| ƒƒ| | d t_[3]((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRt sN   "#F = =c s‡fd†}d|joW|oLˆiioˆiiii|}nˆiioˆii|}qoqsnx£|D]›}|djoqzntid|ƒ}|o2|iddƒ\}}||ƒ} | |}n'|} ||ƒ}|dj pt ‚d||f}qzW|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.csTtid|ƒo d|Sˆiiotii||ƒStii||ƒSdS(Ns decode\..+sfilters.(R’tmatchR$RRtNON_UNICODE_ESCAPESR1tDEFAULT_ESCAPES(R)(R(s0/usr/lib/python2.6/site-packages/mako/codegen.pyt locate_encodeNs   Rcs (.+?)(\(.*\))iis%s(%s)N( R$R3R-R.RR’R¼tgroupR%tAssertionError( RR.ttargett is_expressionR¿tetmR›tfargsRbRu((Rs0/usr/lib/python2.6/site-packages/mako/codegen.pyR¥Is*      cCs±|i|ƒt|iƒp?|iidj ot|iiiiƒpt|iiƒo:|i |i id|i t ƒ}|i id|ƒn|i id|i ƒdS(Ns%ss__M_writer(%s)(RvR,tescapesR$R3R%R-R.RR¥t escapes_codeRxRrRRT(RR R>((s0/usr/lib/python2.6/site-packages/mako/codegen.pytvisitExpressionls "cCsc|io5|iƒp|iidƒn|iidƒn!|i|ƒ|ii|iƒdS(NRƒ(tisendt get_childrenRRTR%RvRx(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pytvisitControlLinezs    cCs.|i|ƒ|iidt|iƒƒdS(Ns__M_writer(%s)(RvRRTR†tcontent(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyt visitTextƒs c Cs˜t|iiƒdj}|o|iiddƒnx|iD]}|i|ƒq@W|o6|iiddd|i|iidtƒ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()( R,R-R.RRmRMRNR¥RR%(RR R7Rc((s0/usr/lib/python2.6/site-packages/mako/codegen.pyt visitTextTag‡s$     cCs®|ip |i|ƒ|ii|iƒ|i oqt|iiƒdjoX|ii dƒ|ii ddi g}|i ƒD]}|t |ƒq~ƒƒqªndS(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]))Ri( RDRvRRwRxR(R,R;RpRTRnRQR†(RR R9Ru((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRFœs  $ cCsj|i|ƒ|iidƒ}|o%|iid|id|fƒn|iid|idƒdS(NR.s5runtime._include_file(context, %s, _template_uri, %s)Rys1runtime._include_file(context, %s, _template_uri)(RvR0R1RRTRz(RR R.((s0/usr/lib/python2.6/site-packages/mako/codegen.pytvisitIncludeTag­s   cCsdS(N((RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRB¹scCsdS(N((RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR€¼scCs|i|ƒdS(N(t visitCallTag(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pytvisitCallNamespaceTag¿sc sïˆiidƒdg‰ˆii|dtƒ‰ˆi|dtƒ‰ˆidƒˆiiˆƒdt f‡‡‡‡fd†ƒY}|ƒ}x|i D]}|i |ƒq›Wˆii ƒ|i iƒ}ˆiiddi|ƒƒt}|oˆiid d ƒnˆiˆƒˆiiˆƒx|i D]}|i ˆƒq6Wˆii ƒˆi||ttd tƒˆiidd diˆƒdƒˆiid dd ƒˆi|ƒˆiidˆig|itƒdddƒdS(Nsdef ccall(caller):tbodyR}tcallert DefVisitorcs eZ‡‡‡‡fd†ZRS(csNˆi|ˆdtƒˆi|iƒ|iˆijoˆi|i=ndS(NR}(R~RR=R)R‹(R>R (tbody_identifiersRRtcallable_identifiers(s0/usr/lib/python2.6/site-packages/mako/codegen.pyR€Òs(RRR€((RÖRRR×(s0/usr/lib/python2.6/site-packages/mako/codegen.pyRÕÑss def body(%s):Riscontext._push_buffer()stry:R¦s return [%s]s+caller = context.caller_stack._get_caller()s_context.caller_stack.nextcaller = runtime.Namespace('caller', context, callables=ccall(caller))s__M_writer(%s)sfinally:s&context.caller_stack.nextcaller = None(RRTR;RXRrRt add_declaredR&R=RLRMRNR¤R4R+RnRmRqRsR%RvR¥t expression(RR RÕR‡RctbodyargsR((RÖRRR×s0/usr/lib/python2.6/site-packages/mako/codegen.pyRÑÅsP  %            N(RRt__doc__RtpropertyR;R2R6R^R`R_RR%RqRvR•R~RrRsRtR¥RÉRÌRÎRÏRFRÐRBR€RÒRÑ(((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR Gs2 , ^ .  6Q   % 3: #       RRcBs¤eZdZdded„Zd„Zed„ƒZd„Z d„Z d„Z d„Z d„Z d „Zd „Zd „Zd „Zd „Zd„Zd„ZRS(sCtracks the status of identifier names as template code is rendered.cCsZ|dj oÈt|tiƒotƒ|_tiƒ|_qðt|iƒi g}|i i ƒD]}||i qb~ƒi |i ƒi |iƒ|_|o|ii |iƒ|_nti|i|_ntƒ|_tiƒ|_tƒ|_tƒ|_ tƒ|_tƒ|_tiƒ|_ ||_|dj o|i|ƒndS(N(R%RRt NamespaceTagRORSRt SetLikeDictRYRPR‹R\R)RRoRŠRpR RN(RR tparentR}R9R—((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR s*  0        cKst|||S(sXcreate a new Identifiers for a new Node, with this Identifiers as the parent.(RR(RR R5((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRXAscCst|ii|iƒiƒƒS(N(RORYRPR‹R\(R((s0/usr/lib/python2.6/site-packages/mako/codegen.pyR8Gsc Cs†dt|iƒt|iƒt|iƒg}|iiƒD]}||iq;~g}|iiƒD]}||iqe~|ifS(NsrIdentifiers(declared=%r, locally_declared=%r, undeclared=%r, topleveldefs=%r, closuredefs=%r, argumentdeclared=%r)( tlistRSRRŠRYR\R)R‹Ro(RR9R—Rš((s0/usr/lib/python2.6/site-packages/mako/codegen.pyt__repr__Ks   **cCsxQ|iƒD]C}|djo0||ii|iƒjo|ii|ƒq q Wx$|iƒD]}|ii|ƒqaWdS(squpdate the state of this Identifiers with the undeclared and declared identifiers of the given node.R"N(R²RSRPRRŠRZRQ(RR R›((s0/usr/lib/python2.6/site-packages/mako/codegen.pytcheck_declaredVs ) cCs8|ii|ƒ||ijo|ii|ƒndS(N(RSRZRŠtremove(RR›((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRØ`scCs|i|ƒdS(N(Râ(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRÉescCs|i|ƒdS(N(Râ(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRÌhscCs:|ip,|i|ƒ|ii|iƒƒ|_ndS(N(RDRâRpRPRQ(RR ((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRFks  cCs9|i|jo%x"|iD]}|i|ƒqWndS(N(R RMRN(RR Rc((s0/usr/lib/python2.6/site-packages/mako/codegen.pyRBps cCsù|iƒo||i|is"  " ÿÿÂ