How to use the hearthstone.utils.ElementTree.Element function in hearthstone

To help you get started, we’ve selected a few hearthstone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HearthSim / python-hearthstone / hearthstone / dbf.py View on Github external
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":
github HearthSim / python-hearthstone / hearthstone / dbf.py View on Github external
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
github HearthSim / python-hearthstone / hearthstone / dbf.py View on Github external
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)
github HearthSim / python-hearthstone / hearthstone / dbf.py View on Github external
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
github HearthSim / python-hearthstone / hearthstone / dbf.py View on Github external
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:
github HearthSim / python-hearthstone / hearthstone / dbf.py View on Github external
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:
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
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)