diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 55bcadc..ebf5e9c 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -48,10 +48,10 @@ def _remove_superfluous_paths(): """Removes superfluous files and directories.""" optional_paths = [(re.compile(path), keep) for path, keep in OPTIONAL_PATHS] rootdir = "." - for dirpath, dirnames, filenames in os.walk(rootdir): - for pathname in dirnames + filenames: - fullpath = os.path.join(dirpath, pathname) - for pattern, keep in optional_paths: + for pattern, keep in optional_paths: + for dirpath, dirnames, filenames in os.walk(rootdir): + for pathname in dirnames + filenames: + fullpath = os.path.join(dirpath, pathname) if pattern.match(fullpath): if not keep: if os.path.isfile(fullpath):