Fixed issues and print useful info
This commit is contained in:
parent
0f19dc902d
commit
2857556170
1 changed files with 8 additions and 6 deletions
12
parser.py
12
parser.py
|
@ -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
|
||||||
|
else:
|
||||||
|
for key in ['dtstart', 'dtend']:
|
||||||
|
if icev.subcomponents[1][key].to_ical() != self.event[key].to_ical():
|
||||||
ex = False
|
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():
|
||||||
|
|
Reference in a new issue