def save_xml(self):
     material_dict = self.materials.material_dict
     filename = self.parent.filename
     materials_xml = Element("materials")
     for name, material in material_dict.items():
         material_xml = SubElement(materials_xml, "material")
         name_xml = SubElement(material_xml, "name")
         name_xml.text = name
         surface_color_xml = SubElement(material_xml, "surface_color")
         red_xml = SubElement(surface_color_xml, "red")
         green_xml = SubElement(surface_color_xml, "green")
         blue_xml = SubElement(surface_color_xml, "blue")
         red_xml.text = str(material.get_surface_colour()[0])
         green_xml.text = str(material.get_surface_colour()[1])
         blue_xml.text = str(material.get_surface_colour()[2])
         transparency_xml = SubElement(material_xml, "transparency")
         transparency_xml.text = str(material.get_transparency())
         reflectance_method_xml = SubElement(material_xml, "reflectance_method")
         reflectance_method_xml.text = str(material.get_reflectance_method())
         reflectance_xml = SubElement(material_xml, "reflectance")
         reflectance_xml.text = str(material.get_reflectance())
         slip_coefficient_xml = SubElement(material_xml, "slip_coefficient")
         slip_coefficient_xml.text = str(material.get_slip_coefficient())
         imperviousness_xml = SubElement(material_xml, "imperviousness")
         imperviousness_xml.text = str(material.get_imperviousness())
     print(prettify(materials_xml))
Пример #2
0
def get_table_data(name, order_by=None):
    component = models.components[name]
    properties = sorted(component.properties)
    for field in models.HIDDEN_FIELDS:
        properties.remove(field)
    headers = [util.prettify(property) for property in properties]
    rows = [(x.id, x.uuid, [getattr(x, field) for field in properties]) for x in component.query.all()]
    return headers, rows
Пример #3
0
def create_component_form(model):
    dct = {}
    for key in model.properties:
        if key not in models.HIDDEN_FIELDS:
            dct[key] = TextField(util.prettify(key), id='id_%s' % key)
    return type('ComponentForm', (Form,), dct)
Пример #4
0
 def __unicode__(self):
     data = prettify(self._document)
     return '%s[%d]:\n%s' % (self.__class__.__name__, id(self), data)
Пример #5
0
def create_form(model):
    dct = {}
    for key in model.properties:
        if key not in models.HIDDEN_FIELDS:
            dct[key] = TextField(util.prettify(key))
    return type('ComponentForm', (Form, ), dct)