Permalink
Browse files

Some fixes.

  • Loading branch information...
1 parent 750f016 commit b44449f8aba12bf1e603935cff871a3f95d2bd6a @skinkie committed Jul 30, 2011
Showing with 10 additions and 4 deletions.
  1. +10 −4 nsapi/nsapi.py
View
@@ -9,6 +9,7 @@
import simplejson
import time
import codecs
+import iso8601
urls = (
'/xml/(.*)', 'NSAPI',
@@ -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)
@@ -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)
@@ -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')

0 comments on commit b44449f

Please sign in to comment.