From bd8707f54cefb81d664116de42851e3de4e9436a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 11 Sep 2013 15:56:59 +0900 Subject: [PATCH] support import of renamed .apkg files --- anki/importing/__init__.py | 2 +- aqt/importing.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/anki/importing/__init__.py b/anki/importing/__init__.py index 4ac509448..a640f8b89 100644 --- a/anki/importing/__init__.py +++ b/anki/importing/__init__.py @@ -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), diff --git a/aqt/importing.py b/aqt/importing.py index a87890d9b..f30b55136 100644 --- a/aqt/importing.py +++ b/aqt/importing.py @@ -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)