From f53aa32aefb755e3876831fa76677a9f16fc2ca0 Mon Sep 17 00:00:00 2001 From: LucaBarban <45258881+LucaBarban@users.noreply.github.com> Date: Wed, 21 Dec 2022 08:46:16 +0100 Subject: [PATCH] Fixing edgecase --- gcal.py | 7 ++++--- mycaldav.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gcal.py b/gcal.py index 4136372..f1bb104 100644 --- a/gcal.py +++ b/gcal.py @@ -73,7 +73,7 @@ def getFromGoogleCalendar(self) -> list[Lezione]: while (True): for event in events["items"]: try: - tmpAttività = event["description"].split(" ")[0] + tmpAttività = event["description"].split(" in ")[0] tmpGiorno = event["description"].split(" di ")[1].split(" con ")[0] tmpClasse = event["description"].split(" in ")[1].split(" di ")[0] tmpDocnote = event["description"].split(" con ")[1] @@ -85,9 +85,10 @@ def getFromGoogleCalendar(self) -> list[Lezione]: tmpTime = tmpTimeList[0] + ":" + tmpTimeList[1] + "-" tmpTimeList = event["end"]["dateTime"].split("T")[1].split(":") tmpTime += tmpTimeList[0] + ":" + tmpTimeList[1] - gCalendar.append(Lezione(event["summary"], tmpGiorno, tmpData, tmpAttività, tmpDocnote, event["location"], tmpClasse, tmpTime, event["id"])) + tmpLocation = "" if "location" not in event else event["location"] + gCalendar.append(Lezione(event["summary"], tmpGiorno, tmpData, tmpAttività, tmpDocnote, tmpLocation, tmpClasse, tmpTime, event["id"])) except Exception as e: - print("Error reading from google calendar on:", event, e) + print("Error reading from google calendar on:", event, "\nException:", e) exit() eventsNumber += len(events["items"]) diff --git a/mycaldav.py b/mycaldav.py index f52b3b0..d5d2ab8 100644 --- a/mycaldav.py +++ b/mycaldav.py @@ -37,7 +37,7 @@ def getEvents(): tuid = event event = event.vobject_instance.vevent tsummary = event.summary.value - tactivity = event.description.value.split(" ")[0] + tactivity = event.description.value.split(" in ")[0] tday = event.description.value.split(" di ")[1].split("con")[0] tclass = event.description.value.split(" in ")[1].split(" di ")[0] tlocation = event.location.value