Remove logic for iterating directories to search for config file
@@ -6,18 +6,11 @@ import os
import re
-def find_all(path, filename_regex):
- """Find all files in ``path`` that match ``filename_regex`` regex."""
- path = os.path.abspath(path)
- for root, dirs, files in os.walk(path, topdown=True):
- dirs.sort()
- for filename in files:
- if re.match(filename_regex, filename):
- yield os.path.abspath(os.path.join(root, filename))
-
-
def find_one(path, filename_regex):
"""Find the first file in ``path`` that match ``filename_regex`` regex."""
- for _path in find_all(path, filename_regex):
- return _path
+ _path = os.path.abspath(path)
+ for filename in os.listdir(_path):
+ if re.match(filename_regex, filename):
+ return os.path.join(_path, filename)
+
return ''
