Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore subdirectories by pattern #1678

Open
skettlitz opened this issue Apr 2, 2015 · 3 comments
Open

Ignore subdirectories by pattern #1678

skettlitz opened this issue Apr 2, 2015 · 3 comments
Assignees

Comments

@skettlitz
Copy link

Currently ignoring subdirectories by pattern is not possible.

What works is:

  1. ignoring files by pattern by setting 'IGNORE_FILES = ["pattern1_","pattern2_","._","__"]'
  2. ignoring specific directories by setting 'PATH_EXCLUDE = ["maindir1","maindir2/subdir"]'

What I'd suggest is another way to ignore subdirectories by pattern.

The following code adds a configuration variable 'IGNORE_SUBDIRS' analogous to 'IGNORE_FILES'.

diff --git a/pelican/generators.py b/pelican/generators.py
index 75bd6b2..20942ab 100644
--- a/pelican/generators.py
+++ b/pelican/generators.py
@@ -139,6 +139,11 @@ class Generator(object):
                     for e in exclusions_by_dirpath.get(dirpath, ()):
                         if e in dirs:
                             dirs.remove(e)
+                    for dir in dirs:
+                        #check IGNORE_SUBDIRS
+                        ignores = self.settings['IGNORE_SUBDIRS']
+                        if any(fnmatch.fnmatch(dir, ignore) for ignore in ignores):
+                            dirs.remove(dir)
                     reldir = os.path.relpath(dirpath, self.path)
                     for f in temp_files:
                         fp = os.path.join(reldir, f)

and

diff --git a/pelican/settings.py b/pelican/settings.py
index 0d69c08..c675f50 100644
--- a/pelican/settings.py
+++ b/pelican/settings.py
@@ -122,6 +122,7 @@ DEFAULT_CONFIG = {
     'PYGMENTS_RST_OPTIONS': {},
     'TEMPLATE_PAGES': {},
     'IGNORE_FILES': ['.#*'],
+    'IGNORE_SUBDIRS': [],
     'SLUG_SUBSTITUTIONS': (),
     'INTRASITE_LINK_REGEX': '[{|](?P<what>.*?)[|}]',
     'SLUGIFY_SOURCE': 'title',
@leotrs
Copy link

leotrs commented Aug 1, 2016

LGTM

@justinmayer
Copy link
Member

@leotrs: Nothing to merge here, because it's not a pull request. 😉

If this were to be submitted as a pull request, replete with docs and tests, then we could certainly consider merging it.

@justinmayer justinmayer changed the title Ignore subdirectories by pattern. Ignore subdirectories by pattern Sep 11, 2016
@Scheirle
Copy link
Member

Somewhat related to #1975

@justinmayer justinmayer self-assigned this Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants