main
Bob Mottram 2020-02-23 09:42:09 +00:00
parent 09e9ff5616
commit f0f818197e
1 changed files with 42 additions and 33 deletions

View File

@ -192,6 +192,7 @@ def thisWeeksEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}: def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
"""Retrieves calendar events for this week """Retrieves calendar events for this week
Returns a dictionary indexed by day number of lists containing Event and Place activities Returns a dictionary indexed by day number of lists containing Event and Place activities
Note: currently not used but could be with a weekly calendar screen
""" """
now=datetime.now() now=datetime.now()
year=now.year year=now.year
@ -275,7 +276,8 @@ def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
return events return events
def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumber: int) -> {}: def getCalendarEvents(baseDir: str,nickname: str,domain: str, \
year: int,monthNumber: int) -> {}:
"""Retrieves calendar events """Retrieves calendar events
Returns a dictionary indexed by day number of lists containing Event and Place activities Returns a dictionary indexed by day number of lists containing Event and Place activities
""" """
@ -291,12 +293,18 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumb
postFilename=locatePost(baseDir,nickname,domain,postId) postFilename=locatePost(baseDir,nickname,domain,postId)
if not postFilename: if not postFilename:
recreateEventsFile=True recreateEventsFile=True
else: continue
postJsonObject=loadJson(postFilename) postJsonObject=loadJson(postFilename)
if postJsonObject: if not postJsonObject:
if postJsonObject.get('object'): continue
if isinstance(postJsonObject['object'], dict): if not postJsonObject.get('object'):
if postJsonObject['object'].get('tag'): continue
if not isinstance(postJsonObject['object'], dict):
continue
if not postJsonObject['object'].get('tag'):
continue
postEvent=[] postEvent=[]
dayOfMonth=None dayOfMonth=None
for tag in postJsonObject['object']['tag']: for tag in postJsonObject['object']['tag']:
@ -318,6 +326,7 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumb
else: else:
# tag is a place # tag is a place
postEvent.append(tag) postEvent.append(tag)
if postEvent and dayOfMonth: if postEvent and dayOfMonth:
calendarPostIds.append(postId) calendarPostIds.append(postId)
if not events.get(dayOfMonth): if not events.get(dayOfMonth):