From c80e8a7f3b2340fbc9ec2e6c35d347af6693a859 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 18 Dec 2020 10:32:00 +0100 Subject: tracking: Handle posten events without description --- modules/tracking.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/tracking.py b/modules/tracking.py index 779162a..77f5a74 100755 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -158,12 +158,15 @@ class PostenModule(TrackingModule): if not len(eventset): continue last = eventset[0] - desc = last.find('{%s}Description' % ns).text.replace('<', '<').replace('
', ' ') + desc = last.find('{%s}Description' % ns).text or '' + desc = desc.replace('<', '<').replace('
', ' ') desc = re.sub(r'<[^>]*?>', '', desc).encode('utf8').strip() isodate = last.find('{%s}OccuredAtIsoDateTime' % ns).text[:-10] isodate = datetime.datetime.strptime(isodate, '%Y-%m-%dT%H:%M:%S') city = last.find('{%s}City' % ns).text status = last.find('{%s}Status' % ns).text.encode('utf-8') + if not desc: + desc = status if city: desc = '%s (%s)' % (desc, city.encode('utf8')) date = last.find('{%s}OccuredAtDisplayDate' % ns).text + ' ' + last.find('{%s}OccuredAtDisplayTime' % ns).text -- cgit v1.2.3