def OnCancel(self, event): """""" tracer.debug("WurmAddonInstallDlg - OnCancel") self.toInstall = [] WurmCommon.outMessage(_("Install list cleaned")) self.Close()
def Unpack(self, target=None): """Extract the files in the archive to the path specified in the mapping dictionary""" tracer.debug("7ZipArchive - Unpack") totalfiles = float(len(self.namelist)) # float to force non-integer division countfiles = 0 rf = SevenZip.SevenZipFile(self.filename) for n in self.namelist: # report progress countfiles += 1 if totalfiles > 1: WurmCommon.outProgressPercent(_("Unpacking RAR file"), countfiles/totalfiles) if not self.IsFileRequired(n, self.filemap): continue ext = os.path.splitext(n)[1].replace('.', '') # leaves only the extension, no leading dot if len(ext) == 0: # no extension, probably a directory, so ignore it WurmCommon.outWarning(_("Skipping probable directory %(filename)s") % {'filename': n}) continue (path, filename) = os.path.split(n) if len(filename) > 0: # must check size, since directories may appear as files in the RAR try: rf.extract(n, os.path.join(target, self.addonname)) except SevenZip.SevenZipException, details: WurmCommon.outError(_("Could not extract file %(filename)s") % {'filename': filename} + ":" + str(details)) continue WurmCommon.outMessage(_("Successfully Extracted %(filename)s to %(dirname)s") % {'filename': filename, 'dirname': os.path.join(target, self.addonname)})