diff --git a/pyrmv/classes/Leg.py b/pyrmv/classes/Leg.py index ae6ed56..f0c9a9e 100644 --- a/pyrmv/classes/Leg.py +++ b/pyrmv/classes/Leg.py @@ -9,10 +9,12 @@ class Leg(): self.origin = StopTrip(data["Origin"]) self.destination = StopTrip(data["Destination"]) + if "GisRef" in data: self.gis = Gis(data["GisRef"]["ref"], data["GisRoute"]) else: self.gis = None + self.index = data["idx"] self.name = data["name"] self.type = data["type"] @@ -22,13 +24,9 @@ class Leg(): else: self.direction = None - if "Messages" in data: - messages = [] - for message in data["Messages"]["Message"]: - messages.append(Message(message)) - self.messages = messages - else: - self.messages = None + self.messages = [] + for message in data["Messages"]["Message"]: + self.messages.append(Message(message)) if "number" in data: self.number = data["number"] diff --git a/pyrmv/classes/Message.py b/pyrmv/classes/Message.py index c6729a3..4d7ec98 100644 --- a/pyrmv/classes/Message.py +++ b/pyrmv/classes/Message.py @@ -32,18 +32,16 @@ class Message(): def __init__(self, data: dict) -> None: - affected_stops = [] + self.affected_stops = [] for stop in data["affectedStops"]["StopLocation"]: - affected_stops.append(Stop(stop)) - self.affected_stops = affected_stops + self.affected_stops.append(Stop(stop)) self.valid_from_stop = Stop(data["validFromStop"]) self.valid_to_stop = Stop(data["validToStop"]) - channels = [] + self.channels = [] for channel in data["channel"]: - channels.append(Channel(channel)) - self.channels = channels + self.channels.append(Channel(channel)) self.id = data["id"] self.active = data["act"] diff --git a/pyrmv/classes/Trip.py b/pyrmv/classes/Trip.py index eb35a3a..d6eced9 100644 --- a/pyrmv/classes/Trip.py +++ b/pyrmv/classes/Trip.py @@ -5,13 +5,15 @@ from isodate import parse_duration class Trip(): def __init__(self, data: dict): + self.raw_data = data self.origin = StopTrip(data["Origin"]) self.destination = StopTrip(data["Destination"]) - legs = [] + + self.legs = [] for leg in data["LegList"]["Leg"]: - legs.append(Leg(leg)) - self.legs = legs + self.legs.append(Leg(leg)) + self.calculation = data["calculation"] self.index = data["idx"] self.id = data["tripId"]