mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-122903: Honor directories in zipfile.Path.glob. (#122908)
This commit is contained in:
parent
9cd0326310
commit
6aa35f3002
4 changed files with 40 additions and 9 deletions
|
@ -28,7 +28,7 @@ class Translator:
|
|||
"""
|
||||
Given a glob pattern, produce a regex that matches it.
|
||||
"""
|
||||
return self.extend(self.translate_core(pattern))
|
||||
return self.extend(self.match_dirs(self.translate_core(pattern)))
|
||||
|
||||
def extend(self, pattern):
|
||||
r"""
|
||||
|
@ -41,6 +41,14 @@ class Translator:
|
|||
"""
|
||||
return rf'(?s:{pattern})\Z'
|
||||
|
||||
def match_dirs(self, pattern):
|
||||
"""
|
||||
Ensure that zipfile.Path directory names are matched.
|
||||
|
||||
zipfile.Path directory names always end in a slash.
|
||||
"""
|
||||
return rf'{pattern}[/]?'
|
||||
|
||||
def translate_core(self, pattern):
|
||||
r"""
|
||||
Given a glob pattern, produce a regex that matches it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue