diff --git a/zipp/__init__.py b/zipp/__init__.py index ddfa0a6..1263ff9 100644 --- a/zipp/__init__.py +++ b/zipp/__init__.py @@ -5,7 +5,6 @@ import contextlib import pathlib import re -import fnmatch from .py310compat import text_encoding @@ -13,6 +12,13 @@ __all__ = ['Path'] +def _translate(pattern): + """ + Given a glob pattern, produce a regex that matches it. + """ + return pattern.replace('**', r'.*').replace('*', r'[^/]*') + + def _parents(path): """ Given a path with elements separated by @@ -367,7 +373,7 @@ def glob(self, pattern): if not pattern: raise ValueError(f"Unacceptable pattern: {pattern!r}") - matches = re.compile(fnmatch.translate(pattern)).fullmatch + matches = re.compile(_translate(pattern)).fullmatch return ( child for child in self._descendants()