diff -r 59714b9033bc -r 4a3188fc8951 obsolete/exp_anki.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/exp_anki.py Thu Sep 15 19:19:34 2016 +0300 @@ -0,0 +1,89 @@ +FONAME = "test.apkg" + +# Looks like anki libs change working directory to media directory of current deck +# Therefore absolute path should be stored before creating temporary deck +FONAME = os.path.abspath(FONAME) +FBASENAME, _ = os.path.splitext(os.path.basename(FONAME)) +TMPDIR = tempfile.mkdtemp(dir = os.path.dirname(FONAME)) + +import anki +from anki.exporting import AnkiPackageExporter + +collection = anki.Collection(os.path.join(TMPDIR, 'collection.anki2')) + +deck_id = collection.decks.id(FBASENAME + "_deck") +deck = collection.decks.get(deck_id) +# deck = collection.decks.confForDid(deck_id) +# collection.decks.update(deck) +# print(dir(deck)) +# print(type(deck)) +# print(deck) + +model = collection.models.new(FBASENAME + "_model") +model['tags'].append(FBASENAME + "_tag") +model['did'] = deck_id +model['css'] = """ +.card { + font-family: arial; + font-size: 20px; + text-align: center; + color: black; + background-color: white; +} +.from { + font-style: italic; +} +""" + +collection.models.addField(model, collection.models.newField('en')) +collection.models.addField(model, collection.models.newField('tr')) + +tmpl = collection.models.newTemplate('en -> tr') +tmpl['qfmt'] = '