INNER CODE UNIT · Python
UnzipFile
Ershany/Arcane-Engine · Setup/ArcaneUtils.py:86
def UnzipFile(filepath, deleteZipFile=True):
zipFilePath = os.path.abspath(filepath) # get full path of files
zipFileLocation = os.path.dirname(zipFilePath)
zipFileContent = dict()
zipFileContentSize = 0
with ZipFile(zipFilePath, 'r') as zipFileFolder:
for name in zipFileFolder.namelist():
zipFileContent[name] = zipFileFolder.getinfo(name).file_size
zipFileContentSize = sum(zipFileContent.values())
extractedContentSize = 0
startTime = time.time()
for zippedFileName, zippedFileSize in zipFileContent.items():
UnzippedFilePath = os.path.abspath(f"{zipFileLocation}/{zippedFileName}")
os.makedirs(os.path.dirname(UnzippedFilePath), exist_ok=True)
if os.path.isfile(UnzippedFilePath):
zipFileContentSize -= zippedFileSize
else: