From e378e83a8a626d08683bbbd7d27063f77245d7ef Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 11 Oct 2019 19:48:46 +0100 Subject: [PATCH] Tidying --- webinterface.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/webinterface.py b/webinterface.py index 5b311b97..119318a0 100644 --- a/webinterface.py +++ b/webinterface.py @@ -2784,21 +2784,24 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumb postEvent=[] dayOfMonth=None for tag in postJsonObject['object']['tag']: - if tag.get('type'): - if tag['type']=='Event' or tag['type']=='Place': - if tag['type']=='Event': - # tag is an event - if tag.get('startTime'): - eventTime= \ - datetime.strptime(tag['startTime'], \ - "%Y-%m-%dT%H:%M:%S%z") - if int(eventTime.strftime("%Y"))==year and \ - int(eventTime.strftime("%m"))==monthNumber: - dayOfMonth=str(int(eventTime.strftime("%d"))) - postEvent.append(tag) - else: - # tag is a place - postEvent.append(tag) + if not tag.get('type'): + continue + if tag['type']!='Event' and tag['type']!='Place': + continue + if tag['type']=='Event': + # tag is an event + if not tag.get('startTime'): + continue + eventTime= \ + datetime.strptime(tag['startTime'], \ + "%Y-%m-%dT%H:%M:%S%z") + if int(eventTime.strftime("%Y"))==year and \ + int(eventTime.strftime("%m"))==monthNumber: + dayOfMonth=str(int(eventTime.strftime("%d"))) + postEvent.append(tag) + else: + # tag is a place + postEvent.append(tag) if postEvent and dayOfMonth: calendarPostIds.append(postId) if not events.get(dayOfMonth):