devctrl.utility.hdf5_backup.find_tld_datafile#

find_tld_datafile(p: Path, file_pattern: str) → Path[source]#

Find the data file associated with the path.

Parameters:
  • p – Path to find the main data file for.

  • file_pattern – Pattern to match filenames with using re.fullmatch().

Raises:
  • FileNotFoundError – If the file was not found.

  • RuntimeError – If multiple matching files are found in one directory.

Returns:

Main data file path.

  • If p is the file itself, return it.

  • If p is a directory, check if it contains the file.

  • If p is a file, check if the data file is in the same directory.

  • Search for the data file in the three directories above the given path.