PEP8
This commit is contained in:
parent
dc5ce1186f
commit
24a80dff35
1 changed files with 7 additions and 14 deletions
13
main.py
13
main.py
|
@ -53,7 +53,7 @@ else:
|
||||||
if not os.path.exists(DATA_DIR):
|
if not os.path.exists(DATA_DIR):
|
||||||
os.makedirs(DATA_DIR)
|
os.makedirs(DATA_DIR)
|
||||||
|
|
||||||
##### Logger stuff #####
|
# Logger stuff
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
@ -80,8 +80,6 @@ if DEBUG:
|
||||||
stream_handler.setFormatter(formatter)
|
stream_handler.setFormatter(formatter)
|
||||||
logger.addHandler(stream_handler)
|
logger.addHandler(stream_handler)
|
||||||
|
|
||||||
########################
|
|
||||||
|
|
||||||
|
|
||||||
TIMEDELTA_SYNCHRO = datetime.timedelta(days=15) # Number of days to look for
|
TIMEDELTA_SYNCHRO = datetime.timedelta(days=15) # Number of days to look for
|
||||||
# for synchronization
|
# for synchronization
|
||||||
|
@ -93,6 +91,7 @@ SCOPES = 'https://www.googleapis.com/auth/calendar'
|
||||||
CLIENT_SECRET_FILE = 'client_secret.json'
|
CLIENT_SECRET_FILE = 'client_secret.json'
|
||||||
APPLICATION_NAME = 'Google Calendar API Python Quickstart'
|
APPLICATION_NAME = 'Google Calendar API Python Quickstart'
|
||||||
|
|
||||||
|
|
||||||
class Event:
|
class Event:
|
||||||
"""
|
"""
|
||||||
The event class allows a simple convertion between `icalendar.cal.Event`
|
The event class allows a simple convertion between `icalendar.cal.Event`
|
||||||
|
@ -181,6 +180,7 @@ def get_ntnoe():
|
||||||
r = requests.get(url, auth=(NTNOE_ID, NTNOE_PASS))
|
r = requests.get(url, auth=(NTNOE_ID, NTNOE_PASS))
|
||||||
return r.content
|
return r.content
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Get the events on NTNOE the puts them on Google Calendar.
|
"""Get the events on NTNOE the puts them on Google Calendar.
|
||||||
"""
|
"""
|
||||||
|
@ -214,7 +214,6 @@ def main():
|
||||||
|
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
then = now + TIMEDELTA_SYNCHRO
|
then = now + TIMEDELTA_SYNCHRO
|
||||||
time_search = datetime.datetime(now.year, now.month, now.day, 1)
|
|
||||||
|
|
||||||
# NTNOE calendar often changes. So let's delete former synchronizations.
|
# NTNOE calendar often changes. So let's delete former synchronizations.
|
||||||
logger.info('Deleting former events.')
|
logger.info('Deleting former events.')
|
||||||
|
@ -232,12 +231,6 @@ def main():
|
||||||
logger.info('Adding new events.')
|
logger.info('Adding new events.')
|
||||||
for e in ical.walk('VEVENT'):
|
for e in ical.walk('VEVENT'):
|
||||||
event = Event(e)
|
event = Event(e)
|
||||||
t = (
|
|
||||||
event.summary,
|
|
||||||
event.start.isoformat(),
|
|
||||||
event.end.isoformat(),
|
|
||||||
event.location
|
|
||||||
)
|
|
||||||
if now >= event.end or event.start >= then:
|
if now >= event.end or event.start >= then:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue