(
    dirpath: types.PathLike,
    *,
    match_regex: Optional[str] = None,
    ignore_regex: Optional[str] = None,
    extension: Optional[str] = None,
    ignore_invisible: bool = True,
    recursive: bool = False,
)
Yield full paths of files on disk under directory ``dirpath``, optionally
    filtering for or against particular patterns or file extensions and
    crawling all subdirectories.

    Args:
        dirpath: Path to directory on disk where files are stored.
        match_regex: Regular expression pattern.
            Only files whose names match this pattern are included.
        ignore_regex: Regular expression pattern.
            Only files whose names *do not* match this pattern are included.
        extension: File extension, e.g. ".txt" or ".json".
            Only files whose extensions match are included.
        ignore_invisible: If True, ignore invisible files,
            i.e. those that begin with a period.; otherwise, include them.
        recursive: If True, iterate recursively through subdirectories
            in search of files to include; otherwise, only return files located
            directly under ``dirpath``.

    Yields:
        Next file's name, including the full path on disk.

    Raises:
        OSError: if ``dirpath`` is not found on disk
Yield full paths of files on disk under directory ``dirpath``, optionally
    filtering for or against particular patterns or file extensions and
    crawling all subdirectories.
Yield full paths of files on disk under directory dirpath optionally filtering for or against particular patterns or file extensions and crawling all subdirectories .
def get_filepaths(
    dirpath: types.PathLike,
    *,
    match_regex: Optional[str] = None,
    ignore_regex: Optional[str] = None,
    extension: Optional[str] = None,
    ignore_invisible: bool = True,
    recursive: bool = False,
) -> Iterable[str]:
    """
    Yield full paths of files on disk under directory ``dirpath``, optionally
    filtering for or against particular patterns or file extensions and
    crawling all subdirectories.

    Args:
        dirpath: Path to directory on disk where files are stored.
        match_regex: Regular expression pattern.
            Only files whose names match this pattern are included.
        ignore_regex: Regular expression pattern.
            Only files whose names *do not* match this pattern are included.
        extension: File extension, e.g. ".txt" or ".json".
            Only files whose extensions match are included.
        ignore_invisible: If True, ignore invisible files,
            i.e. those that begin with a period.; otherwise, include them.
        recursive: If True, iterate recursively through subdirectories
            in search of files to include; otherwise, only return files located
            directly under ``dirpath``.

    Yields:
        Next file's name, including the full path on disk.

    Raises:
        OSError: if ``dirpath`` is not found on disk
    """
    dirpath = utils.to_path(dirpath).resolve()
    if not dirpath.is_dir():
        raise OSError(f"directory '{dirpath}' does not exist")

    re_match = re.compile(match_regex) if match_regex else None
    re_ignore = re.compile(ignore_regex) if ignore_regex else None

    def is_good_file(dpath, fname):
        if ignore_invisible and fname.startswith("."):
            return False
        if re_match and not re_match.search(fname):
            return False
        if re_ignore and re_ignore.search(fname):
            return False
        if extension and os.path.splitext(fname)[-1] != extension:
            return False
        if not os.path.isfile(os.path.join(dpath, fname)):
            return False
        return True

    if recursive is True:
        for dirpath_, _, filenames in os.walk(dirpath):
            if ignore_invisible and dirpath_.startswith("."):
                continue
            for filename in filenames:
                if filename.startswith("."):
                    continue
                if is_good_file(dirpath_, filename):
                    yield os.path.join(dirpath_, filename)
    else:
        for subpath in dirpath.iterdir():
            if is_good_file(str(dirpath), subpath.name):
                yield str(subpath)
def get_filepaths ( dirpath : types . PathLike , * , match_regex : Optional [ str ] = None , ignore_regex : Optional [ str ] = None , extension : Optional [ str ] = None , ignore_invisible : bool = True , recursive : bool = False , ) -> Iterable [ str ] : dirpath = utils . to_path ( dirpath ) . resolve ( ) if not dirpath . is_dir ( ) : raise OSError ( f"directory '{dirpath}' does not exist" ) re_match = re . compile ( match_regex ) if match_regex else None re_ignore = re . compile ( ignore_regex ) if ignore_regex else None def is_good_file ( dpath , fname ) : if ignore_invisible and fname . startswith ( "." ) : return False if re_match and not re_match . search ( fname ) : return False if re_ignore and re_ignore . search ( fname ) : return False if extension and os . path . splitext ( fname ) [ - 1 ] != extension : return False if not os . path . isfile ( os . path . join ( dpath , fname ) ) : return False return True if recursive is True : for dirpath_ , _ , filenames in os . walk ( dirpath ) : if ignore_invisible and dirpath_ . startswith ( "." ) : continue for filename in filenames : if filename . startswith ( "." ) : continue if is_good_file ( dirpath_ , filename ) : yield os . path . join ( dirpath_ , filename ) else : for subpath in dirpath . iterdir ( ) : if is_good_file ( str ( dirpath ) , subpath . name ) : yield str ( subpath )