Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into gh-81079-glob-case-sensitive-arg-2
  • Loading branch information
barneygale committed May 2, 2023
commit c411cfacb54d610756f9da4c5987e8ff98d49fd1
18 changes: 11 additions & 7 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ def _ignore_error(exception):
return (getattr(exception, 'errno', None) in _IGNORED_ERRNOS or
getattr(exception, 'winerror', None) in _IGNORED_WINERRORS)

#
# Globbing helpers
#

def _is_wildcard_pattern(pat):
# Whether this pattern needs actual matching using fnmatch, or can
# be looked up directly as a file.
return "*" in pat or "?" in pat or "[" in pat

def _is_case_sensitive(flavour):
return flavour.normcase('Aa') == 'Aa'

#
# Globbing helpers
#

@functools.lru_cache()
def _make_selector(pattern_parts, case_sensitive):
Expand All @@ -73,8 +78,6 @@ def _make_selector(pattern_parts, case_sensitive):
cls = _ParentSelector
elif '**' in pat:
raise ValueError("Invalid pattern: '**' can only be an entire path component")
elif pat == '..':
cls = _ParentSelector
else:
cls = _WildcardSelector
return cls(pat, child_parts, case_sensitive)
Expand Down Expand Up @@ -114,9 +117,10 @@ class _ParentSelector(_Selector):
def __init__(self, name, child_parts, case_sensitive):
_Selector.__init__(self, child_parts, case_sensitive)

def _select_from(self, parent_path, scandir):
def _select_from(self, parent_path, scandir):
path = parent_path._make_child_relpath('..')
return self.successor._select_from(path, scandir)
for p in self.successor._select_from(path, scandir):
yield p


class _WildcardSelector(_Selector):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.