Compare commits

..

No commits in common. "85ebaf7c841806bf7562460e2e0552c8a26635d1" and "d5a92c9a8e2f9b9bc54ef1b30baf7fd4ba9e2ad4" have entirely different histories.

View file

@ -43,12 +43,6 @@ class TripElement:
detail: StrDict detail: StrDict
def airport_label(airport: StrDict) -> str:
"""Airport label: name and iata."""
name = airport.get("alt_name") or airport["city"]
return f"{name} ({airport['iata']})"
@dataclass @dataclass
class Trip: class Trip:
"""Trip.""" """Trip."""
@ -210,9 +204,12 @@ class Trip:
for item in self.travel: for item in self.travel:
if item["type"] == "flight": if item["type"] == "flight":
flight_from = item["from_airport"]
flight_to = item["to_airport"]
name = ( name = (
f"✈️ {airport_label(item['from_airport'])}" "✈️ "
+ f"{airport_label(item['to_airport'])}" + f"{flight_from['name']} ({flight_from['iata']}) -> "
+ f"{flight_to['name']} ({flight_to['iata']})"
) )
elements.append( elements.append(
@ -224,18 +221,17 @@ class Trip:
) )
) )
if item["type"] == "train": if item["type"] == "train":
for leg in item["legs"]: name = f"{item['from']} -> {item['to']}"
name = f"{leg['from']}{leg['to']}"
elements.append( elements.append(
TripElement( TripElement(
when=leg["depart"], when=item["depart"],
title=name, title=name,
detail=leg, detail=item,
element_type="train", element_type="train",
) )
) )
if item["type"] == "ferry": if item["type"] == "ferry":
name = f"{item['from']} {item['to']}" name = f"{item['from']} -> {item['to']}"
elements.append( elements.append(
TripElement( TripElement(
when=item["depart"], when=item["depart"],