# HG changeset patch # User Oleksandr Gavenko # Date 1476518973 -10800 # Node ID 01fcbb1d5cea5f11e9c80845cb7ce3b33c453c78 # Parent a8ee8f8d38f321df4b142ddfc4be57399545706f Add a way to mark card for deletion. diff -r a8ee8f8d38f3 -r 01fcbb1d5cea Makefile --- a/Makefile Sat Oct 15 02:38:10 2016 +0300 +++ b/Makefile Sat Oct 15 11:09:33 2016 +0300 @@ -410,6 +410,9 @@ .PHONY: anki anki: $(SRS_ANKI_FILES) +dist/srs/%.apkg: %.gadict %.del py/gadict.py py/gadict_srs_anki.py $(MAKEFILE_LIST) | dist/srs/ + PYTHONPATH=/usr/share/anki: python -B py/gadict_srs_anki.py $< $@ + dist/srs/%.apkg: %.gadict py/gadict.py py/gadict_srs_anki.py $(MAKEFILE_LIST) | dist/srs/ PYTHONPATH=/usr/share/anki: python -B py/gadict_srs_anki.py $< $@ diff -r a8ee8f8d38f3 -r 01fcbb1d5cea obsolete/gadict_en-ru+uk.del --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/gadict_en-ru+uk.del Sat Oct 15 11:09:33 2016 +0300 @@ -0,0 +1,8 @@ +shrive +begird +chide +grave +stave +throughly +bespit +crow diff -r a8ee8f8d38f3 -r 01fcbb1d5cea py/gadict_srs_anki.py --- 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 = "
Please delete this note ({})
".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()