flake8 format

main
Bob Mottram 2020-04-03 11:53:31 +00:00
parent 283a4d54c1
commit 34abcb54c2
1 changed files with 164 additions and 158 deletions

View File

@ -6,8 +6,6 @@ __maintainer__="Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
import json
import time
import os
from datetime import datetime
@ -16,6 +14,7 @@ from utils import locatePost
from utils import daysInMonth
from utils import mergeDicts
def isHappeningEvent(tag: {}) -> bool:
"""Is this tag an Event or Place ActivityStreams type?
"""
@ -25,6 +24,7 @@ def isHappeningEvent(tag: {}) -> bool:
return False
return True
def isHappeningPost(postJsonObject: {}) -> bool:
"""Is this a post with tags?
"""
@ -38,8 +38,9 @@ def isHappeningPost(postJsonObject: {}) -> bool:
return False
return True
def getTodaysEvents(baseDir: str,nickname: str,domain: str, \
currYear=None,currMonthNumber=None, \
def getTodaysEvents(baseDir: str, nickname: str, domain: str,
currYear=None, currMonthNumber=None,
currDayOfMonth=None) -> {}:
"""Retrieves calendar events for today
Returns a dictionary of lists containing Event and Place activities
@ -90,7 +91,7 @@ def getTodaysEvents(baseDir: str,nickname: str,domain: str, \
if not tag.get('startTime'):
continue
eventTime = \
datetime.strptime(tag['startTime'], \
datetime.strptime(tag['startTime'],
"%Y-%m-%dT%H:%M:%S%z")
if int(eventTime.strftime("%Y")) == year and \
int(eventTime.strftime("%m")) == monthNumber and \
@ -119,6 +120,7 @@ def getTodaysEvents(baseDir: str,nickname: str,domain: str, \
return events
def todaysEventsCheck(baseDir: str, nickname: str, domain: str) -> bool:
"""Are there calendar events today?
"""
@ -155,7 +157,7 @@ def todaysEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
if not tag.get('startTime'):
continue
eventTime = \
datetime.strptime(tag['startTime'], \
datetime.strptime(tag['startTime'],
"%Y-%m-%dT%H:%M:%S%z")
if int(eventTime.strftime("%Y")) == year and \
int(eventTime.strftime("%m")) == monthNumber and \
@ -165,6 +167,7 @@ def todaysEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
return eventsExist
def thisWeeksEventsCheck(baseDir: str, nickname: str, domain: str) -> bool:
"""Are there calendar events this week?
"""
@ -201,17 +204,18 @@ def thisWeeksEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
if not tag.get('startTime'):
continue
eventTime = \
datetime.strptime(tag['startTime'], \
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 and \
int(eventTime.strftime("%d"))<=dayNumber+6):
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
def getThisWeeksEvents(baseDir: str, nickname: str, domain: str) -> {}:
"""Retrieves calendar events for this week
Returns a dictionary indexed by day number of lists containing
@ -257,12 +261,12 @@ def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
if not tag.get('startTime'):
continue
eventTime = \
datetime.strptime(tag['startTime'], \
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 and \
int(eventTime.strftime("%d"))<=dayNumber+6):
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)
@ -290,7 +294,7 @@ def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
year += 1
for d in range(1, dayNumber + 6 - lastDayOfMonth):
dailyEvents = \
getTodaysEvents(baseDir,nickname,domain, \
getTodaysEvents(baseDir, nickname, domain,
year, monthNumber, d)
if dailyEvents:
if dailyEvents.get(d):
@ -301,7 +305,8 @@ def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
return events
def getCalendarEvents(baseDir: str,nickname: str,domain: str, \
def getCalendarEvents(baseDir: str, nickname: str, domain: str,
year: int, monthNumber: int) -> {}:
"""Retrieves calendar events
Returns a dictionary indexed by day number of lists containing
@ -340,7 +345,7 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str, \
if not tag.get('startTime'):
continue
eventTime = \
datetime.strptime(tag['startTime'], \
datetime.strptime(tag['startTime'],
"%Y-%m-%dT%H:%M:%S%z")
if int(eventTime.strftime("%Y")) == year and \
int(eventTime.strftime("%m")) == monthNumber:
@ -365,7 +370,8 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str, \
return events
def removeCalendarEvent(baseDir: str,nickname: str,domain: str, \
def removeCalendarEvent(baseDir: str, nickname: str, domain: str,
year: int, monthNumber: int, messageId: str) -> None:
"""Removes a calendar event
"""