WIP: changing xml of tags, now correct, also reading them
This commit is contained in:
parent
0fd32205cc
commit
272fdee3bc
|
@ -35,9 +35,9 @@ var entry = {"content": `<entry>
|
||||||
<translationContainer cluster="1">
|
<translationContainer cluster="1">
|
||||||
<translation>preizkus</translation>
|
<translation>preizkus</translation>
|
||||||
<explanation>explainme!</explanation>
|
<explanation>explainme!</explanation>
|
||||||
<tagsContainer>
|
<labelList>
|
||||||
<tag><type>podrocje</type><value>biologija</value></tag>
|
<label type="podrocje">biologija</label>
|
||||||
</tagsContainer>
|
</labelList>
|
||||||
</translationContainer>
|
</translationContainer>
|
||||||
<translationContainer cluster="1">
|
<translationContainer cluster="1">
|
||||||
<translation></translation>
|
<translation></translation>
|
||||||
|
@ -48,9 +48,9 @@ var entry = {"content": `<entry>
|
||||||
</translationContainer>
|
</translationContainer>
|
||||||
<translationContainer cluster="2">
|
<translationContainer cluster="2">
|
||||||
<translation>sdfsd</translation>
|
<translation>sdfsd</translation>
|
||||||
<tagsContainer>
|
<labelList>
|
||||||
<tag><type>podrocje</type><value>ozboltologija</value></tag>
|
<label type="podrocje">ozboltologija</label>
|
||||||
</tagsContainer>
|
</labelList>
|
||||||
</translationContainer>
|
</translationContainer>
|
||||||
<translationContainer cluster="3">
|
<translationContainer cluster="3">
|
||||||
<translation>fsd</translation>
|
<translation>fsd</translation>
|
||||||
|
|
|
@ -13,16 +13,19 @@ class Translation(Editable):
|
||||||
def __init__(self, translation_xml):
|
def __init__(self, translation_xml):
|
||||||
translation = translation_xml.querySelector("translation")
|
translation = translation_xml.querySelector("translation")
|
||||||
self.translation = translation.textContent if translation else ""
|
self.translation = translation.textContent if translation else ""
|
||||||
self.source = translation.getAttribute("source") or ""
|
self.source = translation.getAttribute("source") if translation else ""
|
||||||
|
|
||||||
explanation = translation_xml.querySelector("explanation")
|
explanation = translation_xml.querySelector("explanation")
|
||||||
self.explanation = explanation.textContent if explanation else ""
|
self.explanation = explanation.textContent if explanation else ""
|
||||||
|
|
||||||
self.tags = {}
|
self.tags = []
|
||||||
for tag_xml in translation_xml.querySelectorAll("tagsContainer tag"):
|
for tag_xml in translation_xml.querySelectorAll("labelList label"):
|
||||||
t_type = tag_xml.querySelector("type").textContent
|
t_type = tag_xml.getAttribute("type")
|
||||||
t_value = tag_xml.querySelector("value").textContent
|
t_value = tag_xml.textContent
|
||||||
self.tags[t_type] = t_value
|
|
||||||
|
|
||||||
|
if t_type not in TAGS:
|
||||||
|
console.log("Bad tag: ({})->({})".format(t_type, t_value))
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.tags.append((t_type, t_value))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user