Fix: reverse card missed glossary.
Translation list may be None after adding glossary syntax.
--- a/py/gadict.py Wed Sep 21 22:46:28 2016 +0300
+++ b/py/gadict.py Wed Sep 21 22:57:21 2016 +0300
@@ -50,8 +50,6 @@
raise ParseException("Part of speech expected...\n")
self.pos = pos
self.tr_list = tr_list
- if not tr_list:
- self.tr_list = []
self.ex_list = ex_list
self.glos_list = glos_list
self.ant_list = ant_list
@@ -60,7 +58,10 @@
self.topic_list = topic_list
def add_tr(self, tr):
- self.tr_list.append(tr)
+ if self.tr_list:
+ self.tr_list.append(tr)
+ else:
+ self.tr_list = [tr]
def add_ex(self, ex):
if self.ex_list:
--- a/py/gadict_c5.py Wed Sep 21 22:46:28 2016 +0300
+++ b/py/gadict_c5.py Wed Sep 21 22:57:21 2016 +0300
@@ -110,7 +110,7 @@
FOUT.write("; ".join(["{"+s+"}" for s in sense.rel_list]))
if not LANGS or len(LANGS) != 1:
FOUT.write("\n")
- for (lang, tr) in sense.tr_list:
+ for (lang, tr) in sense.ex_list or []:
if LANGS and not (lang in LANGS):
continue
FOUT.write(" ")
--- a/py/gadict_srs_anki.py Wed Sep 21 22:46:28 2016 +0300
+++ b/py/gadict_srs_anki.py Wed Sep 21 22:57:21 2016 +0300
@@ -113,8 +113,11 @@
font-style: italic;
font-size: .85em;
}
+div.glos .lang {
+ color: brown;
+}
span.glos {
- font-size: .85em;
+ font-size: .95em;
}
"""
@@ -208,7 +211,7 @@
buf.append(" <span class='syn'>syn: ")
buf.append("; ".join(sense.syn_list))
buf.append("</span>")
- for (lang, tr) in sense.tr_list:
+ for (lang, tr) in sense.tr_list or []:
if len(sense.tr_list) > 1:
buf.append("<div class='sense'>")
buf.append(" <span class='lang'>")
@@ -264,7 +267,7 @@
buf.append(" <span class='rel'>rel: ")
buf.append("; ".join(sense.rel_list))
buf.append("</span>")
- for (lang, tr) in sense.tr_list:
+ for (lang, tr) in sense.tr_list or []:
if len(sense.tr_list) > 1:
buf.append("<div class='sense'>")
buf.append(" <span class='lang'>")
@@ -275,6 +278,15 @@
buf.append("</span>")
if len(sense.tr_list) > 1:
buf.append("</div>")
+ for (lang, tr) in sense.glos_list or []:
+ buf.append("<div class='glos'>")
+ buf.append(" <span class='lang'>")
+ buf.append(lang)
+ buf.append("</span>")
+ buf.append(" <span class='glos'>")
+ buf.append(tr)
+ buf.append("</span>")
+ buf.append("</div>")
reverse_from = "".join(buf) # without examples!!
builder.add_note("en->tr", identity, direct_from, direct_to)
builder.add_note("tr->en", identity, reverse_from, direct_from)