X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FFileUtils.py;h=ac50b8a9b7a5a0d9be116664054b65a52d737e97;hb=3a1235a834118bb52c5d92fce9c7182c04a44e0b;hp=cf2df4e897c73f50b7e7bff88ef4e5af0c5d893f;hpb=226986f4ad9de637ec22b5ee1436f0a365aaf808;p=dead%2Fcensus-tools.git diff --git a/src/FileUtils.py b/src/FileUtils.py index cf2df4e..ac50b8a 100644 --- a/src/FileUtils.py +++ b/src/FileUtils.py @@ -29,22 +29,23 @@ def mkdir_p(path, mode): -def find_file_paths(root, target_filename, return_first = False): +def find_file_paths(root, target_filenames=[], return_first = False): """ - Search beneath root for files named target_filename. If - return_first is True, then return as soon as a match is - found. Otherwise, return once all matching paths have been - found. Either way, the result is a list containing all matched - paths (even if we only matched one). + Search beneath root for files whose names are contained in the + target_filenames list. If return_first is True, then return as + soon as a match is found. Otherwise, return once all matching + paths have been found. Either way, the result is a list containing + all matched paths (even if we only matched one). """ found_files = [] for folder, subfolders, files in os.walk(root): for f in files: - if (f == target_filename): - if return_first: - return [os.path.join(folder, f)] - else: - found_files.append(os.path.join(folder, f)) + for t in target_filenames: + if (f == t): + if return_first: + return [os.path.join(folder, f)] + else: + found_files.append(os.path.join(folder, f)) return found_files