diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2015-02-25 09:48:50 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2015-02-25 09:48:50 +0100 |
commit | edd6d64b9b7acb52285bbf56417139600509a018 (patch) | |
tree | 4768fb9a5edc51053c3e83fa27e1271688e4e6de | |
parent | 35fe94cadd044a248a081bb88d25012caaa87763 (diff) |
tracking: Fixed location for tollpost and PostNord.
-rw-r--r-- | modules/tracking.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/modules/tracking.py b/modules/tracking.py index c5d292e..c86ef46 100644 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -237,8 +237,9 @@ class TollpostModule(TrackingModule): lastevent = item['events'][-1] date = datetime.datetime.strptime(lastevent['eventTime'], '%Y-%m-%dT%H:%M:%S') event = lastevent['eventDescription'] - location = lastevent['location']['name'] - status = '%s (%s)' % (event, location) + location = lastevent['location'].get('name') or lastevent['location'].get('city') + if location: + status = '%s (%s)' % (event, location) results.append(TrackingResult(code, date, status.encode('utf-8'), delivered)) return results @@ -270,8 +271,9 @@ class PostNordModule(TrackingModule): lastevent = item['events'][-1] date = datetime.datetime.strptime(lastevent['eventTime'], '%Y-%m-%dT%H:%M:%S') event = lastevent['eventDescription'] - location = lastevent['location']['name'] - status = '%s (%s)' % (event, location) + location = lastevent['location'].get('name') or lastevent['location'].get('city') + if location: + status = '%s (%s)' % (event, location) results.append(TrackingResult(code, date, status.encode('utf-8'), delivered)) return results |