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)
try:
print(self.event['uid'])
ev = self.calendar.event_by_uid(self.event['uid'])
except caldav.lib.error.NotFoundError:
ev = None
if ev:
icev = Calendar.from_ical(ev.data)
ex = True
for key in ['summary', 'dtstart', 'dtend']:
if icev.subcomponents[1][key] != self.event[key]:
if icev.subcomponents[1]['summary'] != self.event['summary']:
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
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.save()
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'))
elif tag == 'tr':
for mr in self.multirows.values():