Merge pull request #37 from hans/patch/924

Handle invalid import file argument in both launch cases (single-profile...
This commit is contained in:
Damien Elmes 2013-07-01 22:30:31 -07:00
commit 157b402495

View file

@ -227,8 +227,8 @@ Are you sure?""")):
showInfo(_("""\ showInfo(_("""\
To import into a password protected profile, please open the profile before attempting to import.""")) To import into a password protected profile, please open the profile before attempting to import."""))
else: else:
import aqt.importing self.handleImport(self.pendingImport)
aqt.importing.importFile(self, self.pendingImport)
self.pendingImport = None self.pendingImport = None
runHook("profileLoaded") runHook("profileLoaded")
@ -723,6 +723,13 @@ and check the statistics for a home deck instead."""))
# Importing & exporting # Importing & exporting
########################################################################## ##########################################################################
def handleImport(self, path):
import aqt.importing
if not os.path.exists(path):
return showInfo(_("Please use File>Import to import this file."))
aqt.importing.importFile(self, path)
def onImport(self): def onImport(self):
import aqt.importing import aqt.importing
aqt.importing.onImport(self) aqt.importing.onImport(self)
@ -1106,7 +1113,5 @@ Please ensure a profile is open and Anki is not busy, then try again."""),
# import # import
if not isinstance(buf, unicode): if not isinstance(buf, unicode):
buf = unicode(buf, "utf8", "ignore") buf = unicode(buf, "utf8", "ignore")
if not os.path.exists(buf):
return showInfo(_("Please use File>Import to import this file.")) self.handleImport(buf)
import aqt.importing
aqt.importing.importFile(self, buf)