mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
catch .anki(2) imports
This commit is contained in:
parent
f3a6472c5c
commit
8489f84937
1 changed files with 13 additions and 8 deletions
|
@ -12,8 +12,8 @@ import shutil
|
|||
|
||||
from aqt.qt import *
|
||||
import anki.importing as importing
|
||||
from aqt.utils import getOnlyText, getFile, showText, showWarning, openHelp,\
|
||||
askUser, tooltip
|
||||
from aqt.utils import getOnlyText, getFile, showText, showWarning, openHelp, \
|
||||
askUser, tooltip, showInfo
|
||||
from anki.hooks import addHook, remHook
|
||||
import aqt.forms
|
||||
import aqt.modelchooser
|
||||
|
@ -274,6 +274,16 @@ def onImport(mw):
|
|||
if not file:
|
||||
return
|
||||
file = str(file)
|
||||
|
||||
head, ext = os.path.splitext(file)
|
||||
ext = ext.lower()
|
||||
if ext == ".anki":
|
||||
showInfo(_(".anki files are from a very old version of Anki. You can import them with Anki 2.0, available on the Anki website."))
|
||||
return
|
||||
elif ext == ".anki2":
|
||||
showInfo(_(".anki2 files are not directly importable - please import the .apkg or .zip file you have received instead."))
|
||||
return
|
||||
|
||||
importFile(mw, file)
|
||||
|
||||
def importFile(mw, file):
|
||||
|
@ -303,11 +313,6 @@ def importFile(mw, file):
|
|||
except Exception as e:
|
||||
msg = repr(str(e))
|
||||
if msg == "'unknownFormat'":
|
||||
if file.endswith(".anki2"):
|
||||
showWarning(_("""\
|
||||
.anki2 files are not designed for importing. If you're trying to restore from a \
|
||||
backup, please see the 'Backups' section of the user manual."""))
|
||||
else:
|
||||
showWarning(_("Unknown file format."))
|
||||
else:
|
||||
msg = _("Import failed. Debugging info:\n")
|
||||
|
|
Loading…
Reference in a new issue