Add importPackage action

This commit is contained in:
Scott Noyes 2020-05-01 11:19:47 -05:00
parent e01544a538
commit 32bf6559ed

View File

@ -34,6 +34,7 @@ import anki.lang
import anki.storage import anki.storage
import aqt import aqt
from anki.exporting import AnkiPackageExporter from anki.exporting import AnkiPackageExporter
from anki.importing import AnkiPackageImporter
from . import web, util from . import web, util
@ -1215,6 +1216,22 @@ class AnkiConnect:
return True return True
return False return False
@util.api()
def importPackage(self, path):
collection = self.collection()
if collection is not None:
try:
self.startEditing()
importer = AnkiPackageImporter(collection, path)
importer.run()
except:
self.stopEditing()
raise
else:
self.stopEditing()
return True
return False
# #
# Entry # Entry