From 3ccd0199221069c2a6af37559db1c0a8b0294739 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 25 Nov 2007 14:35:43 +0100 Subject: [PATCH] jinja loaders check now if a file is a file and not a directory instead of using path.exists. --HG-- branch : trunk --- jinja/exceptions.py | 2 +- jinja/loaders.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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() -- 2.26.2