File Path Utils
Module containing file path utilities for WriteStrategy to use.
common_source_base(sources)
Find the common parent directory of the source paths.
Parameters:
-
sources(sequence of pathlib.Path or str) –Source paths of the predictions. Array sources (
"array") are ignored.
Returns:
-
Path or None–The common parent, or None if it cannot be determined (fewer than two file sources, or no shared base such as mixed absolute and relative paths).
create_write_file_path(dirpath, file_path, write_extension, postfix='', source_base=None)
Create the file name for the output file.
If source_base is given, the source path relative to it is preserved under
dirpath, keeping outputs unique for same-named files in different directories.
Parameters:
-
dirpath(Path) –The output directory to write file to.
-
file_path(Path) –The original file path.
-
write_extension(str) –The extension that output files should have.
-
postfix(str, default:"") –Appends to filename before extension.
-
source_base(Path or None, default:None) –Common parent of all sources. If set, the structure relative to it is kept.
Returns:
-
Path–The output file path.