diff --git a/pelican/generators.py b/pelican/generators.py index 75eca388..ef021070 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -155,16 +155,15 @@ class Generator(object): if os.path.isdir(root): for dirpath, dirs, temp_files in os.walk( - root, followlinks=True): - drop = [] + root, topdown=True, followlinks=True): excl = exclusions_by_dirpath.get(dirpath, ()) - for d in dirs: + # We copy the `dirs` list as we will modify it in the loop: + for d in list(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) + if d in dirs: + dirs.remove(d) reldir = os.path.relpath(dirpath, self.path) for f in temp_files: diff --git a/pelican/tests/support.py b/pelican/tests/support.py index 93db8328..751fb5ec 100644 --- a/pelican/tests/support.py +++ b/pelican/tests/support.py @@ -188,7 +188,7 @@ class LogCountHandler(BufferingHandler): """Capturing and counting logged messages.""" def __init__(self, capacity=1000): - logging.handlers.BufferingHandler.__init__(self, capacity) + super(LogCountHandler, self).__init__(capacity) def count_logs(self, msg=None, level=None): return len([