Skip to content

Commit

Permalink
Delete _globber too.
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Dec 12, 2024
1 parent 15614a6 commit 00a89bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions Lib/pathlib/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class PurePathBase:
'_raw_paths',
)
parser = posixpath
_globber = PathGlobber

def __init__(self, *args):
for arg in args:
Expand Down Expand Up @@ -321,7 +320,7 @@ def match(self, path_pattern, *, case_sensitive=None):
return False
if len(path_parts) > len(pattern_parts) and path_pattern.anchor:
return False
globber = self._globber(sep, case_sensitive)
globber = PathGlobber(sep, case_sensitive)
for path_part, pattern_part in zip(path_parts, pattern_parts):
match = globber.compile(pattern_part)
if match(path_part) is None:
Expand All @@ -337,7 +336,7 @@ def full_match(self, pattern, *, case_sensitive=None):
pattern = self.with_segments(pattern)
if case_sensitive is None:
case_sensitive = _is_case_sensitive(self.parser)
globber = self._globber(pattern.parser.sep, case_sensitive, recursive=True)
globber = PathGlobber(pattern.parser.sep, case_sensitive, recursive=True)
match = globber.compile(str(pattern))
return match(str(self)) is not None

Expand Down Expand Up @@ -512,7 +511,7 @@ def glob(self, pattern, *, case_sensitive=None, recurse_symlinks=True):
else:
case_pedantic = True
recursive = True if recurse_symlinks else _no_recurse_symlinks
globber = self._globber(self.parser.sep, case_sensitive, case_pedantic, recursive)
globber = PathGlobber(self.parser.sep, case_sensitive, case_pedantic, recursive)
select = globber.selector(parts)
return select(self)

Expand Down
5 changes: 2 additions & 3 deletions Lib/pathlib/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class PurePath(PurePathBase):
'_hash',
)
parser = os.path
_globber = _StringGlobber

def __new__(cls, *args, **kwargs):
"""Construct a PurePath from one or several strings and or existing
Expand Down Expand Up @@ -497,7 +496,7 @@ def full_match(self, pattern, *, case_sensitive=None):
# paths shouldn't match wildcards, so we change it to the empty string.
path = str(self) if self.parts else ''
pattern = str(pattern) if pattern.parts else ''
globber = self._globber(self.parser.sep, case_sensitive, recursive=True)
globber = _StringGlobber(self.parser.sep, case_sensitive, recursive=True)
return globber.compile(pattern)(path) is not None

# Subclassing os.PathLike makes isinstance() checks slower,
Expand Down Expand Up @@ -743,7 +742,7 @@ def glob(self, pattern, *, case_sensitive=None, recurse_symlinks=False):
case_pedantic = True
parts = self._parse_pattern(pattern)
recursive = True if recurse_symlinks else _no_recurse_symlinks
globber = self._globber(self.parser.sep, case_sensitive, case_pedantic, recursive)
globber = _StringGlobber(self.parser.sep, case_sensitive, case_pedantic, recursive)
select = globber.selector(parts[::-1])
root = str(self)
paths = select(root)
Expand Down

0 comments on commit 00a89bf

Please sign in to comment.