From b9da2d88e21e5edda04e928352b45d203147be26 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 14 May 2019 21:29:04 +0200 Subject: ee.xsd: o Removing distributor info, wasn't useful. o Removing part type, using a fact instead. part-search-list: o Putting in some smart rules about values for parts. Might be too smart for its own good. o Removing duplication checking, that is up to the searcher to decide. --- src/ee/xml/types.py | 109 +--------------------------------------------------- src/ee/xml/uris.py | 2 + 2 files changed, 3 insertions(+), 108 deletions(-) (limited to 'src/ee/xml') diff --git a/src/ee/xml/types.py b/src/ee/xml/types.py index a6ef46b..bfda4fa 100644 --- a/src/ee/xml/types.py +++ b/src/ee/xml/types.py @@ -821,16 +821,14 @@ class PartDb(GeneratedsSuper): class Part(GeneratedsSuper): subclass = None superclass = None - def __init__(self, uri=None, supplier=None, part_type=None, description=None, links=None, references=None, distributor_info=None, facts=None, price_breaks=None, **kwargs_): + def __init__(self, uri=None, supplier=None, description=None, links=None, references=None, facts=None, price_breaks=None, **kwargs_): self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') self.uri = _cast(None, uri) self.supplier = supplier - self.part_type = part_type self.description = description self.links = links self.references = references - self.distributor_info = distributor_info self.facts = facts self.price_breaks = price_breaks def factory(*args_, **kwargs_): @@ -849,11 +847,6 @@ class Part(GeneratedsSuper): def set_supplier(self, supplier): self.supplier = supplier supplierProp = property(get_supplier, set_supplier) - 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_description(self): return self.description def set_description(self, description): @@ -869,11 +862,6 @@ class Part(GeneratedsSuper): 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): - self.distributor_info = distributor_info - distributor_infoProp = property(get_distributor_info, set_distributor_info) def get_facts(self): return self.facts def set_facts(self, facts): @@ -892,11 +880,9 @@ class Part(GeneratedsSuper): def hasContent_(self): if ( self.supplier is not None or - self.part_type is not None or self.description is not None or self.links 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 ): @@ -936,9 +922,6 @@ class Part(GeneratedsSuper): if self.supplier is not None: showIndent(outfile, level, pretty_print) outfile.write('<%ssupplier>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.supplier), input_name='supplier')), namespaceprefix_ , eol_)) - if self.part_type is not None: - showIndent(outfile, level, pretty_print) - outfile.write('<%spart-type>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.part_type), input_name='part-type')), namespaceprefix_ , eol_)) if self.description is not None: showIndent(outfile, level, pretty_print) outfile.write('<%sdescription>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.description), input_name='description')), namespaceprefix_ , eol_)) @@ -946,8 +929,6 @@ class Part(GeneratedsSuper): self.links.export(outfile, level, namespaceprefix_, namespacedef_='', name_='links', 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: self.facts.export(outfile, level, namespaceprefix_, namespacedef_='', name_='facts', pretty_print=pretty_print) if self.price_breaks is not None: @@ -969,10 +950,6 @@ class Part(GeneratedsSuper): supplier_ = child_.text supplier_ = self.gds_validate_string(supplier_, node, 'supplier') self.supplier = supplier_ - elif 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_ == 'description': description_ = child_.text description_ = self.gds_validate_string(description_, node, 'description') @@ -987,11 +964,6 @@ class Part(GeneratedsSuper): obj_.build(child_) self.references = obj_ obj_.original_tagname_ = 'references' - elif nodeName_ == 'distributor-info': - obj_ = DistributorInfo.factory(parent_object_=self) - obj_.build(child_) - self.distributor_info = obj_ - obj_.original_tagname_ = 'distributor-info' elif nodeName_ == 'facts': obj_ = FactList.factory(parent_object_=self) obj_.build(child_) @@ -1790,84 +1762,6 @@ class FactList(GeneratedsSuper): # end class FactList -class DistributorInfo(GeneratedsSuper): - subclass = None - superclass = None - def __init__(self, state=None, **kwargs_): - self.original_tagname_ = None - self.parent_object_ = kwargs_.get('parent_object_') - self.state = state - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, DistributorInfo) - if subclass is not None: - return subclass(*args_, **kwargs_) - if DistributorInfo.subclass: - return DistributorInfo.subclass(*args_, **kwargs_) - else: - return DistributorInfo(*args_, **kwargs_) - factory = staticmethod(factory) - def get_state(self): - return self.state - def set_state(self, state): - self.state = state - stateProp = property(get_state, set_state) - def hasContent_(self): - if ( - self.state is not None - ): - return True - else: - return False - def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='DistributorInfo', pretty_print=True): - imported_ns_def_ = GenerateDSNamespaceDefs_.get('DistributorInfo') - 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_='DistributorInfo') - if self.hasContent_(): - outfile.write('>%s' % (eol_, )) - self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='DistributorInfo', pretty_print=pretty_print) - showIndent(outfile, level, pretty_print) - outfile.write('%s' % (namespaceprefix_, name_, eol_)) - else: - outfile.write('/>%s' % (eol_, )) - def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='DistributorInfo'): - pass - def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='DistributorInfo', fromsubclass_=False, pretty_print=True): - if pretty_print: - eol_ = '\n' - else: - eol_ = '' - if self.state is not None: - showIndent(outfile, level, pretty_print) - outfile.write('<%sstate>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.state), input_name='state')), 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_ == 'state': - state_ = child_.text - state_ = self.gds_validate_string(state_, node, 'state') - self.state = state_ -# end class DistributorInfo - - class Amount(GeneratedsSuper): subclass = None superclass = None @@ -2747,7 +2641,6 @@ __all__ = [ "Assembly", "AssemblyPart", "AssemblyPartList", - "DistributorInfo", "Fact", "FactList", "Link", diff --git a/src/ee/xml/uris.py b/src/ee/xml/uris.py index c716103..f168c59 100644 --- a/src/ee/xml/uris.py +++ b/src/ee/xml/uris.py @@ -1,10 +1,12 @@ from typing import Optional +# Values for `..#type` facts CAPACITOR = "http://purl.org/ee/part-type#capacitor" RESISTOR = "http://purl.org/ee/part-type#resistor" DIODE = "http://purl.org/ee/part-type#diode" INDUCTOR = "http://purl.org/ee/part-type#inductor" CRYSTAL = "http://purl.org/ee/part-type#inductor" +TRANSISTOR = "http://purl.org/ee/part-type#transistor" _DIGIKEY_FACT_KEY_PREFIX = "http://purl.org/ee/digikey-fact-key#" -- cgit v1.2.3