From 653ba7792ef1d490281f393326c96648bf8e2197 Mon Sep 17 00:00:00 2001 From: Stefan de Konink Date: Fri, 8 Apr 2011 13:06:59 +0200 Subject: [PATCH] Some bugs, and assumptions are the mother of all... exactly. Never trust documentation. --- nsapi/nsapi.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nsapi/nsapi.py b/nsapi/nsapi.py index 7ca4e29..3bf15f8 100644 --- a/nsapi/nsapi.py +++ b/nsapi/nsapi.py @@ -58,24 +58,24 @@ def GET(self): def processor(self, content): root = ElementTree.XML(content) dstations = {} - stations = root.findall('Station') + stations = root.findall('.//station') for station in stations: - if station.find('Land').text == 'NL': - code = station.find('code').text + if station.find('.//country').text == 'NL': + code = station.find('.//code').text if code not in dstations: - dstations[code] = {'alias': []} - if station.find('Alias').text == 'true': - dstations[code]['alias'].append(station.find('Naam')) + dstations[code] = {'alias': [], 'defaultname': '', 'locationX': '', 'locationY': ''} + if station.find('.//alias').text == 'true': + dstations[code]['alias'].append(station.find('.//name').text) else: - dstations[code]['defaultname'].append(station.find('Naam')) - dstations[code]['locationX'] = station.find('Lat') - dstations[code]['locationY'] = station.find('Long') - dstations[code]['alias'].append(station.find('Naam')) + dstations[code]['defaultname'] = station.find('.//name').text + dstations[code]['locationX'] = station.find('.//lat').text + dstations[code]['locationY'] = station.find('.//long').text + dstations[code]['alias'].append(station.find('.//name').text) root = ElementTree.Element('stations') - root.attrib['timestamp'] = int(time.time()) + root.attrib['timestamp'] = str(int(time.time())) - for station in dstations: + for station in dstations.values(): for alias in station['alias']: sub = ElementTree.SubElement(root, 'station') sub.attrib['locationX'] = station['locationX']