Skip to content
Snippets Groups Projects
Verified Commit 9490ab01 authored by Marco Aceti's avatar Marco Aceti
Browse files

Handle empty station_ori_name

Sometimes Trenord does not fill this field
parent 703f0b42
No related branches found
No related tags found
No related merge requests found
Pipeline #2674 passed
......@@ -168,8 +168,8 @@ class Train:
# Assertion: there should always be at least two stops - the first and the last.
assert len(self.stops) >= 2
# API bug: sometimes, the last stop is not marked as last
logging.warning(f"{self.category} {self.number} has not a last stop.")
# API bug: often, the last stop is not marked as last
logging.debug(f"{self.category} {self.number} has not a last stop.")
if len(list(filter(lambda s: s.stop_type == tr_st.TrainStopType.LAST, self.stops))) == 0: # fmt: skip
i = len(self.stops) - 1
while i > 0:
......
......@@ -203,7 +203,7 @@ class TrainStop:
)
assert isinstance(station_code, str) and len(station_code) > 0
station = st.Station.by_code(station_code)
if station._phantom:
if station._phantom and stop_data.get("station", {}).get("station_ori_name"):
station.name = stop_data["station"]["station_ori_name"].title().strip()
stop_type: TrainStopType
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment