diff --git a/agenda/trip.py b/agenda/trip.py index a3cc35c..fe49bdf 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -13,12 +13,6 @@ from agenda import travel from agenda.types import StrDict, Trip -class UnknownStation(Exception): - """Unknown station.""" - - pass - - def load_travel(travel_type: str, plural: str, data_dir: str) -> list[StrDict]: """Read flight and train journeys.""" items = travel.parse_yaml(plural, data_dir) @@ -27,18 +21,10 @@ def load_travel(travel_type: str, plural: str, data_dir: str) -> list[StrDict]: return items -def get_station(name: str, by_name: dict[str, StrDict]) -> StrDict: - """Get station by name.""" - try: - return by_name[name] - except IndexError: - raise UnknownStation(name) - - def add_station_objects(item: StrDict, by_name: dict[str, StrDict]) -> None: """Lookup stations and add to train or leg.""" - item["from_station"] = get_station(item["from"], by_name) - item["to_station"] = get_station(item["to"], by_name) + item["from_station"] = by_name[item["from"]] + item["to_station"] = by_name[item["to"]] def load_trains(