ok

Mini Shell

Direktori : /proc/self/root/proc/self/root/proc/self/root/lib/python2.7/site-packages/jinja2/
Upload File :
Current File : //proc/self/root/proc/self/root/proc/self/root/lib/python2.7/site-packages/jinja2/loaders.pyo

�
��Rc@sidZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZd	�Zd
efd��YZdefd
��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdS(s�
    jinja2.loaders
    ~~~~~~~~~~~~~~

    Jinja loader classes.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i����N(t
ModuleType(tpath(tsha1(tTemplateNotFound(topen_if_existstinternalcode(tstring_typest	iteritemscCs�g}x~|jd�D]m}tj|ksRtjrCtj|ksR|tjkrat|��q|r|dkr|j|�qqW|S(s�Split 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
BaseLoadercBs8eZdZeZd�Zd�Zedd��Z	RS(s�Baseclass 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|jj��nt|��dS(s�Get 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(tselftenvironmentR((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt
get_sourceFs	cCstd��dS(s�Iterates 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
Cs�d}|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,eZdZdd�Zd�Zd�ZRS(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.
    sutf-8cCs7t|t�r|g}nt|�|_||_dS(N(t
isinstanceRtlistt
searchpathtencoding(RR3R4((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt__init__�scs�t|�}x�|jD]�}tj||��t��}|dkrLqnz|j�j|j�}Wd|j	�Xtj
�����fd�}|�|fSWt|��dS(Ncs0ytj���kSWntk
r+tSXdS(N(RtgetmtimetOSErrortFalse((R(tmtime(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR)�s
(RR3RtjoinRRtreadtdecodeR4tcloseR6R(RRRRR3tftcontentsR)((R(R9s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR�scCs�t�}x�|jD]�}x�tj|�D]�\}}}x�|D]}tjj||�t|�jtjj�j	tjjd�}|d dkr�|d}n||kr?|j
|�q?q?Wq)WqWt|�S(NRis./(tsetR3tostwalkRR:tlentstripRtreplacetaddtsorted(RtfoundR3tdirpathtdirnamest	filenamesR(R((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR�s	

(RR-R.R5RR(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR0�s
	t
PackageLoadercBs/eZdZddd�Zd�Zd�ZRS(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_resourcesRNRORPR4tmanagerR1tfilesystem_boundtprovidertpackage_path(Rtpackage_nameRUR4RNRORPRT((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR5�s		cs�t|�}dj|jft|��}|jj|�sLt|��nd�}|jr�|jj	|j
|��tj�����fd�}n|jj
|j
|�}|j|j��|fS(NRcs0ytj���kSWntk
r+tSXdS(N(RR6R7R8((R(R9(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR)�s
(RR:RUttupleRTthas_resourceRRRStget_resource_filenameRRRR6tget_resource_stringR<R4(RRRRtpR)R'((R(R9s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR�s
	cs}�j}|d dkr&|d}n|dkr;d}nt|��g�����fd���|��j��S(Nis./R	tcshxa�jj|�D]M}|d|}�jj|�rF�|�q�j|�jd��qWdS(NR(RTtresource_listdirtresource_isdirRtlstrip(RR(tfullname(t_walktoffsettresultsR(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRa�s

(RURCtsort(RR((RaRbRcRs2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR�s	
	

(RR-R.R5RR(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRL�s


	t
DictLoadercBs)eZdZd�Zd�Zd�ZRS(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(RRf((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR5
scsH��jkr8�j���d���fd�fSt���dS(Ncs��jj��kS(N(Rftget((RR'R(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt<lambda>s(RfRR(RRR((RR'Rs2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs
cCs
t|j�S(N(RGRf(R((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs(RR-R.R5RR(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRes		tFunctionLoadercBs eZdZd�Zd�ZRS(s�A loader that is passed a function which does the loading.  The
    function becomes the name of the template passed 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(RRj((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR5,scCsJ|j|�}|dkr*t|��nt|t�rF|ddfS|S(N(RjRRR1R(RRRtrv((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR/s
(RR-R.R5R(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRis	tPrefixLoadercBsGeZdZdd�Zd�Zd�Zedd��Zd�Z	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(Rft	delimiter(RRfRm((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR5Gs	cCs\y,|j|jd�\}}|j|}Wn#ttfk
rQt|��nX||fS(Ni(R
RmRft
ValueErrortKeyErrorR(RRtprefixR%tloader((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt
get_loaderKscCsM|j|�\}}y|j||�SWntk
rHt|��nXdS(N(RrRR(RRRRqR%((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRSs

cCsP|j|�\}}y|j|||�SWntk
rKt|��nXdS(N(RrR,R(RRR%R&Rqt
local_name((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR,\s

cCsYg}xLt|j�D];\}}x,|j�D]}|j||j|�q/WqW|S(N(RRfRRRm(RtresultRpRqR((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRfs
 N(
RR-R.R5RrRRRR,R(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRl8s
				tChoiceLoadercBs;eZdZd�Zd�Zedd��Zd�ZRS(s�This 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(RRv((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR5|scCsLx9|jD].}y|j||�SWq
tk
r7q
Xq
Wt|��dS(N(RvRR(RRRRq((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRs
cCsOx<|jD]1}y|j|||�SWq
tk
r:q
Xq
Wt|��dS(N(RvR,R(RRR%R&Rq((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR,�s
cCs:t�}x$|jD]}|j|j��qWt|�S(N(R@RvtupdateRRG(RRHRq((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR�s	N(	RR-R.R5RRRR,R(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRuns		t_TemplateModulecBseZdZRS(s9Like a normal module but with support for weak references(RR-R.(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRx�stModuleLoadercBsMeZdZeZd�Zed��Zed��Ze	dd��ZRS(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`.
    cs�dt|��t��}t|t�r7|g}nt|�}||_tj|�fd��tj	�<||_
�|_dS(Ns_jinja2_module_templates_%xcstjj�d�S(N(tsystmodulestpopR(tx(RV(s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRh�s(tidRxR1RR2t__path__tweakreftproxyRzR{tmoduleRV(RRtmod((RVs2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR5�s			cCsdt|jd��j�S(Nttmpl_sutf-8(Rtencodet	hexdigest(R%((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytget_template_key�scCstj|�dS(Ns.py(RyR�(R%((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pytget_module_filename�scCs�|j|�}d|j|f}t|j|d�}|dkr�yt|dddg�}Wntk
r~t|��nXtj	j
|d�n|jj||j
|�S(Ns%s.%stroot(R�RVtgetattrR�Rt
__import__tImportErrorRRzR{R|R#tfrom_module_dictt__dict__(RRR%R&tkeyR�R�((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyR,�s
	N(RR-R.R8RR5tstaticmethodR�R�RRR,(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyRy�s	(R.RARzR�ttypesRRthashlibRtjinja2.exceptionsRtjinja2.utilsRRtjinja2._compatRRRtobjectRR0RLReRiRlRuRxRy(((s2/usr/lib/python2.7/site-packages/jinja2/loaders.pyt<module>
s&	e9A6)

Zerion Mini Shell 1.0