mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
catch more unicode errors on import, and improve error msg
This commit is contained in:
parent
e610776bb0
commit
3048a8e137
1 changed files with 9 additions and 1 deletions
|
@ -73,6 +73,11 @@ class ImportDialog(QDialog):
|
||||||
self.frm.importMode.setCurrentIndex(self.mw.pm.profile.get('importMode', 0))
|
self.frm.importMode.setCurrentIndex(self.mw.pm.profile.get('importMode', 0))
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
|
def _unicodeWarning(self):
|
||||||
|
showWarning(_(
|
||||||
|
"Selected file was not in UTF-8 format. Please see the "
|
||||||
|
" importing section of the manual."))
|
||||||
|
|
||||||
def setupOptions(self):
|
def setupOptions(self):
|
||||||
self.model = self.mw.col.models.current()
|
self.model = self.mw.col.models.current()
|
||||||
self.modelChooser = aqt.modelchooser.ModelChooser(
|
self.modelChooser = aqt.modelchooser.ModelChooser(
|
||||||
|
@ -149,6 +154,9 @@ you can enter it here. Use \\t to represent tab."""),
|
||||||
self.mw.checkpoint(_("Import"))
|
self.mw.checkpoint(_("Import"))
|
||||||
try:
|
try:
|
||||||
self.importer.run()
|
self.importer.run()
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
self._unicodeWarning()
|
||||||
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
msg = _("Import failed.\n")
|
msg = _("Import failed.\n")
|
||||||
err = unicode(e)
|
err = unicode(e)
|
||||||
|
@ -269,7 +277,7 @@ def importFile(mw, file):
|
||||||
try:
|
try:
|
||||||
importer.open()
|
importer.open()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
showWarning(_("Selected file was not in UTF-8 format."))
|
self._unicodeWarning()
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
msg = unicode(e)
|
msg = unicode(e)
|
||||||
|
|
Loading…
Reference in a new issue