From bdd7daf4190abdc897a85afd22fe345d7d051b7c Mon Sep 17 00:00:00 2001 From: Paul Logston Date: Thu, 9 Jun 2016 01:09:58 -0400 Subject: [PATCH] Check full paths when excluding files The `Generator._include_path` method needs to be updated because it does not filter files with enough specificity. For example, let's say our Pelican project is devoted to hosting article about talks a different conferences. If we wanted to filter a talk at `content/jacksconf-2016/videos/jacks-talk.json`, we could do so (without using this patch) by including `jacks-talk.json` in the list IGNORE_FILES. However, if there are multiple `jacks-talk.json` files (maybe a bunch of different Jacks wanted to talk at a bunch of different conferences), we would exclude all `jacks-talk.json` files by including the single `jacks-talk.json` string in IGNORE_FILES. By checking the full path passed to `_include_path`, we can filter on a more granular level. --- pelican/generators.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pelican/generators.py b/pelican/generators.py index d9923e35..be29793f 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -105,10 +105,13 @@ class Generator(object): """ if extensions is None: extensions = tuple(self.readers.extensions) - basename = os.path.basename(path) # check IGNORE_FILES ignores = self.settings['IGNORE_FILES'] + if any(fnmatch.fnmatch(path, ignore) for ignore in ignores): + return False + + basename = os.path.basename(path) if any(fnmatch.fnmatch(basename, ignore) for ignore in ignores): return False