def transform_Items(di, parent): href = parent.child_with_tag("Definition").attributes["href"] ref = templates[href].attributes["uuid"] return [ xml_dict.xml_node("Template", {"ref": ref}), xml_dict.xml_node("TemplateRules", {"operator": "and"}) ]
def xml(self): return xml_dict.xml_node( tag='packagedElement', attributes={ XMI.type: 'uml:Enumeration', XMI.id: self.id, 'name': self.name, }, children=[ xml_dict.xml_node(tag='ownedLiteral', attributes={ XMI.type: 'uml:EnumerationLiteral', XMI.id: new_id(), 'name': v, }) for v in self.values ])
def create_mvd(roots): return [xml_dict.xml_node( "mvdXML", { "uuid": transform_uuid(ifcopenshell.guid.new()), "name": "", "status": "sample", }, children=[xml_dict.xml_node( "Templates", children=[templates[t] for t in used_template_ids.keys()] ),xml_dict.xml_node( "Views", children=roots )] )]
def xml(self): return xml_dict.xml_node(tag='packagedElement', attributes={ XMI.type: 'uml:Class', XMI.id: self.id, 'name': self.name, 'visibility': 'public' })
def xml(self): return xml_dict.xml_node(tag='packagedElement', attributes={ XMI.type: 'uml:Realization', XMI.id: self.id, "supplier": self.supplier, "client": self.client })
def transform_DocConceptRoot(di, parent): return xml_dict.xml_node( "ConceptRoot", { 'uuid': transform_uuid(di.attributes["UniqueId"]), 'name': di.child_with_tag("ApplicableEntity").attributes["href"], 'applicableRootEntity': di.child_with_tag("ApplicableEntity").attributes["href"] } )
def transform_DocTemplateDefinition(di, parent): if di.attributes.get("href"): if di.attributes["href"] not in templates: raise DependencyError(di.attributes["href"]) ref = templates[di.attributes["href"]].attributes["uuid"] return xml_dict.xml_node( "Template", {'ref': ref} ) elif di.attributes.get("Type") and di.attributes.get("id"): return xml_dict.xml_node( "ConceptTemplate", { 'id': di.attributes["id"], 'uuid': transform_uuid(di.attributes["UniqueId"]), 'name': di.attributes["Name"], 'applicableEntity': di.attributes["Type"] } )
def transform_Documentation(di, parent): if parent.tag == "DocTemplateUsage": try: text = di.text.strip() except: text = None if text: return xml_dict.xml_node( "Definitions", children=[xml_dict.xml_node( "Definition", children=[xml_dict.xml_node( "Body", # is already being escaped # text=f"<![CDATA[{text}]]>" text=text )] )] )
def transform_Rules(di, parent): if parent.tag == "DocTemplateDefinition": tag = "Rules" elif parent.tag == "DocModelRuleAttribute": tag = "EntityRules" else: if 'DocModelRuleConstraint' in [c.tag for c in di.children]: tag = "Constraints" assert len(di.children) == 1 else: tag = "AttributeRules" return xml_dict.xml_node(tag)
def inner(type_id_connector_id, owner): # @todo flatstarmap? type_id, connector_id = type_id_connector_id li = [ xml_dict.xml_node(tag='memberEnd', attributes={ XMI.idref: connector_id, }) ] if owner is None: li.append( xml_dict.xml_node(tag='ownedEnd', attributes={ XMI.type: 'uml:Property', XMI.id: connector_id, "association": assoc_id }, children=[ xml_dict.xml_node(tag='type', attributes={ XMI.idref: type_id, }) ])) else: owner.children.append( xml_dict.xml_node(tag='ownedAttribute', attributes={ XMI.type: 'uml:Property', XMI.id: connector_id, "association": assoc_id }, children=[ xml_dict.xml_node(tag='type', attributes={ XMI.idref: type_id, }) ])) return li
def transform_DocTemplateUsage(di, parent): children = [] if di.child_with_tag("Definition").child_with_tag("Items") is None: # for non-parametrized usages we need to take care of the definition ref = templates[di.child_with_tag("Definition").attributes["href"]].attributes["uuid"] children.append( xml_dict.xml_node("Template", {"ref": ref}) ) href = di.child_with_tag("Definition").attributes["href"] if href not in used_template_ids: used_template_ids[href] = 1 return xml_dict.xml_node( "Concept", { 'uuid': transform_uuid(di.attributes["UniqueId"]), 'name': templates[href].attributes["name"], 'status': "sample", 'override': "false" }, children=children )
def xml(self): c_ids = [ cid or new_id() for _, cid in zip_l(self.connector_types, self.connector_ids or []) ] owners = self.owners or ([None] * len(c_ids)) return xml_dict.xml_node(tag='packagedElement', attributes={ XMI.type: self.type, XMI.id: self.id, 'visibility': 'public' }, children=list( flatmap(create_connector(self.id), zip(self.connector_types, c_ids), owners)))
def transform_DocTemplateItem(di, parent): if "RuleParameters" in di.attributes: params = [p for p in di.attributes.get("RuleParameters", "").split(";") if p and do_try(lambda: parse_mvd_expr(p), lambda: print(f"Failed to parse {p}")) is not failure] params = ";".join(params) if params: params += ";" try: description = [("Description", di.child_with_tag("Documentation").text)] except: description = [] return xml_dict.xml_node( "TemplateRule", dict([ *description, ("Parameters", params) ]) )
def transform_DocModelRuleConstraint(di, parent): v = di.child_with_tag("Expression").child_with_tag("Value").attributes["Literal"].replace("'", "") return xml_dict.xml_node( "Constraint", {"Expression": f"[Value]='{v}'"} )
def inner(di, parent): return xml_dict.xml_node( target, {attribute_mapping.get(k, k): v for k, v in di.attributes.items()} )