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
def title(self) -> str:
"""Trip title."""
return (
format_list_with_ampersand(
[conf["name"] for conf in self.conferences]
+ [event["title"] for event in self.events]
)
or "[unnamed trip]"
)
titles: list[str] = [conf["name"] for conf in self.conferences] + [
event["title"] for event in self.events
]
if not titles:
for travel in self.travel:
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
def end(self) -> datetime.date | None: