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.
This commit is contained in:
Paul Logston 2016-06-09 01:09:58 -04:00
commit bdd7daf419
No known key found for this signature in database
GPG key ID: 69A100239E35ED16

View file

@ -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