Adding import/export for entry.measure and entry.lexical_unit
This commit is contained in:
parent
413f3febae
commit
227c3ee4b8
|
@ -27,12 +27,34 @@ def export_entry(entry):
|
||||||
headword.appendChild(headword_lemma)
|
headword.appendChild(headword_lemma)
|
||||||
head.appendChild(headword)
|
head.appendChild(headword)
|
||||||
|
|
||||||
|
# if({}) works uncorrectly in transcrypt
|
||||||
|
if len(entry.lexical_unit) > 0:
|
||||||
|
lexunit = doc.createElement("lexicalUnit")
|
||||||
|
lexunit.setAttribute("id", entry.lexical_unit["id"])
|
||||||
|
lexunit.setAttribute("type", "single")
|
||||||
|
lexeme = doc.createElement("lexeme")
|
||||||
|
lexeme.setAttribute("lexical_unit_lexeme_id", entry.lexical_unit["id"])
|
||||||
|
lexeme.textContent = entry.lexical_unit["text"]
|
||||||
|
|
||||||
|
lexunit.appendChild(lexeme)
|
||||||
|
head.appendChild(lexunit)
|
||||||
|
|
||||||
grammar = doc.createElement("grammar")
|
grammar = doc.createElement("grammar")
|
||||||
grammar_category = doc.createElement("category")
|
grammar_category = doc.createElement("category")
|
||||||
grammar_category.textContent = entry.grammar
|
grammar_category.textContent = entry.grammar
|
||||||
grammar.appendChild(grammar_category)
|
grammar.appendChild(grammar_category)
|
||||||
head.appendChild(grammar)
|
head.appendChild(grammar)
|
||||||
|
|
||||||
|
if len(entry.measure) > 0:
|
||||||
|
measure_list = doc.createElement("measureList")
|
||||||
|
measure = doc.createElement("measure")
|
||||||
|
measure.setAttribute("source", entry.measure["source"])
|
||||||
|
measure.setAttribute("type", entry.measure["type"])
|
||||||
|
measure.textContent = entry.measure["text"]
|
||||||
|
|
||||||
|
measure_list.appendChild(measure)
|
||||||
|
head.appendChild(measure_list)
|
||||||
|
|
||||||
variants = doc.createElement("variantList")
|
variants = doc.createElement("variantList")
|
||||||
head.appendChild(variants)
|
head.appendChild(variants)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,19 @@ class Entry(Editable):
|
||||||
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")]
|
||||||
|
|
||||||
|
self.lexical_unit = {}
|
||||||
|
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
||||||
|
if lex_unit:
|
||||||
|
self.lexical_unit['id'] = lex_unit.getAttribute("lexical_unit_lexeme_id")
|
||||||
|
self.lexical_unit['text'] = lex_unit.textContent
|
||||||
|
|
||||||
|
self.measure = {}
|
||||||
|
measure = entry_xml.querySelector("measureList measure")
|
||||||
|
if measure:
|
||||||
|
self.measure["source"] = measure.getAttribute("source")
|
||||||
|
self.measure["type"] = measure.getAttribute("type")
|
||||||
|
self.measure["text"] = measure.textContent
|
||||||
|
|
||||||
self.labels = []
|
self.labels = []
|
||||||
for tag_xml in entry_xml.querySelectorAll("head labelList label"):
|
for tag_xml in entry_xml.querySelectorAll("head labelList label"):
|
||||||
t_type = tag_xml.getAttribute("type")
|
t_type = tag_xml.getAttribute("type")
|
||||||
|
@ -29,3 +42,7 @@ class Entry(Editable):
|
||||||
self.senses = [Sense(sense_xml) for sense_xml in
|
self.senses = [Sense(sense_xml) for sense_xml in
|
||||||
entry_xml.querySelectorAll("body senseList sense")]
|
entry_xml.querySelectorAll("body senseList sense")]
|
||||||
|
|
||||||
|
def get_measure_text(self):
|
||||||
|
console.log(self.measure["text"] if "text" in self.measure else "")
|
||||||
|
return self.measure["text"] if "text" in self.measure else ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user