def cijena_HRK(): return (cijena_EUR() * EUR_2_HRK.getEUR_2_HRK())
def getChildByAttribute(node, attribute, value): for n in node.childNodes: if n.attributes[attribute].value == value: return n return None def parseXML(xml, country): xmldoc = minidom.parseString(xml) slovenia = getChildByAttribute(xmldoc.firstChild, 'label', country) f95 = getChildByAttribute(slovenia, 'type', '95') priceType = getChildByAttribute(f95, 'type', 'normal') price = getChildByAttribute(priceType, 'type', 'price') return price.firstChild.toxml() def cijena(xml, country): return float(parseXML(xml, country)) if __name__ == "__main__": xml, country, currencycode = auth() base_price = float(cijena(xml, map_country_code(country))) if (country, currencycode) == ('HR', 'HRK'): print "%.2f" % base_price elif (country, currencycode) == ('HR', 'EUR'): print "%.2f" % (base_price / EUR_2_HRK.getEUR_2_HRK()) elif (country, currencycode) == ('SI', 'HRK'): print "%.2f" % (base_price * EUR_2_HRK.getEUR_2_HRK()) elif (country, currencycode) == ('SI', 'EUR'): print "%.2f" % base_price