You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lexonomy_custom_editor/src/model/entry.py

32 lines
1.3 KiB

5 years ago
from model.sense import Sense
from model.editable import Editable
from model.tags import TAGS
5 years ago
class Entry(Editable):
5 years ago
def __init__(self, entry_xml):
status = entry_xml.querySelector("head status")
headword = entry_xml.querySelector("head headword lemma")
grammar = entry_xml.querySelector("head grammar category")
comment = entry_xml.querySelector("head comment")
self.status = status.textContent if status else ""
self.headword = headword.textContent if headword else ""
self.grammar = grammar.textContent if grammar else ""
self.comment = comment.textContent if comment else ""
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]
self.labels = []
for tag_xml in entry_xml.querySelectorAll("head labelList label"):
t_type = tag_xml.getAttribute("type")
t_value = tag_xml.textContent
if t_type not in TAGS:
# using some default
t_type = TAGS.keys()[0]
self.labels.append((t_type, t_value))
5 years ago
self.senses = [Sense(sense_xml) for sense_xml in
entry_xml.querySelectorAll("body senseList sense")]
5 years ago