|
|
|
@ -17,6 +17,12 @@ class Example(Data):
|
|
|
|
|
self.components = []
|
|
|
|
|
self.edited = False
|
|
|
|
|
|
|
|
|
|
# removes space from last component if multiword example
|
|
|
|
|
def check_multiword_components(self):
|
|
|
|
|
if self.is_multiword():
|
|
|
|
|
self.components[len(self.components) - 1].no_space = ComponentLexeme.LAST_COMPONENT_SPACE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def import_xml(self, example_xml):
|
|
|
|
|
self.translations = from_container_list(example_xml.querySelectorAll("translationContainer"))
|
|
|
|
|
|
|
|
|
@ -38,14 +44,17 @@ class Example(Data):
|
|
|
|
|
if comp.isValid():
|
|
|
|
|
self.components.append(comp)
|
|
|
|
|
|
|
|
|
|
self.check_multiword_components()
|
|
|
|
|
|
|
|
|
|
def export(self, doc):
|
|
|
|
|
self.check_multiword_components()
|
|
|
|
|
|
|
|
|
|
result = doc.createElement("exampleContainer")
|
|
|
|
|
|
|
|
|
|
inner = self.inner.export(doc, self.edited)
|
|
|
|
|
# TODO: bad quick fix
|
|
|
|
|
for idx, comp in enumerate(self.components):
|
|
|
|
|
inner.appendChild(comp.export(
|
|
|
|
|
doc, self.is_multiword(), idx == len(self.components) - 1))
|
|
|
|
|
for comp in self.components:
|
|
|
|
|
inner.appendChild(comp.export(doc))
|
|
|
|
|
|
|
|
|
|
result.appendChild(inner)
|
|
|
|
|
return result
|
|
|
|
|