From a0758f5c11d9086666af8ca0a300b2ba6ef4e062 Mon Sep 17 00:00:00 2001 From: matic_t Date: Mon, 12 Oct 2020 01:27:36 -0700 Subject: [PATCH] sense id support --- src/export.py | 3 +++ src/model/sense.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/export.py b/src/export.py index c691b4b..94792f2 100644 --- a/src/export.py +++ b/src/export.py @@ -114,6 +114,9 @@ def export_sense(doc, sense): sense_xml = doc.createElement("sense") sense_xml.appendChild(_export_label_list(doc, sense.labels)) + if sense.id is not None: + sense_xml.setAttribute("id", sense.id) + definition_list = doc.createElement("definitionList") sense_xml.appendChild(definition_list) diff --git a/src/model/sense.py b/src/model/sense.py index e1580a9..4e9e6cc 100644 --- a/src/model/sense.py +++ b/src/model/sense.py @@ -11,6 +11,7 @@ from view.utils import clean_label class Sense(Data): def __init__(self): self.original_idx = -1 + self.id = None self.definition = {} self.labels = [] self.translations = [] @@ -18,6 +19,7 @@ class Sense(Data): def import_xml(self, sense_xml, idx): self.original_idx = idx + self.id = sense_xml.getAttribute("id") if sense_xml.hasAttribute("id") else None for definition in sense_xml.querySelectorAll("definitionList definition"): key = definition.getAttribute("type")