support import of renamed .apkg files

This commit is contained in:
Damien Elmes 2013-09-11 15:56:59 +09:00
parent aa2b31a82b
commit bd8707f54c
2 changed files with 9 additions and 2 deletions

View file

@ -13,7 +13,7 @@ from anki.lang import _
Importers = (
(_("Text separated by tabs or semicolons (*)"), TextImporter),
(_("Packaged Anki Deck (*.apkg)"), AnkiPackageImporter),
(_("Packaged Anki Deck (*.apkg *.zip)"), AnkiPackageImporter),
(_("Anki 1.2 Deck (*.anki)"), Anki1Importer),
(_("Mnemosyne 2.0 Deck (*.db)"), MnemosyneImporter),
(_("Supermemo XML export (*.xml)"), SupermemoXmlImporter),

View file

@ -300,8 +300,15 @@ backup, please see the 'Backups' section of the user manual."""))
mw.progress.finish()
diag = ImportDialog(mw, importer)
else:
# if it's an apkg, we need to ask whether to import/replace
# if it's an apkg/zip, first test it's a valid file
if importer.__class__.__name__ == "AnkiPackageImporter":
z = zipfile.ZipFile(importer.file)
try:
z.getinfo("collection.anki2")
except:
showWarning(_("The provided file is not a valid .apkg file."))
return
# we need to ask whether to import/replace
if not setupApkgImport(mw, importer):
return
mw.progress.start(immediate=True)