Merge pull request #27 from ospalh/fix-warning-method-function
Turn method importing.ImportDialog._unicodeWarning() into a function.
This commit is contained in:
commit
69dc430504
@ -73,11 +73,6 @@ 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(
|
||||||
@ -155,7 +150,7 @@ you can enter it here. Use \\t to represent tab."""),
|
|||||||
try:
|
try:
|
||||||
self.importer.run()
|
self.importer.run()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
self._unicodeWarning()
|
showUnicodeWarning()
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
msg = _("Import failed.\n")
|
msg = _("Import failed.\n")
|
||||||
@ -245,6 +240,14 @@ you can enter it here. Use \\t to represent tab."""),
|
|||||||
def helpRequested(self):
|
def helpRequested(self):
|
||||||
openHelp("FileImport")
|
openHelp("FileImport")
|
||||||
|
|
||||||
|
|
||||||
|
def showUnicodeWarning():
|
||||||
|
"""Shorthand to show a standard warning."""
|
||||||
|
showWarning(_(
|
||||||
|
"Selected file was not in UTF-8 format. Please see the "
|
||||||
|
"importing section of the manual."))
|
||||||
|
|
||||||
|
|
||||||
def onImport(mw):
|
def onImport(mw):
|
||||||
filt = ";;".join([x[0] for x in importing.Importers])
|
filt = ";;".join([x[0] for x in importing.Importers])
|
||||||
file = getFile(mw, _("Import"), None, key="import",
|
file = getFile(mw, _("Import"), None, key="import",
|
||||||
@ -276,7 +279,7 @@ def importFile(mw, file):
|
|||||||
try:
|
try:
|
||||||
importer.open()
|
importer.open()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
self._unicodeWarning()
|
showUnicodeWarning()
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
msg = unicode(e)
|
msg = unicode(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user