]>
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_filename
, return_first
= False):
34 Search beneath root for files named target_filename. If
35 return_first is True, then return as soon as a match is
36 found. Otherwise, return once all matching paths have been
37 found. Either way, the result is a list containing all matched
38 paths (even if we only matched one).
42 for folder
, subfolders
, files
in os
.walk(root
):
44 if (f
== target_filename
):
46 return [os
.path
.join(folder
, f
)]
48 found_files
.append(os
.path
.join(folder
, f
))