mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add regular expressions support into STATIC_PATHS.
This commit is contained in:
parent
f1a9d50a06
commit
429d2c42e4
1 changed files with 18 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ import logging
|
|||
import shutil
|
||||
import fnmatch
|
||||
import calendar
|
||||
import re
|
||||
|
||||
from codecs import open
|
||||
from collections import defaultdict
|
||||
|
|
@ -126,6 +127,7 @@ class Generator(object):
|
|||
root = os.path.join(self.path, path)
|
||||
|
||||
if os.path.isdir(root):
|
||||
# walk specified directory
|
||||
for dirpath, dirs, temp_files in os.walk(root, followlinks=True):
|
||||
for e in exclude:
|
||||
if e in dirs:
|
||||
|
|
@ -136,7 +138,22 @@ class Generator(object):
|
|||
if self._include_path(fp, extensions):
|
||||
files.append(fp)
|
||||
elif os.path.exists(root) and self._include_path(path, extensions):
|
||||
files.append(path) # can't walk non-directories
|
||||
# can't walk non-directories
|
||||
files.append(path)
|
||||
else:
|
||||
# walk all directories and match based on regexp
|
||||
path_pat = re.compile(path)
|
||||
for dirpath, dirs, temp_files in os.walk(self.path, followlinks=True):
|
||||
if not path_pat.match(dirpath):
|
||||
continue
|
||||
for e in exclude:
|
||||
if e in dirs:
|
||||
dirs.remove(e)
|
||||
reldir = os.path.relpath(dirpath, self.path)
|
||||
for f in temp_files:
|
||||
fp = os.path.join(reldir, f)
|
||||
if self._include_path(fp, extensions):
|
||||
files.append(fp)
|
||||
return files
|
||||
|
||||
def add_source_path(self, content):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue