required audio support #1351

pull/6/head
matic_t 4 years ago
parent 1770932a14
commit efe4d07464

@ -26,6 +26,8 @@ def export_entry(entry):
headword_lemma.textContent = entry.headword headword_lemma.textContent = entry.headword
if entry.headword_type is not None: if entry.headword_type is not None:
headword_lemma.setAttribute("type", entry.headword_type) headword_lemma.setAttribute("type", entry.headword_type)
if entry.headword_audio is not None:
headword_lemma.setAttribute("audio", entry.headword_audio)
headword.appendChild(headword_lemma) headword.appendChild(headword_lemma)
head.appendChild(headword) head.appendChild(headword)
@ -146,6 +148,9 @@ def export_translation(doc, translation):
actual_t.textContent = translation.translation actual_t.textContent = translation.translation
actual_t.setAttribute("targetLang", translation.targetLang) actual_t.setAttribute("targetLang", translation.targetLang)
if translation.audio:
actual_t.setAttribute("audio", translation.audio)
if translation.source: if translation.source:
actual_t.setAttribute("source", translation.source) actual_t.setAttribute("source", translation.source)
translation_xml.appendChild(actual_t) translation_xml.appendChild(actual_t)

@ -14,6 +14,7 @@ class Entry(Data):
self.headword = "" self.headword = ""
self.homonymy = [] self.homonymy = []
self.headword_type = None self.headword_type = None
self.headword_audio = None
self.grammar = "" self.grammar = ""
self.comment = "" self.comment = ""
self.variants = [] self.variants = []
@ -31,7 +32,8 @@ class Entry(Data):
comment = entry_xml.querySelector("head comment") comment = entry_xml.querySelector("head comment")
self.status = status.textContent if status else "" self.status = status.textContent if status else ""
self.headword = headword.textContent if headword else "" self.headword = headword.textContent if headword else ""
self.headword_type = headword.getAttribute("type") if headword else None self.headword_type = headword.getAttribute("type") if .hasAttribute("type") else None
self.headword_audio = headword.getAttribute("audio") if headword.hasAttribute("audio") else None
self.grammar = grammar.textContent if grammar else "" self.grammar = grammar.textContent if grammar else ""
self.comment = comment.textContent if comment else "" self.comment = comment.textContent if comment else ""
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")] self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]

@ -33,6 +33,7 @@ class Translation(Data):
self.translation = "" self.translation = ""
self.source = "" self.source = ""
self.targetLang = "" self.targetLang = ""
self.audio = ""
self.explanation = "" self.explanation = ""
self.explanationList = [] self.explanationList = []
self.tags = [] self.tags = []
@ -44,6 +45,7 @@ class Translation(Data):
self.translation = translation.textContent self.translation = translation.textContent
self.source = translation.getAttribute("source") if translation.hasAttribute("source") else "" self.source = translation.getAttribute("source") if translation.hasAttribute("source") else ""
self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else "" self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else ""
self.audio = translation.getAttribute("audio") if translation.hasAttribute("audio") else ""
explanationList = translation_xml.querySelectorAll("explanationList explanation") explanationList = translation_xml.querySelectorAll("explanationList explanation")

Loading…
Cancel
Save