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 (Optional[str]) – glob pattern passed to Path.glob()

  • regex (Optional[str]) – regex pattern passed to re.search() and applied in addition to glob pattern

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

Return type:

Path | None