Switch to a map based approach

This commit is contained in:
Kovid Goyal 2025-04-07 08:50:15 +05:30
parent a5f4f19887
commit 5504e9fdf9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1113,10 +1113,15 @@ class ZipFile:
# Kovid: Extract longer names first, just in case the zip file has
# an entry for a directory without a trailing slash
members.sort(key=len, reverse=True)
zimembers = tuple(map(self.getinfo, members))
args = []
for name in members:
zi = self.getinfo(name)
dest = self._get_targetpath(zi, path)
args.append((zi, dest, pwd))
for zipinfo in zimembers:
self._extract_member(zipinfo, path, pwd)
def do_one(a):
return self._extract_member_to(*a)
tuple(map(do_one, args))
def _get_targetpath(self, member: ZipInfo, targetpath: str) -> str:
# build the destination pathname, replacing