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
|
|
@ -132,15 +132,23 @@ class Generator(object):
|
|||
exclusions_by_dirpath.setdefault(parent_path, set()).add(subdir)
|
||||
|
||||
files = []
|
||||
ignores = self.settings['IGNORE_FILES']
|
||||
for path in paths:
|
||||
# careful: os.path.join() will add a slash when path == ''.
|
||||
root = os.path.join(self.path, path) if path else self.path
|
||||
|
||||
if os.path.isdir(root):
|
||||
for dirpath, dirs, temp_files in os.walk(root, followlinks=True):
|
||||
for e in exclusions_by_dirpath.get(dirpath, ()):
|
||||
if e in dirs:
|
||||
dirs.remove(e)
|
||||
drop = []
|
||||
excl = exclusions_by_dirpath.get(dirpath, ())
|
||||
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)
|
||||
for f in temp_files:
|
||||
fp = os.path.join(reldir, f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue