def test_suspended(): # create a new empty deck dst = getEmptyDeck() # import the 1 card version of the model tmp = getUpgradeDeckPath("suspended12.anki") imp = Anki1Importer(dst, tmp) imp.run() assert dst.db.scalar("select due from cards") < 0
def _upgrade(self, path): if not os.path.exists(path): return [_("File was missing.")] imp = Anki1Importer(self.col, path) # try to copy over dropbox media first try: self.maybeCopyFromCustomFolder(path) except Exception, e: imp.log.append(unicode(e))
def test_anki1(): # get the deck path to import tmp = getUpgradeDeckPath() # make sure media is imported properly through the upgrade mdir = tmp.replace(".anki2", ".media") if not os.path.exists(mdir): os.mkdir(mdir) open(os.path.join(mdir, "_foo.jpg"), "w").write("foo") # create a new empty deck dst = getEmptyDeck() # import src into dst imp = Anki1Importer(dst, tmp) imp.run() def check(): assert dst.noteCount() == srcNotes assert dst.cardCount() == srcCards assert len(os.listdir(dst.media.dir())) == 1 check() # importing should be idempotent imp = Anki1Importer(dst, tmp) imp.run() check()
def _upgrade(self, path): if not os.path.exists(path): return [_("File was missing.")] imp = Anki1Importer(self.col, path) # try to copy over dropbox media first try: self.maybeCopyFromCustomFolder(path) except Exception as e: imp.log.append(repr(str(e))) # then run the import try: imp.run() except Exception as e: if repr(str(e)) == "invalidFile": # already logged pass else: imp.log.append(repr(str(e))) self.col.save() return imp.log