def __init__(self, code, description, value, parent): super(BaremeNode, self).__init__(code, description, parent) self.value = value # create a copy of the default value by hand self.default = Bareme(value._name) for s, t in value._tranches: self.default.addTranche(s, t) self.default.marToMoy() self.typeInfo = 'BAREME'
def combineBaremes(BarColl, name="onsenfout"): baremeTot = Bareme(name=name) baremeTot.addTranche(0,0) for val in BarColl.__dict__.itervalues(): if isinstance(val, Bareme): baremeTot.addBareme(val) else: combineBaremes(val, baremeTot) return baremeTot
def handleNodeList(self, nodeList, parent): for element in nodeList: if element.nodeType is not element.TEXT_NODE: if element.tagName == "BAREME": code = element.getAttribute('code') desc = element.getAttribute('description') tranches = Bareme(code) for tranche in element.getElementsByTagName("TRANCHE"): seuil = self.handleValues( tranche.getElementsByTagName("SEUIL")[0], self._date) assi = tranche.getElementsByTagName("ASSIETTE") if assi: assiette = self.handleValues(assi[0], self._date) else: assiette = 1 taux = self.handleValues( tranche.getElementsByTagName("TAUX")[0], self._date) if not seuil is None and not taux is None: tranches.addTranche(seuil, taux * assiette) tranches.marToMoy() node = BaremeNode(code, desc, tranches, parent) elif element.tagName == "CODE": code = element.getAttribute('code') desc = element.getAttribute('description') valueFormat = element.getAttribute('format') val = self.handleValues(element, self._date) if not val is None: node = CodeNode(code, desc, float(val), parent, valueFormat) else: code = element.getAttribute('code') desc = element.getAttribute('description') node = Node(code, desc, parent) self.handleNodeList(element.childNodes, node)