def __installDocset(self, docset, refresh):
extract_location = self.docsetFolder
docset.stats = 'Preparing to install: This might take a while.'
refresh()
zip = ZipFile(docset.zipPath, mode='r')
ll = [name for name in zip.namelist() if '.docset' in name]
if len(ll) > 0:
n = ll[0]
m = os.path.join(self.docsetFolder, n)
docset.stats = 'Preparing to extract'
refresh()
l = zip.infolist()
zip.extractall(path=extract_location, members = self.track_progress(l, docset, len(l), refresh))
zip.close()
os.remove(docset.zipPath)
plistpath = os.path.join(m, self.plistPath)
name = docset.name
image = ''
with open(plistpath, 'rb') as f:
pp = plistlib.load(f)
if 'CFBundleName' in pp.keys():
name = pp['CFBundleName']
if 'CFBundleIdentifier' in pp.keys():
image = pp['CFBundleIdentifier']
dbManager = DBManager.DBManager()
dbManager.DocsetInstalled(name, m, 'transfer', image, 0.0)
if docset in self.__installingDocsets:
self.__installingDocsets.remove(docset)
docset.status = 'Cleaning up...'
refresh()
cleanup_path = os.path.join(self.docsetFolder,'__MACOSX')
if os.path.exists(cleanup_path):
shutil.rmtree(cleanup_path)
docset.status = 'Installed'
refresh()
else:
raise Exception('Unknown docset structure')
评论列表
文章目录