mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +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
|
@ -250,7 +250,10 @@ def _extract_text_encoding(encoding=None, *args, **kwargs):
|
|||
|
||||
class Path:
|
||||
"""
|
||||
A pathlib-compatible interface for zip files.
|
||||
A :class:`importlib.resources.abc.Traversable` interface for zip files.
|
||||
|
||||
Implements many of the features users enjoy from
|
||||
:class:`pathlib.Path`.
|
||||
|
||||
Consider a zip file with this structure::
|
||||
|
||||
|
@ -466,8 +469,7 @@ class Path:
|
|||
prefix = re.escape(self.at)
|
||||
tr = Translator(seps='/')
|
||||
matches = re.compile(prefix + tr.translate(pattern)).fullmatch
|
||||
names = (data.filename for data in self.root.filelist)
|
||||
return map(self._next, filter(matches, names))
|
||||
return map(self._next, filter(matches, self.root.namelist()))
|
||||
|
||||
def rglob(self, pattern):
|
||||
return self.glob(f'**/{pattern}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue