ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ _Yc@sidZddlZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z ddlmZmZd Zd efd YZd efd YZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdS(s jinja2.loaders ~~~~~~~~~~~~~~ Jinja loader classes. :copyright: (c) 2017 by the Jinja Team. :license: BSD, see LICENSE for more details. iN(t ModuleType(tpath(tsha1(tTemplateNotFound(topen_if_existst internalcode(t string_typest iteritemscCsg}x~|jdD]m}tj|ksRtjrCtj|ksR|tjkrat|q|r|dkr|j|qqW|S(sSplit a path into segments and perform a sanity check. If it detects '..' in the path it will raise a `TemplateNotFound` error. t/t.(tsplitRtseptaltseptpardirRtappend(ttemplatetpiecestpiece((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytsplit_template_pathst BaseLoadercBs8eZdZeZdZdZeddZ RS(sBaseclass for all loaders. Subclass this and override `get_source` to implement a custom loading mechanism. The environment provides a `get_template` method that calls the loader's `load` method to get the :class:`Template` object. A very basic example for a loader that looks up templates on the file system could look like this:: from jinja2 import BaseLoader, TemplateNotFound from os.path import join, exists, getmtime class MyLoader(BaseLoader): def __init__(self, path): self.path = path def get_source(self, environment, template): path = join(self.path, template) if not exists(path): raise TemplateNotFound(template) mtime = getmtime(path) with file(path) as f: source = f.read().decode('utf-8') return source, path, lambda: mtime == getmtime(path) cCs2|js"td|jjnt|dS(sGet the template source, filename and reload helper for a template. It's passed the environment and template name and has to return a tuple in the form ``(source, filename, uptodate)`` or raise a `TemplateNotFound` error if it can't locate the template. The source part of the returned tuple must be the source of the template as unicode string or a ASCII bytestring. The filename should be the name of the file on the filesystem if it was loaded from there, otherwise `None`. The filename is used by python for the tracebacks if no loader extension is used. The last item in the tuple is the `uptodate` function. If auto reloading is enabled it's always called to check if the template changed. No arguments are passed so the function must store the old state somewhere (for example in a closure). If it returns `False` the template will be reloaded. s&%s cannot provide access to the sourceN(thas_source_accesst RuntimeErrort __class__t__name__R(tselft environmentR((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt get_sourceFs cCstddS(sIterates over all templates. If the loader does not support that it should raise a :exc:`TypeError` which is the default behavior. s-this loader cannot iterate over all templatesN(t TypeError(R((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytlist_templates]sc Csd}|dkri}n|j||\}}}|j}|dk ro|j||||} | j}n|dkr|j|||}n|dk r| jdkr|| _|j| n|jj||||S(scLoads a template. This method looks up the template in the cache or loads one by calling :meth:`get_source`. Subclasses should not override this method as loaders working on collections of other loaders (such as :class:`PrefixLoader` or :class:`ChoiceLoader`) will not call this method but `get_source` directly. N( tNoneRtbytecode_cachet get_buckettcodetcompilet set_bucketttemplate_classt from_code( RRtnametglobalsR tsourcetfilenametuptodatetbcctbucket((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytloadcs       N( Rt __module__t__doc__tTrueRRRRRR,(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR%s   tFileSystemLoadercBs/eZdZdedZdZdZRS(s"Loads templates from the file system. This loader can find templates in folders on the file system and is the preferred way to load them. The loader takes the path to the templates as string, or if multiple locations are wanted a list of them which is then looked up in the given order:: >>> loader = FileSystemLoader('/path/to/templates') >>> loader = FileSystemLoader(['/path/to/templates', '/other/path']) Per default the template encoding is ``'utf-8'`` which can be changed by setting the `encoding` parameter to something else. To follow symbolic links, set the *followlinks* parameter to ``True``:: >>> loader = FileSystemLoader('/path/to/templates', followlinks=True) .. versionchanged:: 2.8+ The *followlinks* parameter was added. sutf-8cCs@t|tr|g}nt||_||_||_dS(N(t isinstanceRtlistt searchpathtencodingt followlinks(RR3R4R5((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt__init__s   cst|}x|jD]}tj||t}|dkrLqnz|jj|j}Wd|j Xtj fd}||fSWt |dS(Ncs0ytjkSWntk r+tSXdS(N(RtgetmtimetOSErrortFalse((R(tmtime(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR)s ( RR3RtjoinRRtreadtdecodeR4tcloseR7R(RRRRR3tftcontentsR)((R(R:s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs    c Cst}x|jD]}tj|d|j}x|D]\}}}x|D]}tjj||t|jtjj j tjj d}|d dkr|d}n||krN|j |qNqNWq8WqWt |S(NR5Ris./( tsetR3tostwalkR5RR;tlentstripR treplacetaddtsorted( RtfoundR3twalk_dirtdirpathtdirnamest filenamesR(R((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs    (RR-R.R9R6RR(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR0s t PackageLoadercBs/eZdZdddZdZdZRS(s,Load templates from python eggs or packages. It is constructed with the name of the python package and the path to the templates in that package:: loader = PackageLoader('mypackage', 'views') If the package path is not given, ``'templates'`` is assumed. Per default the template encoding is ``'utf-8'`` which can be changed by setting the `encoding` parameter to something else. Due to the nature of eggs it's only possible to reload templates if the package was loaded from the file system and not a zip file. t templatessutf-8cCseddlm}m}m}||}||_||_t|||_||_||_ dS(Ni(tDefaultProvidertResourceManagert get_provider( t pkg_resourcesRPRQRRR4tmanagerR1tfilesystem_boundtprovidert package_path(Rt package_nameRWR4RPRQRRRV((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR6s    cst|}dj|jft|}|jj|sLt|nd}|jr|jj |j |t j fd}n|jj |j |}|j|j|fS(NRcs0ytjkSWntk r+tSXdS(N(RR7R8R9((R(R:(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR)s (RR;RWttupleRVt has_resourceRRRUtget_resource_filenameRTRR7tget_resource_stringR=R4(RRRRtpR)R'((R(R:s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs   cs}j}|d dkr&|d}n|dkr;d}nt|gfd|jS(Nis./R tcshxajj|D]M}|d|}jj|rF|qj|jdqWdS(NR(RVtresource_listdirtresource_isdirRtlstrip(RR(tfullname(t_walktoffsettresultsR(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRcs  (RWRDtsort(RR((RcRdReRs2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs       (RR-R.R6RR(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRNs   t DictLoadercBs)eZdZdZdZdZRS(sLoads a template from a python dict. It's passed a dict of unicode strings bound to template names. This loader is useful for unittesting: >>> loader = DictLoader({'index.html': 'source here'}) Because auto reloading is rarely useful this is disabled per default. cCs ||_dS(N(tmapping(RRh((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR6scsHjkr8jdfdfStdS(NcsjjkS(N(Rhtget((RR'R(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytR^(RhRR(RRR((RR'Rs2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs cCs t|jS(N(RHRh(R((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR s(RR-R.R6RR(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRgs  tFunctionLoadercBs eZdZdZdZRS(sA loader that is passed a function which does the loading. The function receives the name of the template and has to return either an unicode string with the template source, a tuple in the form ``(source, filename, uptodatefunc)`` or `None` if the template does not exist. >>> def load_template(name): ... if name == 'index.html': ... return '...' ... >>> loader = FunctionLoader(load_template) The `uptodatefunc` is a function that is called if autoreload is enabled and has to return `True` if the template is still up to date. For more details have a look at :meth:`BaseLoader.get_source` which has the same return value. cCs ||_dS(N(t load_func(RRl((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR66scCsJ|j|}|dkr*t|nt|trF|ddfS|S(N(RlRRR1R(RRRtrv((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR9s   (RR-R.R6R(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRk$s t PrefixLoadercBsGeZdZddZdZdZeddZdZ RS(sA loader that is passed a dict of loaders where each loader is bound to a prefix. The prefix is delimited from the template by a slash per default, which can be changed by setting the `delimiter` argument to something else:: loader = PrefixLoader({ 'app1': PackageLoader('mypackage.app1'), 'app2': PackageLoader('mypackage.app2') }) By loading ``'app1/index.html'`` the file from the app1 package is loaded, by loading ``'app2/index.html'`` the file from the second. RcCs||_||_dS(N(Rht delimiter(RRhRo((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR6Qs cCs\y,|j|jd\}}|j|}Wn#ttfk rQt|nX||fS(Ni(R RoRht ValueErrortKeyErrorR(RRtprefixR%tloader((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt get_loaderUs cCsM|j|\}}y|j||SWntk rHt|nXdS(N(RtRR(RRRRsR%((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR]s  cCsP|j|\}}y|j|||SWntk rKt|nXdS(N(RtR,R(RRR%R&Rst local_name((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR,fs  cCsYg}xLt|jD];\}}x,|jD]}|j||j|q/WqW|S(N(RRhRRRo(RtresultRrRsR((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRps  N( RR-R.R6RtRRRR,R(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRnBs     t ChoiceLoadercBs;eZdZdZdZeddZdZRS(sThis loader works like the `PrefixLoader` just that no prefix is specified. If a template could not be found by one loader the next one is tried. >>> loader = ChoiceLoader([ ... FileSystemLoader('/path/to/user/templates'), ... FileSystemLoader('/path/to/system/templates') ... ]) This is useful if you want to allow users to override builtin templates from a different location. cCs ||_dS(N(tloaders(RRx((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR6scCsLx9|jD].}y|j||SWq tk r7q Xq Wt|dS(N(RxRR(RRRRs((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs  cCsOx<|jD]1}y|j|||SWq tk r:q Xq Wt|dS(N(RxR,R(RRR%R&Rs((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR,s  cCs:t}x$|jD]}|j|jqWt|S(N(RARxtupdateRRH(RRIRs((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs N( RR-R.R6RRRR,R(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRwxs    t_TemplateModulecBseZdZRS(s9Like a normal module but with support for weak references(RR-R.(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRzst ModuleLoadercBsMeZdZeZdZedZedZe ddZ RS(s6This loader loads templates from precompiled templates. Example usage: >>> loader = ChoiceLoader([ ... ModuleLoader('/path/to/compiled/templates'), ... FileSystemLoader('/path/to/templates') ... ]) Templates can be precompiled with :meth:`Environment.compile_templates`. csdt|t}t|tr7|g}n t|}||_tj|fdtj <||_ |_ dS(Ns_jinja2_module_templates_%xcstjjdS(N(tsystmodulestpopR(tx(RX(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRjR^( tidRzR1RR2t__path__tweakreftproxyR|R}tmoduleRX(RRtmod((RXs2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR6s      cCsdt|jdjS(Nttmpl_sutf-8(Rtencodet hexdigest(R%((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytget_template_keyscCstj|dS(Ns.py(R{R(R%((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytget_module_filenamescCs|j|}d|j|f}t|j|d}|dkryt|dddg}Wntk r~t|nXtj j |dn|j j ||j |S(Ns%s.%stroot(RRXtgetattrRRt __import__t ImportErrorRR|R}R~R#tfrom_module_dictt__dict__(RRR%R&tkeyRR((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR,s   N( RR-R.R9RR6t staticmethodRRRRR,(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR{s  (R.RBR|RttypesRRthashlibRtjinja2.exceptionsRt jinja2.utilsRRtjinja2._compatRRRtobjectRR0RNRgRkRnRwRzR{(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt s&    eCA6)