From 82b734d1a8d5fc0ada3fd10e631f8c20357505e5 Mon Sep 17 00:00:00 2001 From: Ian Adam Naval Date: Mon, 21 Jan 2019 22:13:59 -0500 Subject: [PATCH] Add basic event summary and description Summary is the title of the event in your calendar, so we want it to be a little less verbose. --- autopilot/ical.py | 1 + autopilot/reservation.py | 10 +++++++++- autopilot/scrape.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/autopilot/ical.py b/autopilot/ical.py index 9b42278..3b61836 100644 --- a/autopilot/ical.py +++ b/autopilot/ical.py @@ -13,6 +13,7 @@ def add_vevent(cal: VCalendar2_0, reservation: Reservation): vevent.add('dtstart').value = reservation.start vevent.add('dtend').value = reservation.end vevent.add('summary').value = reservation.summary + vevent.add('description').value = reservation.description return cal diff --git a/autopilot/reservation.py b/autopilot/reservation.py index d232344..4805000 100644 --- a/autopilot/reservation.py +++ b/autopilot/reservation.py @@ -14,4 +14,12 @@ class Reservation(object): start: pendulum.DateTime end: pendulum.DateTime comments: str - summary: str + raw: str + + @property + def summary(self): + return f"Flying {self.aircraft} with {self.instructor}" + + @property + def description(self): + return self.raw diff --git a/autopilot/scrape.py b/autopilot/scrape.py index 00a58a8..6cf0c31 100644 --- a/autopilot/scrape.py +++ b/autopilot/scrape.py @@ -90,7 +90,7 @@ def make_reservation_from_tag(tag: Tag) -> Reservation: strict=False, tz=config.TIME_ZONE) attributes[datetime_attr] = parsed_datetime - attributes['summary'] = raw + attributes['raw'] = raw.replace('\r', '').replace('\t', '') return Reservation(**attributes)