If infile is a string, it opens and returns it. If it’s already a file object, it simply returns it. This function returns (file, should_close_flag). The should_close_flag is True is a file has effectively been opened (if we already pass a file object, we assume that the responsibility for closing the file has already been taken). Example usage:
fp, shouldclose = open_if_filename(infile)
dostuff()
if shouldclose:
fp.close()
Does the same as open_if_filename(), but it can be used with a with statement. Example:
with FileOrPath(infile):
dostuff()
Remove all empty folders inside path recursively. If deleteself is True and path ends up being empty, it is deleted as well. files_to_delete is a list of filenames that we wish to ignore when we determine if a folder is empty or not (for example, those pesky “.DS_Store” files under OS X).
Same as with clean_empty_dirs(), but not recursive.
Copies source_path to dest_path, recursively. However, it does conflict resolution using the conflict module.
Returns True if first_path‘s mtime is higher than second_path‘s mtime.