PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  Qc@s-dZddlmZddlmZmZmZmZmZm Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZdefdYZdefdYZd efd YZd efd YZd ZdZdZdZdZdS(sProvides the Template class, a facade for parsing, generating and executing template strings, as well as template runtime operations.i(tLexer(truntimetutilt exceptionstcodegentcachetcompatNtTemplatecBs7eZdZeZdddedddddddedddddededdeddedddZe j dZ dZ dZ edZedZe j d Zed Zed Zed Zd ZdZdZdZdZdZedZRS(s7Represents a compiled template. :class:`.Template` includes a reference to the original template source (via the :attr:`.source` attribute) as well as the source code of the generated Python module (i.e. the :attr:`.code` attribute), as well as a reference to an actual Python module. :class:`.Template` is constructed using either a literal string representing the template text, or a filename representing a filesystem path to a source file. :param text: textual template source. This argument is mutually exclusive versus the ``filename`` parameter. :param filename: filename of the source template. This argument is mutually exclusive versus the ``text`` parameter. :param buffer_filters: string list of filters to be applied to the output of ``%def``\ s which are buffered, cached, or otherwise filtered, after all filters defined with the ``%def`` itself have been applied. Allows the creation of default expression filters that let the output of return-valued ``%def``\ s "opt out" of that filtering via passing special attributes or objects. :param bytestring_passthrough: When ``True``, and ``output_encoding`` is set to ``None``, and :meth:`.Template.render` is used to render, the `StringIO` or `cStringIO` buffer will be used instead of the default "fast" buffer. This allows raw bytestrings in the output stream, such as in expressions, to pass straight through to the buffer. This flag is forced to ``True`` if ``disable_unicode`` is also configured. .. versionadded:: 0.4 Added to provide the same behavior as that of the previous series. :param cache_args: Dictionary of cache configuration arguments that will be passed to the :class:`.CacheImpl`. See :ref:`caching_toplevel`. :param cache_dir: .. deprecated:: 0.6 Use the ``'dir'`` argument in the ``cache_args`` dictionary. See :ref:`caching_toplevel`. :param cache_enabled: Boolean flag which enables caching of this template. See :ref:`caching_toplevel`. :param cache_impl: String name of a :class:`.CacheImpl` caching implementation to use. Defaults to ``'beaker'``. :param cache_type: .. deprecated:: 0.6 Use the ``'type'`` argument in the ``cache_args`` dictionary. See :ref:`caching_toplevel`. :param cache_url: .. deprecated:: 0.6 Use the ``'url'`` argument in the ``cache_args`` dictionary. See :ref:`caching_toplevel`. :param default_filters: List of string filter names that will be applied to all expressions. See :ref:`filtering_default_filters`. :param disable_unicode: Disables all awareness of Python Unicode objects. See :ref:`unicode_disabled`. :param enable_loop: When ``True``, enable the ``loop`` context variable. This can be set to ``False`` to support templates that may be making usage of the name "``loop``". Individual templates can re-enable the "loop" context by placing the directive ``enable_loop="True"`` inside the ``<%page>`` tag -- see :ref:`migrating_loop`. :param encoding_errors: Error parameter passed to ``encode()`` when string encoding is performed. See :ref:`usage_unicode`. :param error_handler: Python callable which is called whenever compile or runtime exceptions occur. The callable is passed the current context as well as the exception. If the callable returns ``True``, the exception is considered to be handled, else it is re-raised after the function completes. Is used to provide custom error-rendering functions. :param format_exceptions: if ``True``, exceptions which occur during the render phase of this template will be caught and formatted into an HTML error page, which then becomes the rendered result of the :meth:`.render` call. Otherwise, runtime exceptions are propagated outwards. :param imports: String list of Python statements, typically individual "import" lines, which will be placed into the module level preamble of all generated Python modules. See the example in :ref:`filtering_default_filters`. :param future_imports: String list of names to import from `__future__`. These will be concatenated into a comma-separated string and inserted into the beginning of the template, e.g. ``futures_imports=['FOO', 'BAR']`` results in ``from __future__ import FOO, BAR``. If you're interested in using features like the new division operator, you must use future_imports to convey that to the renderer, as otherwise the import will not appear as the first executed statement in the generated code and will therefore not have the desired effect. :param input_encoding: Encoding of the template's source code. Can be used in lieu of the coding comment. See :ref:`usage_unicode` as well as :ref:`unicode_toplevel` for details on source encoding. :param lookup: a :class:`.TemplateLookup` instance that will be used for all file lookups via the ``<%namespace>``, ``<%include>``, and ``<%inherit>`` tags. See :ref:`usage_templatelookup`. :param module_directory: Filesystem location where generated Python module files will be placed. :param module_filename: Overrides the filename of the generated Python module file. For advanced usage only. :param module_writer: A callable which overrides how the Python module is written entirely. The callable is passed the encoded source content of the module and the destination path to be written to. The default behavior of module writing uses a tempfile in conjunction with a file move in order to make the operation atomic. So a user-defined module writing function that mimics the default behavior would be: .. sourcecode:: python import tempfile import os import shutil def module_writer(source, outputpath): (dest, name) = \ tempfile.mkstemp( dir=os.path.dirname(outputpath) ) os.write(dest, source) os.close(dest) shutil.move(name, outputpath) from mako.template import Template mytemplate = Template( filename="index.html", module_directory="/path/to/modules", module_writer=module_writer ) The function is provided for unusual configurations where certain platform-specific permissions or other special steps are needed. :param output_encoding: The encoding to use when :meth:`.render` is called. See :ref:`usage_unicode` as well as :ref:`unicode_toplevel`. :param preprocessor: Python callable which will be passed the full template source before it is parsed. The return result of the callable will be used as the template source code. :param lexer_cls: A :class:`.Lexer` class used to parse the template. The :class:`.Lexer` class is used by default. .. versionadded:: 0.7.4 :param strict_undefined: Replaces the automatic usage of ``UNDEFINED`` for any undeclared variables not located in the :class:`.Context` with an immediate raise of ``NameError``. The advantage is immediate reporting of missing variables which include the name. .. versionadded:: 0.3.6 :param uri: string URI or other identifier for this template. If not provided, the ``uri`` is generated from the filesystem path, or from the in-memory identity of a non-file-based template. The primary usage of the ``uri`` is to provide a key within :class:`.TemplateLookup`, as well as to generate the file path of the generated Python module file, if ``module_directory`` is specified. tstricttbeakerc" Csd|r*tjdd||_||_n|rtjdd||_tjj|\}}tjj|jtjj d}||_n%dt t ||_|j|_|j}|j dr|d}ntjj|}|j drt jd|jn||_||_||_||_|pA||_||_||_||_tjr|rt jdn|r|rt jd n|dkrtjs|jrd g|_qd g|_n ||_||_||_||_||_|dk r"||_ n|dk rtt!|||\} }!| |_"||_#t$|!d||| |n|dk r|dk r|}nF| dk rtjj%tjj&tjj| |d }nd}|j'||}!nt j(d |!|_)||_*|j)j+|_,||_-||_.||_/| |_0|j1| | | | ||dS(Ns\Wt_t/smemory:is..sNTemplate uri "%s" is invalid - it cannot be relative outside of the root path.s4Mako for Python 3 does not support disabling UnicodesAoutput_encoding must be set to None when disable_unicode is used.tstrtunicodes.pys"Template requires text or filename(2tretsubt module_idturitostpatht splitdrivetnormpathtreplacetsepthextidt startswithRtTemplateLookupExceptiontinput_encodingtoutput_encodingtencoding_errorstdisable_unicodetbytestring_passthrought enable_looptstrict_undefinedt module_writerRtpy3ktUnsupportedErrortNonetdefault_filterstbuffer_filterstimportstfuture_importst preprocessort lexer_clst _compile_textt_codet_sourcet ModuleInfotabspathtjoint_compile_from_filetRuntimeExceptiontmoduletfilenamet render_bodyt callable_tformat_exceptionst error_handlertlookuptmodule_directoryt_setup_cache_args("tselfttextR6RR9R:R;RRR<t cache_argst cache_implt cache_enabledt cache_typet cache_dirt cache_urltmodule_filenameRRR#R R'R(R"R)R*R!R+R,tdriveRtu_normtcodeR5((s1/usr/lib/python2.7/site-packages/mako/template.pyt__init__s $                                       cCs'|jrtjStjjdgSdS(Ntloop(R!RtRESERVED_NAMESt difference(R>((s1/usr/lib/python2.7/site-packages/mako/template.pytreserved_namesUs cCss||_||_|r$||_n i|_|rC||jdRARBR@RCRDRE((s1/usr/lib/python2.7/site-packages/mako/template.pyR=\s    cCs|dk r2tjtjj|tj|tj}tjj| sjtj|tj|krtj |}t |||||j nt j |j|}tj|j=|jtjkrtj |}t |||||j t j |j|}tj|j=nt||||ddnRtj |}t|||\}}d|_||_t|d|||d|S(N(R&Rtverify_directoryRRtdirnametstattST_MTIMEtexistst read_filet_compile_module_fileR#Rt load_moduleRtsystmodulest _magic_numberRt MAGIC_NUMBERR0R-R/R.(R>RR6t filemtimetdataR5RI((s1/usr/lib/python2.7/site-packages/mako/template.pyR3nsD      cCst|jjS(s<Return the template source code for this :class:`.Template`.(t_get_module_info_from_callableR8tsource(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyRascCst|jjS(s:Return the module source code for this :class:`.Template`.(R`R8RI(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyRIscCs tj|S(N(RtCache(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyRscCs |jdS(NRP(R@(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyRDscCs |jdS(NRQ(R@(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyREscCs |jdS(NRO(R@(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyRCscOstj||j||S(sRender the output of this template as a string. If the template specifies an output encoding, the string will be encoded accordingly, else the output is raw (raw output uses `cStringIO` and can't handle multibyte characters). A :class:`.Context` object is created corresponding to the given data. Arguments that are explicitly declared by this template's internal rendering method are also pulled from the given ``*args``, ``**data`` members. (Rt_renderR8(R>targsR_((s1/usr/lib/python2.7/site-packages/mako/template.pytrenders cOstj||j||dtS(s7Render the output of this template as a unicode object.t as_unicode(RRcR8tTrue(R>RdR_((s1/usr/lib/python2.7/site-packages/mako/template.pytrender_unicodes  cOsHt|dddkr(|j|ntj||j|||dS(svRender this :class:`.Template` with the given context. The data is written to the context's buffer. t_with_templateN(tgetattrR&t_set_with_templateRt_render_contextR8(R>tcontextRdtkwargs((s1/usr/lib/python2.7/site-packages/mako/template.pytrender_contexts cCst|jd|S(Ns render_%s(thasattrR5(R>tname((s1/usr/lib/python2.7/site-packages/mako/template.pythas_defscCst|t|jd|S(s9Return a def of this template as a :class:`.DefTemplate`.s render_%s(t DefTemplateRjR5(R>Rq((s1/usr/lib/python2.7/site-packages/mako/template.pytget_defscCst|jd|S(Ns render_%s(RjR5(R>Rq((s1/usr/lib/python2.7/site-packages/mako/template.pyt_get_def_callablescCs |jjS(N(R5t_modified_time(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyt last_modifiedsN((t__name__t __module__t__doc__RR,R&tFalseRgRJRtmemoized_propertyRNR=R3tpropertyRaRIRRDRERCReRhRoRrRtRuRw(((s1/usr/lib/python2.7/site-packages/mako/template.pyRs\ `  '     tModuleTemplatecBsMeZdZdddddddeeeddddeddddZRS(s)A Template which is constructed given an existing Python module. e.g.:: t = Template("this is a template") f = file("mymodule.py", "w") f.write(t.code) f.close() import mymodule t = ModuleTemplate(mymodule) print t.render() RR c Cstjdd|j|_|j|_|j|_||_||_| |_ | pW| |_ |j |_ t jr| rtjdn|r| rtjdn||_||_t|||||||jj|_| |_| |_| |_|j||||||dS(Ns\WR s4Mako for Python 3 does not support disabling UnicodesAoutput_encoding must be set to None when disable_unicode is used.(RRt _template_uriRRt_source_encodingRRRRR t _enable_loopR!RR$RR%R5R6R0R7R8R9R:R;R=(R>R5RFttemplatettemplate_filenamet module_sourcettemplate_sourceRRRR R9R:R;R@RARBRCRDRE((s1/usr/lib/python2.7/site-packages/mako/template.pyRJs:               N(RxRyRzR&R{RgRJ(((s1/usr/lib/python2.7/site-packages/mako/template.pyR~s&RscBs eZdZdZdZRS(sNA :class:`.Template` which represents a callable def in a parent template.cCsv||_||_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j |_ dS(N( tparentR8RR5RR9R:R!R;R (R>RR8((s1/usr/lib/python2.7/site-packages/mako/template.pyRJ0s         cCs|jj|S(N(RRt(R>Rq((s1/usr/lib/python2.7/site-packages/mako/template.pyRt<s(RxRyRzRJRt(((s1/usr/lib/python2.7/site-packages/mako/template.pyRs,s R0cBsAeZdZejZdZedZedZ RS(sStores information about a module currently loaded into memory, provides reverse lookups of template source, module source code based on a module's identifier. cCs^||_||_||_||_||_||j|j<|_|rZ||j|R5RFRRRR((s1/usr/lib/python2.7/site-packages/mako/template.pyRJGs     cCs*|jdk r|jStj|jSdS(N(RR&Rtread_python_fileRF(R>((s1/usr/lib/python2.7/site-packages/mako/template.pyRIWscCs|jdk rQ|jjrGt|jtj rG|jj|jjS|jSn5tj |j }|jjr|j|jjS|SdS(N( RR&R5Rt isinstanceRt text_typetdecodeRRWR(R>R_((s1/usr/lib/python2.7/site-packages/mako/template.pyRa^s     ( RxRyRztweakreftWeakValueDictionaryRRJR}RIRa(((s1/usr/lib/python2.7/site-packages/mako/template.pyR0?s   cCs|j||d|jd|jd|j}|j}tj||j|d|jd|j d|j d|j d|j d |d|jd |j d |jd |j }||fS( NRRR+R'R(R)R*tsource_encodingtgenerate_magic_commentR"R!RN(R,RRR+tparseRtcompileRR'R(R)R*tencodingR"R!RN(RR?R6RtlexertnodeRa((s1/usr/lib/python2.7/site-packages/mako/template.pyt_compilens(               c Bs|j}e|||d|j\}}|}ej r[e|ejr[|j}nej |}e ||d}||j |j fdU||fS(NRtexec( RRRRR$RRtencodettypest ModuleTypeRt__dict__( RR?R6t identifierRaRtcidR5RI((s1/usr/lib/python2.7/site-packages/mako/template.pyR-s c Cst|||dt\}}t|tjrK|j|jpBd}n|ra|||nQtjdt j j |\}}t j ||t j |tj||dS(NRtasciiRP(RRgRRRRRttempfiletmkstempRRRStwritetclosetshutiltmove( RR?R6t outputpathR#RaRtdestRq((s1/usr/lib/python2.7/site-packages/mako/template.pyRXs$ cCs/tjrt|jdSt|jdSdS(NRx(RR$t_get_module_infot __globals__t func_globals(R8((s1/usr/lib/python2.7/site-packages/mako/template.pyR`s cCs tj|S(N(R0R(R6((s1/usr/lib/python2.7/site-packages/mako/template.pyRs(Rzt mako.lexerRtmakoRRRRRRRRRRTRZRRRtobjectRR~RsR0RR-RXR`R(((s1/usr/lib/python2.7/site-packages/mako/template.pyts(.        I/