locan.locan_io.utilities.find_file_upstream

locan.locan_io.utilities.find_file_upstream(sub_directory, pattern, regex=None, top_directory=None)[source]

Search for first upstream parent of sub_directory that contains pattern. Return first pattern found. Return None if no pattern has been found when parent equals directory.

Parameters:
  • sub_directory (str | PathLike[str]) – Directory or file path to start with.

  • pattern (str | None) – glob pattern passed to Path.glob()

  • regex (str | None) – regex pattern passed to re.search() and applied in addition to glob pattern

  • top_directory (str | PathLike[str] | None) – Directory in which to stop the search.

Return type:

Path | None