Skip to content

GH-72904: Add glob.translate() function #106703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Nov 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bbfd404
GH-72904: Add optional *seps* argument to `fnmatch.translate()`
barneygale Jun 18, 2023
da9948d
Simplify `_make_child_relpath()` further
barneygale Jul 13, 2023
a07118b
Fix default value in docs
barneygale Jul 13, 2023
2728dcd
Match style of surrounding `fnmatch` code a little better.
barneygale Jul 13, 2023
fbcf4e3
Merge branch 'main' into gh-72904-fnmatch-seps
barneygale Jul 19, 2023
a0ce9c4
Docs + naming improvements
barneygale Jul 19, 2023
5b620fb
Replace *seps* with *sep*
barneygale Jul 26, 2023
51f2698
Update Doc/library/fnmatch.rst
barneygale Aug 4, 2023
9c8c3f3
Move to `glob.translate()`
barneygale Aug 11, 2023
8518ea2
Whoops
barneygale Aug 12, 2023
75129c8
Deduplicate code to handle character sets
barneygale Aug 13, 2023
2505590
Add support for `include_hidden=False`
barneygale Sep 23, 2023
1754d42
Fix doctest
barneygale Sep 23, 2023
dd2d401
Merge branch 'main' into gh-72904-fnmatch-seps
barneygale Sep 23, 2023
7b1ad63
Improve implementation; minimise fnmatch and pathlib diffs.
barneygale Sep 25, 2023
1485ff3
Fix tests
barneygale Sep 26, 2023
4c6d6f0
Tiny performance tweak
barneygale Sep 26, 2023
5aae7a2
Merge branch 'main' into gh-72904-fnmatch-seps
barneygale Sep 26, 2023
afb2d43
Fix `_make_child_relpath()`
barneygale Sep 26, 2023
d73df1b
Minor code improvements
barneygale Sep 26, 2023
c70afe3
Add another test for `include_hidden=False`
barneygale Sep 26, 2023
9cb2952
Merge branch 'main' into gh-72904-fnmatch-seps
barneygale Sep 30, 2023
f178b14
Add whatsnew entry
barneygale Sep 30, 2023
4a726aa
Collapse adjacent `**` segments.
barneygale Sep 30, 2023
78292eb
Apply suggestions from code review
barneygale Sep 30, 2023
5d4062c
Add comment explaining regex that consumes "empty" paths.
barneygale Sep 30, 2023
1ad624d
Merge branch 'main' into gh-72904-fnmatch-seps
barneygale Oct 28, 2023
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-72904-fnmatch-seps
  • Loading branch information
barneygale committed Jul 19, 2023
commit fbcf4e39dea505bdd9ca0f0533dbfd62d83fe50c
10 changes: 5 additions & 5 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def _str_normcase(self):
try:
return self._str_normcase_cached
except AttributeError:
if _is_case_sensitive(self._flavour):
if _is_case_sensitive(self.pathmod):
self._str_normcase_cached = self._str
else:
self._str_normcase_cached = self._str.lower()
Expand Down Expand Up @@ -656,8 +656,8 @@ def match(self, path_pattern, *, case_sensitive=None):
if not isinstance(path_pattern, PurePath):
path_pattern = self.with_segments(path_pattern)
if case_sensitive is None:
case_sensitive = _is_case_sensitive(self._flavour)
sep = path_pattern._flavour.sep
case_sensitive = _is_case_sensitive(self.pathmod)
sep = path_pattern.pathmod.sep
pattern_str = path_pattern._str
if path_pattern.drive or path_pattern.root:
pass
Expand Down Expand Up @@ -942,7 +942,7 @@ def _scandir(self):
def _make_child_relpath(self, name):
tail = self._tail
if tail:
path_str = f'{self._str}{self._flavour.sep}{name}'
path_str = f'{self._str}{self.pathmod.sep}{name}'
else:
path_str = f'{self._str}{name}'
path = self.with_segments(path_str)
Expand Down Expand Up @@ -995,7 +995,7 @@ def _glob(self, pattern, case_sensitive, follow_symlinks):
# do not perform any filesystem access, which can be much faster!
filter_paths = follow_symlinks is not None and '..' not in pattern_parts
deduplicate_paths = False
sep = self._flavour.sep
sep = self.pathmod.sep
paths = iter([self] if self.is_dir() else [])
part_idx = 0
while part_idx < len(pattern_parts):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.