mlfmu.utils.path

Functions

find_default_file(folder, file_extension[, ...])

Return a file inside folder with the file extension that matches file_extension.

mlfmu.utils.path.find_default_file(folder: Path, file_extension: str, default_name: str | None = None) Path | None

Return a file inside folder with the file extension that matches file_extension.

If there are multiple matches it uses the closest match to default_name if given. Return None if there is no clear match.

Parameters:
  • folder (Path) – the folder to search in

  • file_extension (str) – file extension to search for

  • default_name (str | None, optional) – file name used to determine “closest match” in case multiple files match file_extension, by default None

Returns:

the path to the file if it is found, otherwise None

Return type:

Path | None