-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* gh-106752: Sync with zipp 3.16.2 * Add blurb
- Loading branch information
Showing
6 changed files
with
204 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from . import test_path | ||
|
||
|
||
__name__ == '__main__' and test_path.build_alpharep_fixture().extractall('alpharep') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import re | ||
|
||
|
||
def translate(pattern): | ||
r""" | ||
Given a glob pattern, produce a regex that matches it. | ||
>>> translate('*.txt') | ||
'[^/]*\\.txt' | ||
>>> translate('a?txt') | ||
'a.txt' | ||
>>> translate('**/*') | ||
'.*/[^/]*' | ||
""" | ||
return ''.join(map(replace, separate(pattern))) | ||
|
||
|
||
def separate(pattern): | ||
""" | ||
Separate out character sets to avoid translating their contents. | ||
>>> [m.group(0) for m in separate('*.txt')] | ||
['*.txt'] | ||
>>> [m.group(0) for m in separate('a[?]txt')] | ||
['a', '[?]', 'txt'] | ||
""" | ||
return re.finditer(r'([^\[]+)|(?P<set>[\[].*?[\]])|([\[][^\]]*$)', pattern) | ||
|
||
|
||
def replace(match): | ||
""" | ||
Perform the replacements for a match from :func:`separate`. | ||
""" | ||
|
||
return match.group('set') or ( | ||
re.escape(match.group(0)) | ||
.replace('\\*\\*', r'.*') | ||
.replace('\\*', r'[^/]*') | ||
.replace('\\?', r'.') | ||
) |
5 changes: 5 additions & 0 deletions
5
Misc/NEWS.d/next/Library/2023-07-14-16-54-13.gh-issue-106752.BT1Yxw.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Fixed several bugs in zipfile.Path, including: in ``Path.match`, Windows | ||
separators are no longer honored (and never were meant to be); Fixed | ||
``name``/``suffix``/``suffixes``/``stem`` operations when no filename is | ||
present and the Path is not at the root of the zipfile; Reworked glob for | ||
performance and more correct matching behavior. |