Generate trip titles from railway station names

This commit is contained in:
Edward Betts 2024-02-28 15:49:48 +00:00
parent 8f749c8e35
commit 5fdfd9d533

View file

@ -34,13 +34,21 @@ class Trip:
@property @property
def title(self) -> str: def title(self) -> str:
"""Trip title.""" """Trip title."""
return ( titles: list[str] = [conf["name"] for conf in self.conferences] + [
format_list_with_ampersand( event["title"] for event in self.events
[conf["name"] for conf in self.conferences] ]
+ [event["title"] for event in self.events] if not titles:
) for travel in self.travel:
or "[unnamed trip]" if travel["depart"] and travel["depart"].date() != self.start:
) place = travel["from"]
if place not in titles:
titles.append(place)
if travel["depart"] and travel["depart"].date() != self.end:
place = travel["to"]
if place not in titles:
titles.append(place)
return format_list_with_ampersand(titles) or "[unnamed trip]"
@property @property
def end(self) -> datetime.date | None: def end(self) -> datetime.date | None: