PythonRMV/src/pyrmv/classes/Journey.py
profitroll 9282578788
Some checks failed
Tests / test (3.10) (push) Failing after 1m10s
Tests / test (3.7) (push) Has been cancelled
Tests / test (3.8) (push) Has been cancelled
Tests / test (3.9) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Structural changes
2023-11-19 22:38:51 +01:00

22 lines
793 B
Python

from pyrmv.classes.Stop import Stop
from pyrmv.classes.Message import Message
class Journey():
"""Journey object."""
def __init__(self, data: dict):
self.stops = []
self.ref = data["ref"]
self.direction = data["Directions"]["Direction"][0]["value"]
self.direction_flag = data["Directions"]["Direction"][0]["flag"]
self.messages = []
self.stops.extend(Stop(stop) for stop in data["Stops"]["Stop"])
if "Messages" in data:
self.messages.extend(
Message(message) for message in data["Messages"]["Message"]
)
def __str__(self) -> str:
return f"Journey with total of {len(self.stops)} stops and {len(self.messages)} messages heading {self.direction} ({self.direction_flag})"