diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-03-15 14:55:15 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-03-15 14:55:15 +0100 |
commit | 237a6faa8a23826e68bbc00bc107b2d6f97235d0 (patch) | |
tree | fe1a6a6b1a4ed991a6eacd9ec6960325db3f9e4f /src/ee/xml | |
parent | 3523190bb7ca1c38caea3a1aae51062d22e56b09 (diff) | |
download | ee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.tar.gz ee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.tar.bz2 ee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.tar.xz ee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.zip |
Refactoring:
o Renaming part.id to part.uri. Changing to URIs and use that as an
identifier if the part is known. Schematic part does not have an URI.
o Merging <schema-reference> and <part-numbers> into <references>
o Creating <part-uri> as a possible <reference>. Used by order to point
to other parts.
Diffstat (limited to 'src/ee/xml')
-rw-r--r-- | src/ee/xml/bom_file_utils.py | 29 | ||||
-rw-r--r-- | src/ee/xml/types.py | 448 |
2 files changed, 385 insertions, 92 deletions
diff --git a/src/ee/xml/bom_file_utils.py b/src/ee/xml/bom_file_utils.py index 59a9b0e..207ac5a 100644 --- a/src/ee/xml/bom_file_utils.py +++ b/src/ee/xml/bom_file_utils.py @@ -5,8 +5,9 @@ from ee.xml import types __all__ = [ "facts", "find_root_tag", - "find_pn", - "find_dpn", + "schematic_references", + "part_numbers", + "supplier_part_numbers", ] @@ -14,25 +15,19 @@ def find_root_tag(root): return next((tag for tag, klass in types.GDSClassesMapping.items() if klass == type(root)), None) -def part_numbers(part: types.Part) -> List[types.PartNumber]: - pns = part.part_numbersProp # type: types.PartNumberList - - if pns is None: - return [] +def schematic_references(part: types.Part) -> List[types.SchematicReference]: + return [] if part.referencesProp is None or part.referencesProp.schematic_reference is None else \ + part.referencesProp.schematic_reference - return pns.part_numberProp - -def find_pn(part: types.Part) -> Optional[str]: - for pn in part_numbers(part): - if pn.distributor is None: - return pn.value +def part_numbers(part: types.Part) -> List[types.PartNumber]: + return [] if part.referencesProp is None or part.referencesProp.part_number is None else \ + part.referencesProp.part_number -def find_dpn(part: types.Part, distributor: str) -> Optional[str]: - for pn in part_numbers(part): - if pn.distributor == distributor: - return pn.value +def supplier_part_numbers(part: types.Part) -> List[types.SupplierPartNumber]: + return [] if part.referencesProp is None or part.referencesProp.supplier_part_number is None else \ + part.referencesProp.supplier_part_number def facts(part: types.Part, create=False) -> Optional[types.FactList]: diff --git a/src/ee/xml/types.py b/src/ee/xml/types.py index fec6884..35cd664 100644 --- a/src/ee/xml/types.py +++ b/src/ee/xml/types.py @@ -807,13 +807,12 @@ class PartDb(GeneratedsSuper): class Part(GeneratedsSuper): subclass = None superclass = None - def __init__(self, id=None, schema_reference=None, part_type=None, part_numbers=None, distributor_info=None, facts=None, price_breaks=None, **kwargs_): + def __init__(self, uri=None, part_type=None, references=None, distributor_info=None, facts=None, price_breaks=None, **kwargs_): self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') - self.id = _cast(None, id) - self.schema_reference = schema_reference + self.uri = _cast(None, uri) self.part_type = part_type - self.part_numbers = part_numbers + self.references = references self.distributor_info = distributor_info self.facts = facts self.price_breaks = price_breaks @@ -828,21 +827,16 @@ class Part(GeneratedsSuper): else: return Part(*args_, **kwargs_) factory = staticmethod(factory) - def get_schema_reference(self): - return self.schema_reference - def set_schema_reference(self, schema_reference): - self.schema_reference = schema_reference - schema_referenceProp = property(get_schema_reference, set_schema_reference) def get_part_type(self): return self.part_type def set_part_type(self, part_type): self.part_type = part_type part_typeProp = property(get_part_type, set_part_type) - def get_part_numbers(self): - return self.part_numbers - def set_part_numbers(self, part_numbers): - self.part_numbers = part_numbers - part_numbersProp = property(get_part_numbers, set_part_numbers) + def get_references(self): + return self.references + def set_references(self, references): + self.references = references + referencesProp = property(get_references, set_references) def get_distributor_info(self): return self.distributor_info def set_distributor_info(self, distributor_info): @@ -858,16 +852,15 @@ class Part(GeneratedsSuper): def set_price_breaks(self, price_breaks): self.price_breaks = price_breaks price_breaksProp = property(get_price_breaks, set_price_breaks) - def get_id(self): - return self.id - def set_id(self, id): - self.id = id - idProp = property(get_id, set_id) + def get_uri(self): + return self.uri + def set_uri(self, uri): + self.uri = uri + uriProp = property(get_uri, set_uri) def hasContent_(self): if ( - self.schema_reference is not None or self.part_type is not None or - self.part_numbers is not None or + self.references is not None or self.distributor_info is not None or self.facts is not None or self.price_breaks is not None @@ -897,22 +890,19 @@ class Part(GeneratedsSuper): else: outfile.write('/>%s' % (eol_, )) def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='Part'): - if self.id is not None and 'id' not in already_processed: - already_processed.add('id') - outfile.write(' id=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.id), input_name='id')), )) + if self.uri is not None and 'uri' not in already_processed: + already_processed.add('uri') + outfile.write(' uri=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.uri), input_name='uri')), )) def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='Part', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' - if self.schema_reference is not None: - showIndent(outfile, level, pretty_print) - outfile.write('<%sschema-reference>%s</%sschema-reference>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.schema_reference), input_name='schema-reference')), namespaceprefix_ , eol_)) if self.part_type is not None: showIndent(outfile, level, pretty_print) outfile.write('<%spart-type>%s</%spart-type>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.part_type), input_name='part-type')), namespaceprefix_ , eol_)) - if self.part_numbers is not None: - self.part_numbers.export(outfile, level, namespaceprefix_, namespacedef_='', name_='part-numbers', pretty_print=pretty_print) + if self.references is not None: + self.references.export(outfile, level, namespaceprefix_, namespacedef_='', name_='references', pretty_print=pretty_print) if self.distributor_info is not None: self.distributor_info.export(outfile, level, namespaceprefix_, namespacedef_='', name_='distributor-info', pretty_print=pretty_print) if self.facts is not None: @@ -927,24 +917,20 @@ class Part(GeneratedsSuper): self.buildChildren(child, node, nodeName_) return self def buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_('id', node) - if value is not None and 'id' not in already_processed: - already_processed.add('id') - self.id = value + value = find_attr_value_('uri', node) + if value is not None and 'uri' not in already_processed: + already_processed.add('uri') + self.uri = value def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): - if nodeName_ == 'schema-reference': - schema_reference_ = child_.text - schema_reference_ = self.gds_validate_string(schema_reference_, node, 'schema_reference') - self.schema_reference = schema_reference_ - elif nodeName_ == 'part-type': + if nodeName_ == 'part-type': part_type_ = child_.text part_type_ = self.gds_validate_string(part_type_, node, 'part_type') self.part_type = part_type_ - elif nodeName_ == 'part-numbers': - obj_ = PartNumberList.factory(parent_object_=self) + elif nodeName_ == 'references': + obj_ = ReferencesList.factory(parent_object_=self) obj_.build(child_) - self.part_numbers = obj_ - obj_.original_tagname_ = 'part-numbers' + self.references = obj_ + obj_.original_tagname_ = 'references' elif nodeName_ == 'distributor-info': obj_ = DistributorInfo.factory(parent_object_=self) obj_.build(child_) @@ -1052,14 +1038,91 @@ class PartList(GeneratedsSuper): # end class PartList +class PartUri(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, value=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + self.value = value + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, PartUri) + if subclass is not None: + return subclass(*args_, **kwargs_) + if PartUri.subclass: + return PartUri.subclass(*args_, **kwargs_) + else: + return PartUri(*args_, **kwargs_) + factory = staticmethod(factory) + def get_value(self): + return self.value + def set_value(self, value): + self.value = value + valueProp = property(get_value, set_value) + def hasContent_(self): + if ( + self.value is not None + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PartUri', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('PartUri') + if imported_ns_def_ is not None: + namespacedef_ = imported_ns_def_ + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + if self.original_tagname_ is not None: + name_ = self.original_tagname_ + showIndent(outfile, level, pretty_print) + outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) + already_processed = set() + self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PartUri') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PartUri', pretty_print=pretty_print) + showIndent(outfile, level, pretty_print) + outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) + else: + outfile.write('/>%s' % (eol_, )) + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PartUri'): + pass + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PartUri', fromsubclass_=False, pretty_print=True): + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + if self.value is not None: + showIndent(outfile, level, pretty_print) + outfile.write('<%svalue>%s</%svalue>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.value), input_name='value')), namespaceprefix_ , eol_)) + def build(self, node): + already_processed = set() + self.buildAttributes(node, node.attrib, already_processed) + for child in node: + nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] + self.buildChildren(child, node, nodeName_) + return self + def buildAttributes(self, node, attrs, already_processed): + pass + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + if nodeName_ == 'value': + value_ = child_.text + value_ = self.gds_validate_string(value_, node, 'value') + self.value = value_ +# end class PartUri + + class PartNumber(GeneratedsSuper): subclass = None superclass = None - def __init__(self, value=None, distributor=None, **kwargs_): + def __init__(self, value=None, **kwargs_): self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') self.value = value - self.distributor = distributor def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -1076,15 +1139,9 @@ class PartNumber(GeneratedsSuper): def set_value(self, value): self.value = value valueProp = property(get_value, set_value) - def get_distributor(self): - return self.distributor - def set_distributor(self, distributor): - self.distributor = distributor - distributorProp = property(get_distributor, set_distributor) def hasContent_(self): if ( - self.value is not None or - self.distributor is not None + self.value is not None ): return True else: @@ -1120,9 +1177,6 @@ class PartNumber(GeneratedsSuper): if self.value is not None: showIndent(outfile, level, pretty_print) outfile.write('<%svalue>%s</%svalue>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.value), input_name='value')), namespaceprefix_ , eol_)) - if self.distributor is not None: - showIndent(outfile, level, pretty_print) - outfile.write('<%sdistributor>%s</%sdistributor>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.distributor), input_name='distributor')), namespaceprefix_ , eol_)) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1137,34 +1191,238 @@ class PartNumber(GeneratedsSuper): value_ = child_.text value_ = self.gds_validate_string(value_, node, 'value') self.value = value_ - elif nodeName_ == 'distributor': - distributor_ = child_.text - distributor_ = self.gds_validate_string(distributor_, node, 'distributor') - self.distributor = distributor_ # end class PartNumber -class PartNumberList(GeneratedsSuper): +class SupplierPartNumber(GeneratedsSuper): subclass = None superclass = None - def __init__(self, part_number=None, **kwargs_): + def __init__(self, value=None, supplier=None, **kwargs_): self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') + self.value = value + self.supplier = supplier + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, SupplierPartNumber) + if subclass is not None: + return subclass(*args_, **kwargs_) + if SupplierPartNumber.subclass: + return SupplierPartNumber.subclass(*args_, **kwargs_) + else: + return SupplierPartNumber(*args_, **kwargs_) + factory = staticmethod(factory) + def get_value(self): + return self.value + def set_value(self, value): + self.value = value + valueProp = property(get_value, set_value) + def get_supplier(self): + return self.supplier + def set_supplier(self, supplier): + self.supplier = supplier + supplierProp = property(get_supplier, set_supplier) + def hasContent_(self): + if ( + self.value is not None or + self.supplier is not None + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SupplierPartNumber', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('SupplierPartNumber') + if imported_ns_def_ is not None: + namespacedef_ = imported_ns_def_ + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + if self.original_tagname_ is not None: + name_ = self.original_tagname_ + showIndent(outfile, level, pretty_print) + outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) + already_processed = set() + self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SupplierPartNumber') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='SupplierPartNumber', pretty_print=pretty_print) + showIndent(outfile, level, pretty_print) + outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) + else: + outfile.write('/>%s' % (eol_, )) + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SupplierPartNumber'): + pass + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SupplierPartNumber', fromsubclass_=False, pretty_print=True): + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + if self.value is not None: + showIndent(outfile, level, pretty_print) + outfile.write('<%svalue>%s</%svalue>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.value), input_name='value')), namespaceprefix_ , eol_)) + if self.supplier is not None: + showIndent(outfile, level, pretty_print) + outfile.write('<%ssupplier>%s</%ssupplier>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.supplier), input_name='supplier')), namespaceprefix_ , eol_)) + def build(self, node): + already_processed = set() + self.buildAttributes(node, node.attrib, already_processed) + for child in node: + nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] + self.buildChildren(child, node, nodeName_) + return self + def buildAttributes(self, node, attrs, already_processed): + pass + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + if nodeName_ == 'value': + value_ = child_.text + value_ = self.gds_validate_string(value_, node, 'value') + self.value = value_ + elif nodeName_ == 'supplier': + supplier_ = child_.text + supplier_ = self.gds_validate_string(supplier_, node, 'supplier') + self.supplier = supplier_ +# end class SupplierPartNumber + + +class SchematicReference(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, reference=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + self.reference = reference + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, SchematicReference) + if subclass is not None: + return subclass(*args_, **kwargs_) + if SchematicReference.subclass: + return SchematicReference.subclass(*args_, **kwargs_) + else: + return SchematicReference(*args_, **kwargs_) + factory = staticmethod(factory) + def get_reference(self): + return self.reference + def set_reference(self, reference): + self.reference = reference + referenceProp = property(get_reference, set_reference) + def hasContent_(self): + if ( + self.reference is not None + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SchematicReference', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('SchematicReference') + if imported_ns_def_ is not None: + namespacedef_ = imported_ns_def_ + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + if self.original_tagname_ is not None: + name_ = self.original_tagname_ + showIndent(outfile, level, pretty_print) + outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) + already_processed = set() + self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SchematicReference') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='SchematicReference', pretty_print=pretty_print) + showIndent(outfile, level, pretty_print) + outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) + else: + outfile.write('/>%s' % (eol_, )) + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SchematicReference'): + pass + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SchematicReference', fromsubclass_=False, pretty_print=True): + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + if self.reference is not None: + showIndent(outfile, level, pretty_print) + outfile.write('<%sreference>%s</%sreference>%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.reference), input_name='reference')), namespaceprefix_ , eol_)) + def build(self, node): + already_processed = set() + self.buildAttributes(node, node.attrib, already_processed) + for child in node: + nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] + self.buildChildren(child, node, nodeName_) + return self + def buildAttributes(self, node, attrs, already_processed): + pass + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + if nodeName_ == 'reference': + reference_ = child_.text + reference_ = self.gds_validate_string(reference_, node, 'reference') + self.reference = reference_ +# end class SchematicReference + + +class ReferencesList(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, schematic_reference=None, part_uri=None, part_number=None, supplier_part_number=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + if schematic_reference is None: + self.schematic_reference = [] + else: + self.schematic_reference = schematic_reference + if part_uri is None: + self.part_uri = [] + else: + self.part_uri = part_uri if part_number is None: self.part_number = [] else: self.part_number = part_number + if supplier_part_number is None: + self.supplier_part_number = [] + else: + self.supplier_part_number = supplier_part_number def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( - CurrentSubclassModule_, PartNumberList) + CurrentSubclassModule_, ReferencesList) if subclass is not None: return subclass(*args_, **kwargs_) - if PartNumberList.subclass: - return PartNumberList.subclass(*args_, **kwargs_) + if ReferencesList.subclass: + return ReferencesList.subclass(*args_, **kwargs_) else: - return PartNumberList(*args_, **kwargs_) + return ReferencesList(*args_, **kwargs_) factory = staticmethod(factory) + def get_schematic_reference(self): + return self.schematic_reference + def set_schematic_reference(self, schematic_reference): + self.schematic_reference = schematic_reference + def add_schematic_reference(self, value): + self.schematic_reference.append(value) + def add_schematic_reference(self, value): + self.schematic_reference.append(value) + def insert_schematic_reference_at(self, index, value): + self.schematic_reference.insert(index, value) + def replace_schematic_reference_at(self, index, value): + self.schematic_reference[index] = value + schematic_referenceProp = property(get_schematic_reference, set_schematic_reference) + def get_part_uri(self): + return self.part_uri + def set_part_uri(self, part_uri): + self.part_uri = part_uri + def add_part_uri(self, value): + self.part_uri.append(value) + def add_part_uri(self, value): + self.part_uri.append(value) + def insert_part_uri_at(self, index, value): + self.part_uri.insert(index, value) + def replace_part_uri_at(self, index, value): + self.part_uri[index] = value + part_uriProp = property(get_part_uri, set_part_uri) def get_part_number(self): return self.part_number def set_part_number(self, part_number): @@ -1178,15 +1436,31 @@ class PartNumberList(GeneratedsSuper): def replace_part_number_at(self, index, value): self.part_number[index] = value part_numberProp = property(get_part_number, set_part_number) + def get_supplier_part_number(self): + return self.supplier_part_number + def set_supplier_part_number(self, supplier_part_number): + self.supplier_part_number = supplier_part_number + def add_supplier_part_number(self, value): + self.supplier_part_number.append(value) + def add_supplier_part_number(self, value): + self.supplier_part_number.append(value) + def insert_supplier_part_number_at(self, index, value): + self.supplier_part_number.insert(index, value) + def replace_supplier_part_number_at(self, index, value): + self.supplier_part_number[index] = value + supplier_part_numberProp = property(get_supplier_part_number, set_supplier_part_number) def hasContent_(self): if ( - self.part_number + self.schematic_reference or + self.part_uri or + self.part_number or + self.supplier_part_number ): return True else: return False - def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PartNumberList', pretty_print=True): - imported_ns_def_ = GenerateDSNamespaceDefs_.get('PartNumberList') + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ReferencesList', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('ReferencesList') if imported_ns_def_ is not None: namespacedef_ = imported_ns_def_ if pretty_print: @@ -1198,23 +1472,29 @@ class PartNumberList(GeneratedsSuper): showIndent(outfile, level, pretty_print) outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) already_processed = set() - self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='PartNumberList') + self.exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='ReferencesList') if self.hasContent_(): outfile.write('>%s' % (eol_, )) - self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PartNumberList', pretty_print=pretty_print) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='ReferencesList', pretty_print=pretty_print) showIndent(outfile, level, pretty_print) outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_)) else: outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='PartNumberList'): + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='ReferencesList'): pass - def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PartNumberList', fromsubclass_=False, pretty_print=True): + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='ReferencesList', fromsubclass_=False, pretty_print=True): if pretty_print: eol_ = '\n' else: eol_ = '' + for schematic_reference_ in self.schematic_reference: + schematic_reference_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='schematic-reference', pretty_print=pretty_print) + for part_uri_ in self.part_uri: + part_uri_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='part-uri', pretty_print=pretty_print) for part_number_ in self.part_number: part_number_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='part-number', pretty_print=pretty_print) + for supplier_part_number_ in self.supplier_part_number: + supplier_part_number_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='supplier-part-number', pretty_print=pretty_print) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -1225,12 +1505,27 @@ class PartNumberList(GeneratedsSuper): def buildAttributes(self, node, attrs, already_processed): pass def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): - if nodeName_ == 'part-number': + if nodeName_ == 'schematic-reference': + obj_ = SchematicReference.factory(parent_object_=self) + obj_.build(child_) + self.schematic_reference.append(obj_) + obj_.original_tagname_ = 'schematic-reference' + elif nodeName_ == 'part-uri': + obj_ = PartUri.factory(parent_object_=self) + obj_.build(child_) + self.part_uri.append(obj_) + obj_.original_tagname_ = 'part-uri' + elif nodeName_ == 'part-number': obj_ = PartNumber.factory(parent_object_=self) obj_.build(child_) self.part_number.append(obj_) obj_.original_tagname_ = 'part-number' -# end class PartNumberList + elif nodeName_ == 'supplier-part-number': + obj_ = SupplierPartNumber.factory(parent_object_=self) + obj_.build(child_) + self.supplier_part_number.append(obj_) + obj_.original_tagname_ = 'supplier-part-number' +# end class ReferencesList class Fact(GeneratedsSuper): @@ -1911,7 +2206,10 @@ __all__ = [ "PartDb", "PartList", "PartNumber", - "PartNumberList", + "PartUri", "PriceBreak", - "PriceBreakList" + "PriceBreakList", + "ReferencesList", + "SchematicReference", + "SupplierPartNumber" ] |