Skip to content

Commit

Permalink
Some fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
skinkie committed Jul 30, 2011
1 parent 750f016 commit b44449f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nsapi/nsapi.py
Expand Up @@ -9,6 +9,7 @@
import simplejson
import time
import codecs
import iso8601

urls = (
'/xml/(.*)', 'NSAPI',
Expand Down Expand Up @@ -140,6 +141,7 @@ def renderStation(self, root, name):

def processor(self, content):
# XSLT was invented for these kind of transformations
# TODO: RitNummer

dtreinen = []
root = ElementTree.XML(content)
Expand All @@ -156,9 +158,13 @@ def processor(self, content):
if vehicle is not None:
result['type'] = vehicle.text

vertraging = trein.find('.//VetrekVertragingTekst')
vertraging = trein.find('.//VertrekVertragingTekst')
if vertraging:
result['vertraging'] = vertraging.text

ritnummer = trein.find('.//RitNummer')
if ritnummer:
result['ritnummer'] = ritnummer.text

dtreinen.append(result)

Expand All @@ -180,12 +186,12 @@ def processor(self, content):

if 'type' in trein:
sub = ElementTree.SubElement(departure, 'vehicle')
sub.text = trein['type']
sub.text = 'NL.NS.'+trein['type']

if 'vertrektijd' in trein:
sub = ElementTree.SubElement(departure, 'time')
sub.attrib['formatted'] = 'iso8601'
sub.text = trein['vertrektijd']
sub.attrib['formatted'] = trein['vertrektijd']
sub.text = str(int(time.mktime(iso8601.parse_date(trein['vertrektijd']).timetuple())))

if 'spoor' in trein:
sub = ElementTree.SubElement(departure, 'platform')
Expand Down

0 comments on commit b44449f

Please sign in to comment.