From 24a80dff35e3aea9099241a5e40da26ab79fbe18 Mon Sep 17 00:00:00 2001 From: Klafyvel Date: Mon, 18 Dec 2017 18:52:43 +0100 Subject: [PATCH] PEP8 --- main.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index eab7b97..39bab15 100644 --- a/main.py +++ b/main.py @@ -53,7 +53,7 @@ else: if not os.path.exists(DATA_DIR): os.makedirs(DATA_DIR) -##### Logger stuff ##### +# Logger stuff logger = logging.getLogger() @@ -80,8 +80,6 @@ if DEBUG: stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) -######################## - TIMEDELTA_SYNCHRO = datetime.timedelta(days=15) # Number of days to look for # for synchronization @@ -93,6 +91,7 @@ SCOPES = 'https://www.googleapis.com/auth/calendar' CLIENT_SECRET_FILE = 'client_secret.json' APPLICATION_NAME = 'Google Calendar API Python Quickstart' + class Event: """ The event class allows a simple convertion between `icalendar.cal.Event` @@ -172,7 +171,7 @@ def get_ntnoe(): """Retrieves the calendar on NTNOE.""" r = requests.post( "https://ntnoe.metz.supelec.fr/ical/index.php", - data={"envoyer":"Utf8_All","submit":"G%E9n%E9rer"}, + data={"envoyer": "Utf8_All", "submit": "G%E9n%E9rer"}, auth=(NTNOE_ID, NTNOE_PASS), ) @@ -181,6 +180,7 @@ def get_ntnoe(): r = requests.get(url, auth=(NTNOE_ID, NTNOE_PASS)) return r.content + def main(): """Get the events on NTNOE the puts them on Google Calendar. """ @@ -206,15 +206,14 @@ def main(): if not ntnoe_calendar_id: logger.info("Creating `ntnoe` calendar...") created = service.calendars().insert(body={ - 'defaultReminders' : [], - 'selected' : True, - 'summary' : 'ntnoe', + 'defaultReminders': [], + 'selected': True, + 'summary': 'ntnoe', }).execute() ntnoe_calendar_id = created['id'] now = datetime.datetime.now() 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. logger.info('Deleting former events.') @@ -232,12 +231,6 @@ def main(): logger.info('Adding new events.') for e in ical.walk('VEVENT'): event = Event(e) - t = ( - event.summary, - event.start.isoformat(), - event.end.isoformat(), - event.location - ) if now >= event.end or event.start >= then: continue