pytest_wdl/utils.py
def find_project_path(
    *filenames: Union[str, Path],
    start: Optional[Path] = None,
    return_parent: bool = False,
    assert_exists: bool = False,
) -> Optional[Path]:
    """
    Starting from `path` folder and moving upwards, search for any of `filenames` and
    return the first path containing any one of them.

    Args:
        *filenames: Filenames to search. Either a string filename, or a sequence of
            string path elements.
        start: Starting folder
        return_parent: Whether to return the containing folder or the discovered file.
        assert_exists: Whether to raise an exception if a file cannot be found.

    Returns:
        A `Path`, or `None` if no folder is found that contains any of `filenames`.
        If `return_parent` is `False` and more than one of the files is found one
        of the files is randomly selected for return.

    Raises:
        FileNotFoundError if the file cannot be found and `assert_exists` is True.
    """
    path = start or Path.cwd()
    while path != path.parent:
        for filename in filenames:
            if isinstance(filename, str):
                found = list(path.glob(filename))
                found = found[0] if found else None
            else:
                found = path / filename
                if not found.exists():
                    found = None
            if found:
                LOG.debug("Found %s in %s", filename, path)
                if return_parent:
                    return path
                else:
                    return found
        else:
            path = path.parent

    if assert_exists:
        raise FileNotFoundError(
            f"Could not find any of {','.join(str(f) for f in filenames)} "
            f"starting from {start}"
        )

    return None

    Starting from `path` folder and moving upwards, search for any of `filenames` and
    return the first path containing any one of them.

    Args:
        *filenames: Filenames to search. Either a string filename, or a sequence of
            string path elements.
        start: Starting folder
        return_parent: Whether to return the containing folder or the discovered file.
        assert_exists: Whether to raise an exception if a file cannot be found.

    Returns:
        A `Path`, or `None` if no folder is found that contains any of `filenames`.
        If `return_parent` is `False` and more than one of the files is found one
        of the files is randomly selected for return.

    Raises:
        FileNotFoundError if the file cannot be found and `assert_exists` is True.
    
Starting from `path` folder and moving upwards, search for any of `filenames` and
return the first path containing any one of them.

Filenames to search. Either a string filename, or a sequence of
string path elements.
start: Starting folder
return_parent: Whether to return the containing folder or the discovered file.
assert_exists: Whether to raise an exception if a file cannot be found.



FileNotFoundError if the file cannot be found and `assert_exists` is True.
Starting from ` path ` folder and moving upwards search for any of ` filenames ` and return the first path containing any one of them . Filenames to search . Either a string filename or a sequence of string path elements . start : Starting folder return_parent : Whether to return the containing folder or the discovered file . assert_exists : Whether to raise an exception if a file cannot be found . FileNotFoundError if the file cannot be found and ` assert_exists ` is True .
def find_project_path(
    *filenames: Union[str, Path],
    start: Optional[Path] = None,
    return_parent: bool = False,
    assert_exists: bool = False,
) -> Optional[Path]:
    path = start or Path.cwd()
    while path != path.parent:
        for filename in filenames:
            if isinstance(filename, str):
                found = list(path.glob(filename))
                found = found[0] if found else None
            else:
                found = path / filename
                if not found.exists():
                    found = None
            if found:
                LOG.debug("Found %s in %s", filename, path)
                if return_parent:
                    return path
                else:
                    return found
        else:
            path = path.parent
    if assert_exists:
        raise FileNotFoundError(
            f"Could not find any of {','.join(str(f) for f in filenames)} "
            f"starting from {start}"
        )
    return None
def find_project_path ( * filenames : Union [ str , Path ] , start : Optional [ Path ] = None , return_parent : bool = False , assert_exists : bool = False , ) -> Optional [ Path ] : path = start or Path . cwd ( ) while path != path . parent : for filename in filenames : if isinstance ( filename , str ) : found = list ( path . glob ( filename ) ) found = found [ 0 ] if found else None else : found = path / filename if not found . exists ( ) : found = None if found : LOG . debug ( "Found %s in %s" , filename , path ) if return_parent : return path else : return found else : path = path . parent if assert_exists : raise FileNotFoundError ( f"Could not find any of {','.join(str(f) for f in filenames)} " f"starting from {start}" ) return None
Starting from `path` folder and moving upwards, search for any of `filenames` and
return the first path containing any one of them.
Starting from ` path ` folder and moving upwards search for any of ` filenames ` and return the first path containing any one of them .
"""
    Starting from `path` folder and moving upwards, search for any of `filenames` and
    return the first path containing any one of them.

    Args:
        *filenames: Filenames to search. Either a string filename, or a sequence of
            string path elements.
        start: Starting folder
        return_parent: Whether to return the containing folder or the discovered file.
        assert_exists: Whether to raise an exception if a file cannot be found.

    Returns:
        A `Path`, or `None` if no folder is found that contains any of `filenames`.
        If `return_parent` is `False` and more than one of the files is found one
        of the files is randomly selected for return.

    Raises:
        FileNotFoundError if the file cannot be found and `assert_exists` is True.
    """
filenames
Union[str, Path]
start
Optional[Path]
return_parent
bool
assert_exists
bool