xbmcbackup/resources/lib/extractor.py

32 lines
851 B
Python
Raw Normal View History

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