mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
ignoring specific subdirectories by setting 'IGNORE_SUBDIRS'
This commit is contained in:
parent
b6526968bd
commit
5dbe3d4205
2 changed files with 10 additions and 0 deletions
|
|
@ -149,6 +149,7 @@ class Generator:
|
|||
|
||||
files = set()
|
||||
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
|
||||
|
|
@ -158,6 +159,14 @@ class Generator:
|
|||
root, topdown=True, followlinks=True):
|
||||
excl = exclusions_by_dirpath.get(dirpath, ())
|
||||
# We copy the `dirs` list as we will modify it in the loop:
|
||||
# ----
|
||||
for dir in dirs:
|
||||
# check the IGNORE_SUBDIRS
|
||||
subdirignores = self.settings['IGNORE_SUBDIRS']
|
||||
|
||||
if any(fnmatch.fnmatch(dir, willignore) for willignore in subdirignores):
|
||||
dirs.remove(dir)
|
||||
# ----
|
||||
for d in list(dirs):
|
||||
if (d in excl or
|
||||
any(fnmatch.fnmatch(d, ignore)
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ DEFAULT_CONFIG = {
|
|||
'TEMPLATE_PAGES': {},
|
||||
'TEMPLATE_EXTENSIONS': ['.html'],
|
||||
'IGNORE_FILES': ['.#*'],
|
||||
'IGNORE_SUBDIRS': [],
|
||||
'SLUG_REGEX_SUBSTITUTIONS': [
|
||||
(r'[^\w\s-]', ''), # remove non-alphabetical/whitespace/'-' chars
|
||||
(r'(?u)\A\s*', ''), # strip leading whitespace
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue