From: Armin Ronacher Date: Sun, 25 Nov 2007 13:35:43 +0000 (+0100) Subject: jinja loaders check now if a file is a file and not a directory instead of using... X-Git-Tag: 2.0rc1~229 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3ccd0199221069c2a6af37559db1c0a8b0294739;p=jinja2.git jinja loaders check now if a file is a file and not a directory instead of using path.exists. --HG-- branch : trunk --- diff --git a/jinja/exceptions.py b/jinja/exceptions.py index d24dc92..c900815 100644 --- a/jinja/exceptions.py +++ b/jinja/exceptions.py @@ -56,7 +56,7 @@ class TestArgumentError(TypeError, TemplateError): TypeError.__init__(self, message) -class TemplateNotFound(IOError, TemplateError): +class TemplateNotFound(IOError, LookupError, TemplateError): """ Raised if a template does not exist. """ diff --git a/jinja/loaders.py b/jinja/loaders.py index ffb4789..09f7dda 100644 --- a/jinja/loaders.py +++ b/jinja/loaders.py @@ -414,7 +414,7 @@ class BaseFileSystemLoader(BaseLoader): def get_source(self, environment, name, parent): filename = get_template_filename(self.searchpath, name) - if path.exists(filename): + if path.isfile(filename): f = codecs.open(filename, 'r', environment.template_charset) try: return f.read() @@ -473,7 +473,7 @@ class FileSystemLoader(CachedLoaderMixin, BaseFileSystemLoader): def check_source_changed(self, environment, name): filename = get_template_filename(self.searchpath, name) - if path.exists(filename): + if path.isfile(filename): return path.getmtime(filename) return -1 @@ -562,7 +562,7 @@ class BasePackageLoader(BaseLoader): self.package_path.split('/') + [p for p in name.split('/') if p != '..']) ) - if path.exists(filename): + if path.isfile(filename): f = file(filename) try: return f.read()