/usr/lib64/python2.6/site-packages/jinja2
Edit: /usr/lib64/python2.6/site-packages/jinja2/loaders.pyo (13218B)
Ñò
e¤Ic
@ s# d Z d d k l Z y d d k l Z Wn# e j
o d d k l Z n Xd d k l Z d d k
l Z l Z l
Z
d „ Z d e f d „ ƒ YZ d
e f d „ ƒ YZ d e f d
„ ƒ YZ d e f d „ ƒ YZ d e f d „ ƒ YZ d e f d „ ƒ YZ d e f d „ ƒ YZ d S( s
jinja2.loaders
~~~~~~~~~~~~~~
Jinja loader classes.
:copyright: (c) 2009 by the Jinja Team.
:license: BSD, see LICENSE for more details.
iÿÿÿÿ( t path( t sha1( t new( t TemplateNotFound( t LRUCachet open_if_existst internalcodec C s“ g } x† | i d ƒ D]u } t i | j p* t i o t i | j p | t i j o t | ƒ ‚ q | o | d j o | i | ƒ q q W| 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 .( t splitR t sept altsept pardirR t append( t templatet piecest piece( ( s4 /usr/lib64/python2.6/site-packages/jinja2/loaders.pyt split_template_path s t
BaseLoaderc B s) e Z d Z d „ Z e d d „ ƒ 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)
c C s t | ƒ ‚ d S( 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.
N( R ( t selft environmentR ( ( s4 /usr/lib64/python2.6/site-packages/jinja2/loaders.pyt
get_source> s c
C sé d } | d j o
h } n | i | | ƒ \ } } } | i } | d j o% | i | | | | ƒ } | i } n | d j o | i | | | ƒ } n | d j o* | i d j o | | _ | i | ƒ n | i i | | | | ƒ S( sc Loads 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( t NoneR t bytecode_cachet
get_buckett codet compilet
set_buckett template_classt from_code(
R R t namet globalsR t sourcet filenamet uptodatet bcct bucket( ( s4 /usr/lib64/python2.6/site-packages/jinja2/loaders.pyt loadR s
N( t __name__t
__module__t __doc__R R R R% ( ( ( s4 /usr/lib64/python2.6/site-packages/jinja2/loaders.pyR # s t FileSystemLoaderc B s# e Z d Z d d „ Z d „ Z RS( 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.
s utf-8c C s9 t | t ƒ o
| g } n t | ƒ | _ | | _ d S( N( t
isinstancet
basestringt listt
searchpatht encoding( R R- R. ( ( s4 /usr/lib64/python2.6/site-packages/jinja2/loaders.pyt __init__ˆ s
c s· t | ƒ } x˜ | i D] } t i | | Œ ‰ t ˆ ƒ } | d j o q n z | i ƒ i | i ƒ } Wd | i ƒ Xt i
ˆ ƒ ‰ ‡ ‡ f d † } | ˆ | f SWt | ƒ ‚ d S( Nc s2 y t i ˆ ƒ ˆ j SWn t j
o t SXd S( N( R t getmtimet OSErrort False( ( t mtimeR! ( s4 /usr/lib64/python2.6/site-packages/jinja2/loaders.pyR" › s ( R R- R t joinR R t readt decodeR. t closeR0 R ( R R R R R- t ft contentsR" ( ( R3 R! s4 /usr/lib64/python2.6/site-packages/jinja2/loaders.pyR Ž s
( R&