Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _to_xml(self):
root = ElementTree.Element("Dbf")
if self.name is not None:
root.attrib["name"] = self.name
if self.source_fingerprint is not None:
e = ElementTree.Element("SourceFingerprint")
root.append(e)
e.text = self.source_fingerprint
for column, type in self.columns.items():
e = ElementTree.Element("Column")
root.append(e)
e.attrib["name"] = column
e.attrib["type"] = type
for record in self.records:
e = ElementTree.Element("Record")
root.append(e)
for column, type in self.columns.items():
field = ElementTree.Element("Field")
e.append(field)
field.attrib["column"] = column
value = record[column]
if value is None:
continue
if type == "LocString":
def _to_xml(self):
root = ElementTree.Element("Dbf")
if self.name is not None:
root.attrib["name"] = self.name
if self.source_fingerprint is not None:
e = ElementTree.Element("SourceFingerprint")
root.append(e)
e.text = self.source_fingerprint
for column, type in self.columns.items():
e = ElementTree.Element("Column")
root.append(e)
e.attrib["name"] = column
e.attrib["type"] = type
for record in self.records:
e = ElementTree.Element("Record")
root.append(e)
for column, type in self.columns.items():
field = ElementTree.Element("Field")
e.append(field)
field.attrib["column"] = column
if self.name is not None:
root.attrib["name"] = self.name
if self.source_fingerprint is not None:
e = ElementTree.Element("SourceFingerprint")
root.append(e)
e.text = self.source_fingerprint
for column, type in self.columns.items():
e = ElementTree.Element("Column")
root.append(e)
e.attrib["name"] = column
e.attrib["type"] = type
for record in self.records:
e = ElementTree.Element("Record")
root.append(e)
for column, type in self.columns.items():
field = ElementTree.Element("Field")
e.append(field)
field.attrib["column"] = column
value = record[column]
if value is None:
continue
if type == "LocString":
locales = sorted(value.keys())
# Always have enUS as first item
if "enUS" in locales:
locales.insert(0, locales.pop(locales.index("enUS")))
for locale in locales:
eloc = ElementTree.Element(locale)
root.append(e)
for column, type in self.columns.items():
field = ElementTree.Element("Field")
e.append(field)
field.attrib["column"] = column
value = record[column]
if value is None:
continue
if type == "LocString":
locales = sorted(value.keys())
# Always have enUS as first item
if "enUS" in locales:
locales.insert(0, locales.pop(locales.index("enUS")))
for locale in locales:
eloc = ElementTree.Element(locale)
field.append(eloc)
eloc.text = value[locale]
else:
field.text = str(record[column])
return root
def _to_xml(self):
root = ElementTree.Element("Dbf")
if self.name is not None:
root.attrib["name"] = self.name
if self.source_fingerprint is not None:
e = ElementTree.Element("SourceFingerprint")
root.append(e)
e.text = self.source_fingerprint
for column, type in self.columns.items():
e = ElementTree.Element("Column")
root.append(e)
e.attrib["name"] = column
e.attrib["type"] = type
for record in self.records:
if self.source_fingerprint is not None:
e = ElementTree.Element("SourceFingerprint")
root.append(e)
e.text = self.source_fingerprint
for column, type in self.columns.items():
e = ElementTree.Element("Column")
root.append(e)
e.attrib["name"] = column
e.attrib["type"] = type
for record in self.records:
e = ElementTree.Element("Record")
root.append(e)
for column, type in self.columns.items():
field = ElementTree.Element("Field")
e.append(field)
field.attrib["column"] = column
value = record[column]
if value is None:
continue
if type == "LocString":
locales = sorted(value.keys())
# Always have enUS as first item
if "enUS" in locales:
locales.insert(0, locales.pop(locales.index("enUS")))
for locale in locales:
eloc = ElementTree.Element(locale)
field.append(eloc)
eloc.text = value[locale]
else:
def to_xml(self):
ret = ElementTree.Element("Entity", CardID=self.id, ID=str(self.dbf_id))
if self.version:
ret.attrib["version"] = str(self.version)
if self.master_power:
master_power = ElementTree.SubElement(ret, "MasterPower")
master_power.text = self.master_power
for tag in LOCALIZED_TAGS:
value = self.strings[tag]
if value:
e = ElementTree.SubElement(ret, "Tag", enumID=str(int(tag)), name=tag.name)
e.attrib["type"] = "LocString"
for locale, localized_value in sorted(value.items()):
if localized_value:
loc_element = ElementTree.SubElement(e, locale)
loc_element.text = str(localized_value)