--- a/py/gadict_srs_anki.py Sat Oct 15 02:38:10 2016 +0300
+++ b/py/gadict_srs_anki.py Sat Oct 15 11:09:33 2016 +0300
@@ -52,6 +52,12 @@
FBASENAME, _ = os.path.splitext(os.path.basename(FONAME))
TMPDIR = tempfile.mkdtemp(dir = os.path.dirname(FONAME))
+try:
+ FDEL = io.open(FBASENAME+".del", mode='r', buffering=1, encoding="utf-8")
+except:
+ FDEL = None
+
+
import hashlib
import anki
@@ -119,6 +125,10 @@
span.glos {
font-size: .95em;
}
+.del {
+ color: red;
+ font-weight: bold;
+}
"""
collection.models.addField(model, collection.models.newField('From'))
@@ -145,12 +155,16 @@
h = hashlib.md5(":".join((self.name, type_, headword)))
return h.hexdigest()
- def add_note(self, type_, id_, from_, to_):
+ def add_note(self, type_, id_, from_, to_, tags_ = None):
note = self.collection.newNote()
note['From'] = from_
# print(from_)
note['To'] = to_
# print(to_)
+ if isinstance(tags_, str): note.tags = [tags_]
+ elif isinstance(tags_, list): note.tags = tags_
+ elif tags_ is None: pass
+ else: raise Exception('Expect string or list of tags...')
note.guid = self.guid(type_, id_)
self.collection.addNote(note)
@@ -216,6 +230,17 @@
try:
builder = AnkiDbBuilder(TMPDIR, FBASENAME)
+ for identity in FDEL or []:
+ identity = identity.strip()
+ warnmsg = "<div class='del'>Please delete this note ({})</div>".format(identity)
+ builder.add_note("en->tr", identity, warnmsg, warnmsg+" en->tr", "del")
+ builder.add_note("tr->en", identity, warnmsg, warnmsg+" tr->en", "del")
+ builder.add_note("irregular1", identity, warnmsg, warnmsg+" irregular1", "del")
+ builder.add_note("irregular2", identity, warnmsg, warnmsg+" irregular2", "del")
+ builder.add_note("irregular3", identity, warnmsg, warnmsg+" irregular3", "del")
+ builder.add_note("singular", identity, warnmsg, warnmsg+" singular", "del")
+ builder.add_note("plural", identity, warnmsg, warnmsg+" plural", "del")
+
for (headwords, translations) in DOM[1:]:
identity = headwords[0].headword
buf = []
@@ -275,7 +300,6 @@
builder.add_note("singular", identity, question + riddle_s, answer)
builder.add_note("plural", identity, question + riddle_pl, answer)
-
builder.export(FONAME)
finally:
builder.close()