def get_zip_fileinfo(filepath: str) -> Tuple[int, int]:
try:
my_zip = zipfile.ZipFile(filepath, 'r')
except zipfile.BadZipFile:
return -1, -1
total_size = 0
total_count = 0
for info in my_zip.infolist():
if not info.filename.lower().endswith(
('.jpeg', '.jpg', '.png', '.gif')
):
continue
if '__macosx' in info.filename.lower():
continue
total_size += int(info.file_size)
total_count += 1
my_zip.close()
return total_size, total_count
评论列表
文章目录