def onImportCcv(self):
if not self.doDirtyCheck():
return
default_dir = './collections/'
if Mainframe.model.filename != '':
default_dir, tail = os.path.split(Mainframe.model.filename)
fileName, encoding = self.getOpenFileNameAndEncoding(
Lang.value('MI_Import_CCV'), default_dir, "(*.ccv)")
if not fileName:
return
try:
Mainframe.model = model.Model()
Mainframe.model.delete(0)
for data in fancy.readCvv(fileName, encoding):
Mainframe.model.add(model.makeSafe(data), False)
Mainframe.model.is_dirty = False
except IOError:
msgBox(Lang.value('MSG_IO_failed'))
except:
msgBox(Lang.value('MSG_CCV_import_failed'))
finally:
if len(Mainframe.model.entries) == 0:
Mainframe.model = model.Model()
self.overview.rebuild()
Mainframe.sigWrapper.sigModelChanged.emit()
评论列表
文章目录