xbmcbackup/resources/lib/extractor.py

31 lines
849 B
Python
Raw Normal View History

2019-08-27 21:55:22 +02:00
from . import utils as utils
class ZipExtractor:
2019-11-25 22:19:57 +01:00
def extract(self, zipFile, outLoc, progressBar):
utils.log("extracting zip archive")
2019-11-25 22:19:57 +01:00
result = True # result is true unless we fail
# 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
fileCount = float(len(zipFile.listFiles()))
currentFile = 0
2019-11-25 22:19:57 +01:00
try:
for aFile in zipFile.listFiles():
2019-11-25 22:19:57 +01:00
# update the progress bar
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")
result = False
2019-11-25 22:19:57 +01:00
return result