From bdbca9bbc3f17e9f6a8f64ff99347a456f8f03a2 Mon Sep 17 00:00:00 2001 From: edpibu Date: Mon, 21 Sep 2020 07:49:26 +0200 Subject: [PATCH] Fixed data issue --- parser.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/parser.py b/parser.py index bfd656d..cf2ef5c 100755 --- a/parser.py +++ b/parser.py @@ -45,6 +45,8 @@ class GoogleSheetsCalParser(HTMLParser): self.rowspan = 0 self.multirows = {} self.date = {} + self.event = Event() + self.event['uid'] = 0 import priv @@ -106,16 +108,19 @@ class GoogleSheetsCalParser(HTMLParser): cal = Calendar() cal.add('prodid', '-//edpibu//edt-parser//FR') cal.add('version', '2.0') - event = Event() - event.add('uid', f'{self.row}x{self.column}') - event.add('summary', data) - event.add('dtstamp', dt.now()) - print(self.row, self.column, times) - event.add('dtstart', dt.combine(self.date[self.column], times[0], - pytz.timezone('Europe/Paris'))) - event.add('dtend', dt.combine(self.date[self.column], times[1], - pytz.timezone('Europe/Paris'))) - cal.add_component(event) + if self.event['uid'] == f'{self.row}x{self.column}': + self.event['summary'] = f'{self.event["summary"]} {data}' + else: + self.event = Event() + self.event.add('uid', f'{self.row}x{self.column}') + self.event.add('summary', data) + self.event.add('dtstamp', dt.now()) + print(self.row, self.column, times) + self.event.add('dtstart', dt.combine(self.date[self.column], times[0], + pytz.timezone('Europe/Paris'))) + self.event.add('dtend', dt.combine(self.date[self.column], times[1], + pytz.timezone('Europe/Paris'))) + cal.add_component(self.event) self.calendar.save_event(cal.to_ical().decode('utf-8'))