From a8dd19fe2794aca3a622c9c6f4f145659753947c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sat, 7 Nov 2015 09:21:55 +0100 Subject: [PATCH] pattern should always be defined --- patacrep/files.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/patacrep/files.py b/patacrep/files.py index 2f8ea8cd..a204f8e7 100644 --- a/patacrep/files.py +++ b/patacrep/files.py @@ -25,12 +25,15 @@ def recursive_find(root_directory, extensions=None): return [] matches = [] - if extensions: + if extensions is None: + pattern = re.compile('.*') + else: pattern = re.compile(r'.*\.({})$'.format('|'.join(extensions))) + with chdir(root_directory): for root, __ignored, filenames in os.walk(os.curdir): for filename in filenames: - if not extensions or pattern.match(filename): + if pattern.match(filename): matches.append(os.path.join(root, filename)) return matches