Updated jinja version

This commit is contained in:
hbristow
2013-06-18 17:27:09 +10:00
parent 2059972bf7
commit 304fd03e64
21 changed files with 1031 additions and 467 deletions

View File

@@ -13,12 +13,10 @@ import sys
import weakref
from types import ModuleType
from os import path
try:
from hashlib import sha1
except ImportError:
from sha import new as sha1
from hashlib import sha1
from jinja2.exceptions import TemplateNotFound
from jinja2.utils import LRUCache, open_if_exists, internalcode
from jinja2.utils import open_if_exists, internalcode
from jinja2._compat import string_types, iteritems
def split_template_path(template):
@@ -153,7 +151,7 @@ class FileSystemLoader(BaseLoader):
"""
def __init__(self, searchpath, encoding='utf-8'):
if isinstance(searchpath, basestring):
if isinstance(searchpath, string_types):
searchpath = [searchpath]
self.searchpath = list(searchpath)
self.encoding = encoding
@@ -274,7 +272,7 @@ class DictLoader(BaseLoader):
def get_source(self, environment, template):
if template in self.mapping:
source = self.mapping[template]
return source, None, lambda: source != self.mapping.get(template)
return source, None, lambda: source == self.mapping.get(template)
raise TemplateNotFound(template)
def list_templates(self):
@@ -306,7 +304,7 @@ class FunctionLoader(BaseLoader):
rv = self.load_func(template)
if rv is None:
raise TemplateNotFound(template)
elif isinstance(rv, basestring):
elif isinstance(rv, string_types):
return rv, None, None
return rv
@@ -359,7 +357,7 @@ class PrefixLoader(BaseLoader):
def list_templates(self):
result = []
for prefix, loader in self.mapping.iteritems():
for prefix, loader in iteritems(self.mapping):
for template in loader.list_templates():
result.append(prefix + self.delimiter + template)
return result
@@ -431,7 +429,7 @@ class ModuleLoader(BaseLoader):
# create a fake module that looks for the templates in the
# path given.
mod = _TemplateModule(package_name)
if isinstance(path, basestring):
if isinstance(path, string_types):
path = [path]
else:
path = list(path)