diff --git a/pyrmv/classes/Message.py b/pyrmv/classes/Message.py index d70008b..0dbb55d 100644 --- a/pyrmv/classes/Message.py +++ b/pyrmv/classes/Message.py @@ -36,11 +36,19 @@ class Message(): def __init__(self, data: dict) -> None: self.affected_stops = [] - for stop in data["affectedStops"]["StopLocation"]: - self.affected_stops.append(Stop(stop)) + if "affectedStops" in data: + for stop in data["affectedStops"]["StopLocation"]: + self.affected_stops.append(Stop(stop)) - self.valid_from_stop = Stop(data["validFromStop"]) - self.valid_to_stop = Stop(data["validToStop"]) + if "validFromStop" in data: + self.valid_from_stop = Stop(data["validFromStop"]) + else: + self.valid_from_stop = None + + if "validToStop" in data: + self.valid_to_stop = Stop(data["validToStop"]) + else: + self.valid_to_stop = None self.channels = [] for channel in data["channel"]: