def _get_media_from_models(self): anki_exporter = AnkiExporter(self.collection) model_ids = [ model.anki_dict["id"] for model in self.metadata.models.values() ] return anki_exporter.get_files_for_models(model_ids, self.collection.media.dir())
def _copyToTmpDeck(self, name="cram.anki", tags="", ids=[]): # fixme: use namedtmp ndir = tempfile.mkdtemp(prefix="anki") path = os.path.join(ndir, name) from anki.exporting import AnkiExporter e = AnkiExporter(self.deck) e.includeMedia = False if tags: e.limitTags = parseTags(tags) if ids: e.limitCardIds = ids path = unicode(path, sys.getfilesystemencoding()) e.exportInto(path) return (e, path)
def __post_init__(self): self.anki_exporter = AnkiExporter(self.anki_collection) self.models = seq(self.model_ids) \ .map(self.anki_collection.models.get) \ .filter(lambda m: m is not None).to_list()