Adding import/export for entry.measure and entry.lexical_unit

This commit is contained in:
2019-12-27 18:57:22 +01:00
parent 413f3febae
commit 227c3ee4b8
2 changed files with 39 additions and 0 deletions

View File

@@ -27,12 +27,34 @@ def export_entry(entry):
headword.appendChild(headword_lemma)
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_category = doc.createElement("category")
grammar_category.textContent = entry.grammar
grammar.appendChild(grammar_category)
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")
head.appendChild(variants)