Skip to content

Commit

Permalink
Remove glob_scanner and glob_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
xymy committed Nov 30, 2023
1 parent 51b2962 commit 65397ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed

- Removed `glob_scanner()` and `glob_filter()` functions.

## [6.1] - 2023-11-30

### Added
Expand Down
59 changes: 0 additions & 59 deletions src/gethash/utils/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,65 +92,6 @@ def _path_filter(paths: Iterable[AnyStr], *, type: str) -> Iterator[AnyStr]:
yield from filter(pred, paths)


def glob_scanner(
path: AnyStr, *, mode: int = 1, recursive: bool = False, user: bool = False, vars: bool = False
) -> Iterator[AnyStr]:
"""Match a path with glob patterns.
Parameters:
path (AnyStr):
A path with glob patterns.
mode (int, default=1):
The mode of glob. If ``0``, disable globbing; if ``1``, resolve
``*`` and ``?``; if ``2``, resolve ``*``, ``?`` and ``[]``.
recursive (bool, default=False):
If ``True``, the pattern ``**`` will match any files and zero or
more directories, subdirectories and symbolic links to directories.
user (bool, default=False):
If ``True``, user home directory will be expanded.
vars (bool, default=False):
If ``True``, environment variables will be expanded.
Yields:
AnyStr:
The matched path.
"""

glob = _get_glob(mode)
yield from glob(path, recursive=recursive, user=user, vars=vars)


def glob_filter(
path: AnyStr, *, mode: int = 1, type: str = "a", recursive: bool = False, user: bool = False, vars: bool = False
) -> Iterator[AnyStr]:
"""Match and filter a path with glob patterns.
Parameters:
path (AnyStr):
A path with glob patterns.
mode (int, default=1):
The mode of glob. If ``0``, disable globbing; if ``1``, resolve
``*`` and ``?``; if ``2``, resolve ``*``, ``?`` and ``[]``.
type (str, default='a'):
The type of file. If ``a``, include all types; if ``d``, include
directories; if ``f``, include files.
recursive (bool, default=False):
If ``True``, the pattern ``**`` will match any files and zero or
more directories, subdirectories and symbolic links to directories.
user (bool, default=False):
If ``True``, user home directory will be expanded.
vars (bool, default=False):
If ``True``, environment variables will be expanded.
Yields:
AnyStr:
The matched path with the given file type.
"""

matched = glob_scanner(path, mode=mode, recursive=recursive, user=user, vars=vars)
yield from _path_filter(matched, type=type)


def glob_scanners(
paths: Iterable[AnyStr], *, mode: int = 1, recursive: bool = False, user: bool = False, vars: bool = False
) -> Iterator[AnyStr]:
Expand Down

0 comments on commit 65397ce

Please sign in to comment.