def _unzip(files, destination):
size = len(files)
destination.mkdir(exist_ok=True)
LOGGER.debug("Unzip %d files into %s", size, destination)
for pos, zipped_file in enumerate(files, 1):
if pos % STEP == 0 or pos == size:
LOGGER.debug("%.2f%%", 100 * pos / size)
zipped_repo, filename = zipped_file.split('::')
ext = Path(filename).suffix
dest_path = destination.joinpath(str(uuid4()) + ext)
try:
with ZipFile(zipped_repo) as zip_file:
with dest_path.open('wb') as dest_file:
dest_file.write(zip_file.read(filename))
except BadZipFile as error:
LOGGER.error("Malformed file %s, error: %s", zipped_repo, error)
raise RuntimeError('Extraction failed for {}'.format(zipped_repo))
评论列表
文章目录