2019-08-27 21:55:22 +02:00
|
|
|
from . import utils as utils
|
2015-06-26 22:32:22 +02:00
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
|
2015-06-26 22:32:22 +02:00
|
|
|
class ZipExtractor:
|
2019-11-25 22:19:57 +01:00
|
|
|
|
|
|
|
def extract(self, zipFile, outLoc, progressBar):
|
2015-06-26 22:32:22 +02:00
|
|
|
utils.log("extracting zip archive")
|
2019-11-25 22:19:57 +01:00
|
|
|
|
2019-11-25 22:56:59 +01:00
|
|
|
result = True # result is true unless we fail
|
2019-11-25 22:19:57 +01:00
|
|
|
|
|
|
|
# update the progress bar
|
2019-11-25 22:45:41 +01:00
|
|
|
progressBar.updateProgress(0, utils.getString(30100))
|
2019-11-25 22:19:57 +01:00
|
|
|
|
|
|
|
# list the files
|
2015-06-26 22:32:22 +02:00
|
|
|
fileCount = float(len(zipFile.listFiles()))
|
|
|
|
currentFile = 0
|
2019-11-25 22:19:57 +01:00
|
|
|
|
2015-06-26 22:32:22 +02:00
|
|
|
try:
|
|
|
|
for aFile in zipFile.listFiles():
|
2019-11-25 22:19:57 +01:00
|
|
|
# update the progress bar
|
2015-06-26 22:32:22 +02:00
|
|
|
currentFile += 1
|
2019-11-25 22:19:57 +01:00
|
|
|
progressBar.updateProgress(int((currentFile / fileCount) * 100), utils.getString(30100))
|
|
|
|
|
|
|
|
# extract the file
|
|
|
|
zipFile.extract(aFile, outLoc)
|
|
|
|
|
|
|
|
except Exception:
|
2017-01-31 16:15:48 +01:00
|
|
|
utils.log("Error extracting file")
|
2015-06-26 22:32:22 +02:00
|
|
|
result = False
|
2019-11-25 22:19:57 +01:00
|
|
|
|
2015-06-26 22:32:22 +02:00
|
|
|
return result
|