diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-05-03 21:29:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-03 20:29:25 +0000 |
commit | a40f557d7b7a355a55bb90c068e3e9202fd9c8f2 (patch) | |
tree | e61989ef41abe7d9eb6b693bbd7300f308b16396 /Lib/pathlib/_abc.py | |
parent | 37d095002216a4e45b4e82539ca0421ded8aaae3 (diff) | |
download | cpython-a40f557d7b7a355a55bb90c068e3e9202fd9c8f2.tar.gz cpython-a40f557d7b7a355a55bb90c068e3e9202fd9c8f2.zip |
GH-116380: Move pathlib globbing implementation into `pathlib._glob` (#118562)
Moving this code under the `pathlib` package makes it quite a lot easier
to backport in the `pathlib-abc` PyPI package. It was a bit foolish of me
to add it to `glob` in the first place.
Also add `translate()` to `__all__` in `glob`. This function is new in
3.13, so there's no NEWS needed.
Diffstat (limited to 'Lib/pathlib/_abc.py')
-rw-r--r-- | Lib/pathlib/_abc.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/pathlib/_abc.py b/Lib/pathlib/_abc.py index c7e8e2f68ed..591df443be0 100644 --- a/Lib/pathlib/_abc.py +++ b/Lib/pathlib/_abc.py @@ -12,11 +12,12 @@ resemble pathlib's PurePath and Path respectively. """ import functools -import glob import operator from errno import ENOENT, ENOTDIR, EBADF, ELOOP, EINVAL from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO +from . import _glob + # # Internals # @@ -43,7 +44,7 @@ def _is_case_sensitive(parser): return parser.normcase('Aa') == 'Aa' -class Globber(glob._Globber): +class Globber(_glob.Globber): lstat = operator.methodcaller('lstat') add_slash = operator.methodcaller('joinpath', '') @@ -692,7 +693,7 @@ class PathBase(PurePathBase): # know the case sensitivity of the underlying filesystem, so we # must use scandir() for everything, including non-wildcard parts. case_pedantic = True - recursive = True if recurse_symlinks else glob._no_recurse_symlinks + recursive = True if recurse_symlinks else _glob.no_recurse_symlinks globber = self._globber(self.parser.sep, case_sensitive, case_pedantic, recursive) return globber.selector(parts) |