|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /usr/lib/python2.7/site-packages/jinja2/ |
Upload File : |
�
-/�_c @ s� d Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m
Z
d d l m Z d d l m Z d d
l m
Z
d d l m Z d d l m Z d d
l m 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 e f d � � YZ d e f d � � YZ d S(! sK API and implementations for loading templates from different data
sources.
i����N( t sha1( t path( t
ModuleTypei ( t abc( t fspath( t iteritems( t string_types( t TemplateNotFound( t internalcode( t open_if_existsc C s� g } x~ | j d � D]m } t j | k sR t j rC t j | k sR | t j k ra t | � � q | r | d k r | j | � 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( ( s0 /tmp/pip-install-sTXtzD/Jinja2/jinja2/loaders.pyt split_template_path s t
BaseLoaderc B s8 e Z d Z 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 s2 | j s"