From 689508e07dba890fff8d1cd06e0029eca1c30994 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 23 Mar 2019 07:29:49 +0100 Subject: xsd: o Adding list on . For media, datasheets etc. digikey: o Parsing out media. PartDb: o starting on a more generic object db with indexes. order: o Using the new object db for building data while resolving parts. o Creating a report from the order. --- src/ee/xml/types.py | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 2 deletions(-) (limited to 'src/ee/xml') diff --git a/src/ee/xml/types.py b/src/ee/xml/types.py index a1ab7ec..60d659d 100644 --- a/src/ee/xml/types.py +++ b/src/ee/xml/types.py @@ -3,7 +3,7 @@ # # Generated by generateDS.py. -# Python 3.7.2+ (default, Feb 27 2019, 15:41:59) [GCC 8.2.0] +# Python 3.7.2+ (default, Feb 2 2019, 14:31:48) [GCC 8.2.0] # # Command line options: # ('-f', '') @@ -807,12 +807,13 @@ class PartDb(GeneratedsSuper): class Part(GeneratedsSuper): subclass = None superclass = None - def __init__(self, uri=None, part_type=None, description=None, references=None, distributor_info=None, facts=None, price_breaks=None, **kwargs_): + def __init__(self, uri=None, part_type=None, description=None, links=None, references=None, distributor_info=None, facts=None, price_breaks=None, **kwargs_): self.original_tagname_ = None self.parent_object_ = kwargs_.get('parent_object_') self.uri = _cast(None, uri) self.part_type = part_type self.description = description + self.links = links self.references = references self.distributor_info = distributor_info self.facts = facts @@ -838,6 +839,11 @@ class Part(GeneratedsSuper): def set_description(self, description): self.description = description descriptionProp = property(get_description, set_description) + def get_links(self): + return self.links + def set_links(self, links): + self.links = links + linksProp = property(get_links, set_links) def get_references(self): return self.references def set_references(self, references): @@ -867,6 +873,7 @@ class Part(GeneratedsSuper): if ( 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 @@ -911,6 +918,8 @@ class Part(GeneratedsSuper): 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_)) + if self.links is not None: + 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: @@ -940,6 +949,11 @@ class Part(GeneratedsSuper): description_ = child_.text description_ = self.gds_validate_string(description_, node, 'description') self.description = description_ + elif nodeName_ == 'links': + obj_ = LinkList.factory(parent_object_=self) + obj_.build(child_) + self.links = obj_ + obj_.original_tagname_ = 'links' elif nodeName_ == 'references': obj_ = ReferencesList.factory(parent_object_=self) obj_.build(child_) @@ -2082,6 +2096,207 @@ class PriceBreakList(GeneratedsSuper): # end class PriceBreakList +class Link(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, url=None, relation=None, media_type=None, title=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + self.url = _cast(None, url) + self.relation = _cast(None, relation) + self.media_type = _cast(None, media_type) + self.title = _cast(None, title) + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, Link) + if subclass is not None: + return subclass(*args_, **kwargs_) + if Link.subclass: + return Link.subclass(*args_, **kwargs_) + else: + return Link(*args_, **kwargs_) + factory = staticmethod(factory) + def get_url(self): + return self.url + def set_url(self, url): + self.url = url + urlProp = property(get_url, set_url) + def get_relation(self): + return self.relation + def set_relation(self, relation): + self.relation = relation + relationProp = property(get_relation, set_relation) + def get_media_type(self): + return self.media_type + def set_media_type(self, media_type): + self.media_type = media_type + media_typeProp = property(get_media_type, set_media_type) + def get_title(self): + return self.title + def set_title(self, title): + self.title = title + titleProp = property(get_title, set_title) + def hasContent_(self): + if ( + + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='Link', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('Link') + 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_='Link') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='Link', pretty_print=pretty_print) + outfile.write('%s' % (namespaceprefix_, name_, eol_)) + else: + outfile.write('/>%s' % (eol_, )) + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='Link'): + if self.url is not None and 'url' not in already_processed: + already_processed.add('url') + outfile.write(' url=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.url), input_name='url')), )) + if self.relation is not None and 'relation' not in already_processed: + already_processed.add('relation') + outfile.write(' relation=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.relation), input_name='relation')), )) + if self.media_type is not None and 'media_type' not in already_processed: + already_processed.add('media_type') + outfile.write(' media-type=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.media_type), input_name='media-type')), )) + if self.title is not None and 'title' not in already_processed: + already_processed.add('title') + outfile.write(' title=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.title), input_name='title')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='Link', fromsubclass_=False, pretty_print=True): + pass + 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): + value = find_attr_value_('url', node) + if value is not None and 'url' not in already_processed: + already_processed.add('url') + self.url = value + value = find_attr_value_('relation', node) + if value is not None and 'relation' not in already_processed: + already_processed.add('relation') + self.relation = value + value = find_attr_value_('media-type', node) + if value is not None and 'media-type' not in already_processed: + already_processed.add('media-type') + self.media_type = value + value = find_attr_value_('title', node) + if value is not None and 'title' not in already_processed: + already_processed.add('title') + self.title = value + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + pass +# end class Link + + +class LinkList(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, link=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + if link is None: + self.link = [] + else: + self.link = link + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, LinkList) + if subclass is not None: + return subclass(*args_, **kwargs_) + if LinkList.subclass: + return LinkList.subclass(*args_, **kwargs_) + else: + return LinkList(*args_, **kwargs_) + factory = staticmethod(factory) + def get_link(self): + return self.link + def set_link(self, link): + self.link = link + def add_link(self, value): + self.link.append(value) + def add_link(self, value): + self.link.append(value) + def insert_link_at(self, index, value): + self.link.insert(index, value) + def replace_link_at(self, index, value): + self.link[index] = value + linkProp = property(get_link, set_link) + def hasContent_(self): + if ( + self.link + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LinkList', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('LinkList') + 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_='LinkList') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='LinkList', 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_='LinkList'): + pass + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='LinkList', fromsubclass_=False, pretty_print=True): + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + for link_ in self.link: + link_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='link', pretty_print=pretty_print) + 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_ == 'link': + obj_ = Link.factory(parent_object_=self) + obj_.build(child_) + self.link.append(obj_) + obj_.original_tagname_ = 'link' +# end class LinkList + + GDSClassesMapping = { 'part': Part, 'part-db': PartDb, @@ -2216,6 +2431,8 @@ __all__ = [ "DistributorInfo", "Fact", "FactList", + "Link", + "LinkList", "Part", "PartDb", "PartList", -- cgit v1.2.3