From a8ec679349c3eb9c33a9d33e247fd86cb8e53f81 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 14 Mar 2019 12:23:57 +0100 Subject: o Adding PriceBreak. Parsing price breaks from DK. o Adding Money type with parsing. --- src/ee/xml/bomFile.py | 292 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 288 insertions(+), 4 deletions(-) (limited to 'src/ee/xml') diff --git a/src/ee/xml/bomFile.py b/src/ee/xml/bomFile.py index 7c14679..0557a6c 100644 --- a/src/ee/xml/bomFile.py +++ b/src/ee/xml/bomFile.py @@ -3,7 +3,7 @@ # # Generated by generateDS.py. -# Python 3.7.2+ (default, Feb 2 2019, 14:31:48) [GCC 8.2.0] +# Python 3.7.2+ (default, Feb 27 2019, 15:41:59) [GCC 8.2.0] # # Command line options: # ('-f', '') @@ -807,7 +807,7 @@ class BomFile(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, **kwargs_): + def __init__(self, id=None, schema_reference=None, part_type=None, part_numbers=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) @@ -816,6 +816,7 @@ class Part(GeneratedsSuper): self.part_numbers = part_numbers self.distributor_info = distributor_info self.facts = facts + self.price_breaks = price_breaks def factory(*args_, **kwargs_): if CurrentSubclassModule_ is not None: subclass = getSubclassFromModule_( @@ -852,6 +853,11 @@ class Part(GeneratedsSuper): def set_facts(self, facts): self.facts = facts factsProp = property(get_facts, set_facts) + def get_price_breaks(self): + return self.price_breaks + 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): @@ -863,7 +869,8 @@ class Part(GeneratedsSuper): self.part_type is not None or self.part_numbers is not None or self.distributor_info is not None or - self.facts is not None + self.facts is not None or + self.price_breaks is not None ): return True else: @@ -910,6 +917,8 @@ class Part(GeneratedsSuper): 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: + self.price_breaks.export(outfile, level, namespaceprefix_, namespacedef_='', name_='price-breaks', pretty_print=pretty_print) def build(self, node): already_processed = set() self.buildAttributes(node, node.attrib, already_processed) @@ -946,6 +955,11 @@ class Part(GeneratedsSuper): obj_.build(child_) self.facts = obj_ obj_.original_tagname_ = 'facts' + elif nodeName_ == 'price-breaks': + obj_ = PriceBreakList.factory(parent_object_=self) + obj_.build(child_) + self.price_breaks = obj_ + obj_.original_tagname_ = 'price-breaks' # end class Part @@ -1492,6 +1506,273 @@ class DistributorInfo(GeneratedsSuper): # end class DistributorInfo +class Amount(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, value=None, currency=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + self.value = _cast(None, value) + self.currency = _cast(None, currency) + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, Amount) + if subclass is not None: + return subclass(*args_, **kwargs_) + if Amount.subclass: + return Amount.subclass(*args_, **kwargs_) + else: + return Amount(*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_currency(self): + return self.currency + def set_currency(self, currency): + self.currency = currency + currencyProp = property(get_currency, set_currency) + def hasContent_(self): + if ( + + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='Amount', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('Amount') + 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_='Amount') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='Amount', pretty_print=pretty_print) + outfile.write('%s' % (namespaceprefix_, name_, eol_)) + else: + outfile.write('/>%s' % (eol_, )) + def exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='Amount'): + if self.value is not None and 'value' not in already_processed: + already_processed.add('value') + outfile.write(' value=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.value), input_name='value')), )) + if self.currency is not None and 'currency' not in already_processed: + already_processed.add('currency') + outfile.write(' currency=%s' % (self.gds_encode(self.gds_format_string(quote_attrib(self.currency), input_name='currency')), )) + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='Amount', 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_('value', node) + if value is not None and 'value' not in already_processed: + already_processed.add('value') + self.value = value + value = find_attr_value_('currency', node) + if value is not None and 'currency' not in already_processed: + already_processed.add('currency') + self.currency = value + def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): + pass +# end class Amount + + +class PriceBreak(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, quantity=None, amount=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + self.quantity = quantity + self.amount = amount + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, PriceBreak) + if subclass is not None: + return subclass(*args_, **kwargs_) + if PriceBreak.subclass: + return PriceBreak.subclass(*args_, **kwargs_) + else: + return PriceBreak(*args_, **kwargs_) + factory = staticmethod(factory) + def get_quantity(self): + return self.quantity + def set_quantity(self, quantity): + self.quantity = quantity + quantityProp = property(get_quantity, set_quantity) + def get_amount(self): + return self.amount + def set_amount(self, amount): + self.amount = amount + amountProp = property(get_amount, set_amount) + def hasContent_(self): + if ( + self.quantity is not None or + self.amount is not None + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PriceBreak', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('PriceBreak') + 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_='PriceBreak') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PriceBreak', 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_='PriceBreak'): + pass + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PriceBreak', fromsubclass_=False, pretty_print=True): + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + if self.quantity is not None: + showIndent(outfile, level, pretty_print) + outfile.write('<%squantity>%s%s' % (namespaceprefix_ , self.gds_encode(self.gds_format_string(quote_xml(self.quantity), input_name='quantity')), namespaceprefix_ , eol_)) + if self.amount is not None: + self.amount.export(outfile, level, namespaceprefix_, namespacedef_='', name_='amount', 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_ == 'quantity': + quantity_ = child_.text + quantity_ = self.gds_validate_string(quantity_, node, 'quantity') + self.quantity = quantity_ + elif nodeName_ == 'amount': + obj_ = Amount.factory(parent_object_=self) + obj_.build(child_) + self.amount = obj_ + obj_.original_tagname_ = 'amount' +# end class PriceBreak + + +class PriceBreakList(GeneratedsSuper): + subclass = None + superclass = None + def __init__(self, price_break=None, **kwargs_): + self.original_tagname_ = None + self.parent_object_ = kwargs_.get('parent_object_') + if price_break is None: + self.price_break = [] + else: + self.price_break = price_break + def factory(*args_, **kwargs_): + if CurrentSubclassModule_ is not None: + subclass = getSubclassFromModule_( + CurrentSubclassModule_, PriceBreakList) + if subclass is not None: + return subclass(*args_, **kwargs_) + if PriceBreakList.subclass: + return PriceBreakList.subclass(*args_, **kwargs_) + else: + return PriceBreakList(*args_, **kwargs_) + factory = staticmethod(factory) + def get_price_break(self): + return self.price_break + def set_price_break(self, price_break): + self.price_break = price_break + def add_price_break(self, value): + self.price_break.append(value) + def add_price_break(self, value): + self.price_break.append(value) + def insert_price_break_at(self, index, value): + self.price_break.insert(index, value) + def replace_price_break_at(self, index, value): + self.price_break[index] = value + price_breakProp = property(get_price_break, set_price_break) + def hasContent_(self): + if ( + self.price_break + ): + return True + else: + return False + def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PriceBreakList', pretty_print=True): + imported_ns_def_ = GenerateDSNamespaceDefs_.get('PriceBreakList') + 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_='PriceBreakList') + if self.hasContent_(): + outfile.write('>%s' % (eol_, )) + self.exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_='PriceBreakList', 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_='PriceBreakList'): + pass + def exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='PriceBreakList', fromsubclass_=False, pretty_print=True): + if pretty_print: + eol_ = '\n' + else: + eol_ = '' + for price_break_ in self.price_break: + price_break_.export(outfile, level, namespaceprefix_, namespacedef_='', name_='price-break', 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_ == 'price-break': + obj_ = PriceBreak.factory(parent_object_=self) + obj_.build(child_) + self.price_break.append(obj_) + obj_.original_tagname_ = 'price-break' +# end class PriceBreakList + + GDSClassesMapping = { 'bom-file': BomFile, 'part': Part, @@ -1622,6 +1903,7 @@ if __name__ == '__main__': __all__ = [ + "Amount", "BomFile", "DistributorInfo", "Fact", @@ -1629,5 +1911,7 @@ __all__ = [ "Part", "PartList", "PartNumber", - "PartNumberList" + "PartNumberList", + "PriceBreak", + "PriceBreakList" ] -- cgit v1.2.3