mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Apply 'IGNORE_FILES' globs to directories as well (issue 1692)
This adjusts the only piece of code that currently looks at IGNORE_FILES. A subsequent commit will add a new use, with the same semantics.
This commit is contained in:
parent
0a48371985
commit
c7b9a339eb
2 changed files with 15 additions and 6 deletions
|
|
@ -108,9 +108,10 @@ Setting name (followed by default value, if any)
|
||||||
process or ignore. For example, to avoid processing .html files,
|
process or ignore. For example, to avoid processing .html files,
|
||||||
set: ``READERS = {'html': None}``. To add a custom reader for the
|
set: ``READERS = {'html': None}``. To add a custom reader for the
|
||||||
``foo`` extension, set: ``READERS = {'foo': FooReader}``
|
``foo`` extension, set: ``READERS = {'foo': FooReader}``
|
||||||
``IGNORE_FILES = ['.#*']`` A list of file globbing patterns to match against the
|
``IGNORE_FILES = ['.#*']`` A list of glob patterns. Files and directories matching any
|
||||||
source files to be ignored by the processor. For example,
|
of these patterns will be ignored by the processor. For example,
|
||||||
the default ``['.#*']`` will ignore emacs lock files.
|
the default ``['.#*']`` will ignore emacs lock files, and
|
||||||
|
``['__pycache__']`` would ignore Python 3's bytecode caches.
|
||||||
``MD_EXTENSIONS =`` ``['codehilite(css_class=highlight)','extra']`` A list of the extensions that the Markdown processor
|
``MD_EXTENSIONS =`` ``['codehilite(css_class=highlight)','extra']`` A list of the extensions that the Markdown processor
|
||||||
will use. Refer to the Python Markdown documentation's
|
will use. Refer to the Python Markdown documentation's
|
||||||
`Extensions section <http://pythonhosted.org/Markdown/extensions/>`_
|
`Extensions section <http://pythonhosted.org/Markdown/extensions/>`_
|
||||||
|
|
|
||||||
|
|
@ -132,15 +132,23 @@ class Generator(object):
|
||||||
exclusions_by_dirpath.setdefault(parent_path, set()).add(subdir)
|
exclusions_by_dirpath.setdefault(parent_path, set()).add(subdir)
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
|
ignores = self.settings['IGNORE_FILES']
|
||||||
for path in paths:
|
for path in paths:
|
||||||
# careful: os.path.join() will add a slash when path == ''.
|
# careful: os.path.join() will add a slash when path == ''.
|
||||||
root = os.path.join(self.path, path) if path else self.path
|
root = os.path.join(self.path, path) if path else self.path
|
||||||
|
|
||||||
if os.path.isdir(root):
|
if os.path.isdir(root):
|
||||||
for dirpath, dirs, temp_files in os.walk(root, followlinks=True):
|
for dirpath, dirs, temp_files in os.walk(root, followlinks=True):
|
||||||
for e in exclusions_by_dirpath.get(dirpath, ()):
|
drop = []
|
||||||
if e in dirs:
|
excl = exclusions_by_dirpath.get(dirpath, ())
|
||||||
dirs.remove(e)
|
for d in dirs:
|
||||||
|
if (d in excl or
|
||||||
|
any(fnmatch.fnmatch(d, ignore)
|
||||||
|
for ignore in ignores)):
|
||||||
|
drop.append(d)
|
||||||
|
for d in drop:
|
||||||
|
dirs.remove(d)
|
||||||
|
|
||||||
reldir = os.path.relpath(dirpath, self.path)
|
reldir = os.path.relpath(dirpath, self.path)
|
||||||
for f in temp_files:
|
for f in temp_files:
|
||||||
fp = os.path.join(reldir, f)
|
fp = os.path.join(reldir, f)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue