]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - src/FileUtils.py
2 Utility functions for working with the filesystem, generally modeled
3 after useful shell commands.
11 Remove (unlink) a file, ignoring any exceptions that may be
20 def mkdir_p(path
, mode
):
22 Create a directory hierarchy, ignoring any exceptions that may be
26 os
.makedirs(path
, mode
)
32 def find_file_paths(root
, target_filenames
=[], return_first
= False):
34 Search beneath root for files whose names are contained in the
35 target_filenames list. If return_first is True, then return as
36 soon as a match is found. Otherwise, return once all matching
37 paths have been found. Either way, the result is a list containing
38 all matched paths (even if we only matched one).
42 for folder
, subfolders
, files
in os
.walk(root
):
44 for t
in target_filenames
:
47 return [os
.path
.join(folder
, f
)]
49 found_files
.append(os
.path
.join(folder
, f
))