forked from indymedia/epicyon
Less indentation
parent
36e7516257
commit
b193c0d6aa
258
happening.py
258
happening.py
|
@ -50,44 +50,45 @@ def getTodaysEvents(baseDir: str,nickname: str,domain: str, \
|
||||||
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)
|
|
||||||
if not postJsonObject:
|
|
||||||
continue
|
|
||||||
if not postJsonObject.get('object'):
|
|
||||||
continue
|
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
|
||||||
continue
|
|
||||||
if not postJsonObject['object'].get('tag'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
postEvent=[]
|
postJsonObject=loadJson(postFilename)
|
||||||
dayOfMonth=None
|
if not postJsonObject:
|
||||||
for tag in postJsonObject['object']['tag']:
|
continue
|
||||||
if not tag.get('type'):
|
if not postJsonObject.get('object'):
|
||||||
|
continue
|
||||||
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
continue
|
||||||
|
if not postJsonObject['object'].get('tag'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
postEvent=[]
|
||||||
|
dayOfMonth=None
|
||||||
|
for tag in postJsonObject['object']['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
|
continue
|
||||||
if tag['type']!='Event' and tag['type']!='Place':
|
eventTime= \
|
||||||
continue
|
datetime.strptime(tag['startTime'], \
|
||||||
if tag['type']=='Event':
|
"%Y-%m-%dT%H:%M:%S%z")
|
||||||
# tag is an event
|
if int(eventTime.strftime("%Y"))==year and \
|
||||||
if not tag.get('startTime'):
|
int(eventTime.strftime("%m"))==monthNumber and \
|
||||||
continue
|
int(eventTime.strftime("%d"))==dayNumber:
|
||||||
eventTime= \
|
dayOfMonth=str(int(eventTime.strftime("%d")))
|
||||||
datetime.strptime(tag['startTime'], \
|
|
||||||
"%Y-%m-%dT%H:%M:%S%z")
|
|
||||||
if int(eventTime.strftime("%Y"))==year and \
|
|
||||||
int(eventTime.strftime("%m"))==monthNumber and \
|
|
||||||
int(eventTime.strftime("%d"))==dayNumber:
|
|
||||||
dayOfMonth=str(int(eventTime.strftime("%d")))
|
|
||||||
postEvent.append(tag)
|
|
||||||
else:
|
|
||||||
# tag is a place
|
|
||||||
postEvent.append(tag)
|
postEvent.append(tag)
|
||||||
if postEvent and dayOfMonth:
|
else:
|
||||||
calendarPostIds.append(postId)
|
# tag is a place
|
||||||
if not events.get(dayOfMonth):
|
postEvent.append(tag)
|
||||||
events[dayOfMonth]=[]
|
if postEvent and dayOfMonth:
|
||||||
events[dayOfMonth].append(postEvent)
|
calendarPostIds.append(postId)
|
||||||
|
if not events.get(dayOfMonth):
|
||||||
|
events[dayOfMonth]=[]
|
||||||
|
events[dayOfMonth].append(postEvent)
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
|
@ -117,34 +118,36 @@ def todaysEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
|
||||||
for postId in eventsFile:
|
for postId in eventsFile:
|
||||||
postId=postId.replace('\n','')
|
postId=postId.replace('\n','')
|
||||||
postFilename=locatePost(baseDir,nickname,domain,postId)
|
postFilename=locatePost(baseDir,nickname,domain,postId)
|
||||||
if postFilename:
|
if not postFilename:
|
||||||
postJsonObject=loadJson(postFilename)
|
continue
|
||||||
if not postJsonObject:
|
|
||||||
continue
|
|
||||||
if not postJsonObject.get('object'):
|
|
||||||
continue
|
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
|
||||||
continue
|
|
||||||
if not postJsonObject['object'].get('tag'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
for tag in postJsonObject['object']['tag']:
|
postJsonObject=loadJson(postFilename)
|
||||||
if not tag.get('type'):
|
if not postJsonObject:
|
||||||
|
continue
|
||||||
|
if not postJsonObject.get('object'):
|
||||||
|
continue
|
||||||
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
continue
|
||||||
|
if not postJsonObject['object'].get('tag'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for tag in postJsonObject['object']['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
|
continue
|
||||||
if tag['type']!='Event' and tag['type']!='Place':
|
eventTime= \
|
||||||
continue
|
datetime.strptime(tag['startTime'], \
|
||||||
if tag['type']=='Event':
|
"%Y-%m-%dT%H:%M:%S%z")
|
||||||
# tag is an event
|
if int(eventTime.strftime("%Y"))==year and \
|
||||||
if not tag.get('startTime'):
|
int(eventTime.strftime("%m"))==monthNumber and \
|
||||||
continue
|
int(eventTime.strftime("%d"))==dayNumber:
|
||||||
eventTime= \
|
eventsExist=True
|
||||||
datetime.strptime(tag['startTime'], \
|
break
|
||||||
"%Y-%m-%dT%H:%M:%S%z")
|
|
||||||
if int(eventTime.strftime("%Y"))==year and \
|
|
||||||
int(eventTime.strftime("%m"))==monthNumber and \
|
|
||||||
int(eventTime.strftime("%d"))==dayNumber:
|
|
||||||
eventsExist=True
|
|
||||||
break
|
|
||||||
|
|
||||||
return eventsExist
|
return eventsExist
|
||||||
|
|
||||||
|
@ -167,35 +170,37 @@ def thisWeeksEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
|
||||||
for postId in eventsFile:
|
for postId in eventsFile:
|
||||||
postId=postId.replace('\n','')
|
postId=postId.replace('\n','')
|
||||||
postFilename=locatePost(baseDir,nickname,domain,postId)
|
postFilename=locatePost(baseDir,nickname,domain,postId)
|
||||||
if postFilename:
|
if not postFilename:
|
||||||
postJsonObject=loadJson(postFilename)
|
continue
|
||||||
if not postJsonObject:
|
|
||||||
continue
|
|
||||||
if not postJsonObject.get('object'):
|
|
||||||
continue
|
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
|
||||||
continue
|
|
||||||
if not postJsonObject['object'].get('tag'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
for tag in postJsonObject['object']['tag']:
|
postJsonObject=loadJson(postFilename)
|
||||||
if not tag.get('type'):
|
if not postJsonObject:
|
||||||
|
continue
|
||||||
|
if not postJsonObject.get('object'):
|
||||||
|
continue
|
||||||
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
continue
|
||||||
|
if not postJsonObject['object'].get('tag'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for tag in postJsonObject['object']['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
|
continue
|
||||||
if tag['type']!='Event' and tag['type']!='Place':
|
eventTime= \
|
||||||
continue
|
datetime.strptime(tag['startTime'], \
|
||||||
if tag['type']=='Event':
|
"%Y-%m-%dT%H:%M:%S%z")
|
||||||
# tag is an event
|
if int(eventTime.strftime("%Y"))==year and \
|
||||||
if not tag.get('startTime'):
|
int(eventTime.strftime("%m"))==monthNumber and \
|
||||||
continue
|
(int(eventTime.strftime("%d"))>dayNumber and \
|
||||||
eventTime= \
|
int(eventTime.strftime("%d"))<=dayNumber+6):
|
||||||
datetime.strptime(tag['startTime'], \
|
eventsExist=True
|
||||||
"%Y-%m-%dT%H:%M:%S%z")
|
break
|
||||||
if int(eventTime.strftime("%Y"))==year and \
|
|
||||||
int(eventTime.strftime("%m"))==monthNumber and \
|
|
||||||
(int(eventTime.strftime("%d"))>dayNumber and \
|
|
||||||
int(eventTime.strftime("%d"))<=dayNumber+6):
|
|
||||||
eventsExist=True
|
|
||||||
break
|
|
||||||
|
|
||||||
return eventsExist
|
return eventsExist
|
||||||
|
|
||||||
|
@ -225,47 +230,48 @@ def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
|
||||||
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)
|
|
||||||
if not postJsonObject:
|
|
||||||
continue
|
|
||||||
if not postJsonObject.get('object'):
|
|
||||||
continue
|
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
|
||||||
continue
|
|
||||||
if not postJsonObject['object'].get('tag'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
postEvent=[]
|
postJsonObject=loadJson(postFilename)
|
||||||
dayOfMonth=None
|
if not postJsonObject:
|
||||||
weekDayIndex=None
|
continue
|
||||||
for tag in postJsonObject['object']['tag']:
|
if not postJsonObject.get('object'):
|
||||||
if not tag.get('type'):
|
continue
|
||||||
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
continue
|
||||||
|
if not postJsonObject['object'].get('tag'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
postEvent=[]
|
||||||
|
dayOfMonth=None
|
||||||
|
weekDayIndex=None
|
||||||
|
for tag in postJsonObject['object']['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
|
continue
|
||||||
if tag['type']!='Event' and tag['type']!='Place':
|
eventTime= \
|
||||||
continue
|
datetime.strptime(tag['startTime'], \
|
||||||
if tag['type']=='Event':
|
"%Y-%m-%dT%H:%M:%S%z")
|
||||||
# tag is an event
|
if int(eventTime.strftime("%Y"))==year and \
|
||||||
if not tag.get('startTime'):
|
int(eventTime.strftime("%m"))==monthNumber and \
|
||||||
continue
|
(int(eventTime.strftime("%d"))>=dayNumber and \
|
||||||
eventTime= \
|
int(eventTime.strftime("%d"))<=dayNumber+6):
|
||||||
datetime.strptime(tag['startTime'], \
|
dayOfMonth=str(int(eventTime.strftime("%d")))
|
||||||
"%Y-%m-%dT%H:%M:%S%z")
|
weekDayIndex=dayOfMonth-dayNumber
|
||||||
if int(eventTime.strftime("%Y"))==year and \
|
|
||||||
int(eventTime.strftime("%m"))==monthNumber and \
|
|
||||||
(int(eventTime.strftime("%d"))>=dayNumber and \
|
|
||||||
int(eventTime.strftime("%d"))<=dayNumber+6):
|
|
||||||
dayOfMonth=str(int(eventTime.strftime("%d")))
|
|
||||||
weekDayIndex=dayOfMonth-dayNumber
|
|
||||||
postEvent.append(tag)
|
|
||||||
else:
|
|
||||||
# tag is a place
|
|
||||||
postEvent.append(tag)
|
postEvent.append(tag)
|
||||||
if postEvent and weekDayIndex:
|
else:
|
||||||
calendarPostIds.append(postId)
|
# tag is a place
|
||||||
if not events.get(dayOfMonth):
|
postEvent.append(tag)
|
||||||
events[weekDayIndex]=[]
|
if postEvent and weekDayIndex:
|
||||||
events[dayOfMonth].append(postEvent)
|
calendarPostIds.append(postId)
|
||||||
|
if not events.get(dayOfMonth):
|
||||||
|
events[weekDayIndex]=[]
|
||||||
|
events[dayOfMonth].append(postEvent)
|
||||||
|
|
||||||
# if some posts have been deleted then regenerate the calendar file
|
# if some posts have been deleted then regenerate the calendar file
|
||||||
if recreateEventsFile:
|
if recreateEventsFile:
|
||||||
|
|
Loading…
Reference in New Issue