def GenerateCode(comp, save_location): """\ Writes a component out to an XML file """ #make base tag and supply attributes as necessary root = ElementTree.Element( Component.GetName().lower(), { "name": comp.name, "description": comp.description, "version": XmlUtils.VERSION }) #add the tpcl_requirements tag and its text tpcl_req_elem = ElementTree.SubElement(root, "tpcl_requirements") tpcl_req_elem.text = comp.tpcl_requirements #add the categories root.append(ElementTree.Comment("categories")) for cat in comp.categories: cat_elem = ElementTree.SubElement(root, "category", {'name': cat}) #add the properties root.append(ElementTree.Comment("properties")) for name, tpcl_cost in comp.properties.iteritems(): propelem = ElementTree.SubElement(root, "property", {"name": name}) tpcl_cost_elem = ElementTree.SubElement(propelem, "tpcl_cost") tpcl_cost_elem.text = tpcl_cost et = ElementTree.ElementTree(root) XmlUtils.WriteElementTree(et, save_location, indent=True)
def GenerateCode(prop, save_location): """\ Writes a component out to an XML file """ #make base tag and supply attributes as necessary root = ElementTree.Element(Category.GetName().lower(), {"name": prop.name, "description": prop.description, "version": XmlUtils.VERSION}) et = ElementTree.ElementTree(root) XmlUtils.WriteElementTree(et, save_location, indent=True)
def GenerateCode(prop, save_location): """\ Writes a component out to an XML file """ #make base tag and supply attributes as necessary root = ElementTree.Element( Property.GetName().lower(), { "name": prop.name, "description": prop.description, "rank": prop.rank, "display_text": prop.display_text, "version": XmlUtils.VERSION }) #add the tpcl_requirements tag and its text tpcl_display_elem = ElementTree.SubElement(root, "tpcl_display") tpcl_display_elem.text = prop.tpcl_display tpcl_requires_elem = ElementTree.SubElement(root, "tpcl_requires") tpcl_requires_elem.text = prop.tpcl_requires #add the categories root.append(ElementTree.Comment("categories")) for cat in prop.categories: cat_elem = ElementTree.SubElement(root, "category", {'name': cat}) et = ElementTree.ElementTree(root) XmlUtils.WriteElementTree(et, save_location, indent=True)