Fixed issues and print useful info

This commit is contained in:
Edgar P. Burkhart 2020-10-03 18:14:11 +02:00
parent 0f19dc902d
commit 2857556170
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -100,23 +100,25 @@ class GoogleSheetsCalParser(HTMLParser):
cal.add_component(self.event) cal.add_component(self.event)
try: try:
print(self.event['uid'])
ev = self.calendar.event_by_uid(self.event['uid']) ev = self.calendar.event_by_uid(self.event['uid'])
except caldav.lib.error.NotFoundError: except caldav.lib.error.NotFoundError:
ev = None ev = None
if ev: if ev:
icev = Calendar.from_ical(ev.data) icev = Calendar.from_ical(ev.data)
ex = True ex = True
for key in ['summary', 'dtstart', 'dtend']: if icev.subcomponents[1]['summary'] != self.event['summary']:
if icev.subcomponents[1][key] != self.event[key]: ex = False
ex = False else:
for key in ['dtstart', 'dtend']:
if icev.subcomponents[1][key].to_ical() != self.event[key].to_ical():
ex = False
if ex: return if ex: return
print(f'Change on {self.event["dtstart"]}') print(f'Change on {self.event.decoded("dtstart").isoformat()}')
ev.data = cal.to_ical().decode('utf-8') ev.data = cal.to_ical().decode('utf-8')
ev.save() ev.save()
return return
print(f'New event on {self.event["dtstart"]}') print(f'New event on {self.event.decoded("dtstart").isoformat()}')
self.calendar.save_event(cal.to_ical().decode('utf-8')) self.calendar.save_event(cal.to_ical().decode('utf-8'))
elif tag == 'tr': elif tag == 'tr':
for mr in self.multirows.values(): for mr in self.multirows.values():