Classes restructure
Some checks failed
Tests / test (3.10) (push) Failing after 1m10s
Tests / test (3.11) (push) Failing after 1m7s
Tests / test (3.8) (push) Failing after 1m11s
Tests / test (3.9) (push) Has been cancelled

This commit is contained in:
2023-11-24 12:39:25 +01:00
parent 3a65991257
commit c4b7197267
12 changed files with 20 additions and 20 deletions

29
src/pyrmv/classes/leg.py Normal file
View File

@@ -0,0 +1,29 @@
from typing import Any, Mapping
from isodate import parse_duration
from pyrmv.classes.gis import Gis
from pyrmv.classes.message import Message
from pyrmv.classes.stop import StopTrip
class Leg:
"""Trip leg object."""
def __init__(self, data: Mapping[str, Any]):
self.origin = StopTrip(data["Origin"])
self.destination = StopTrip(data["Destination"])
self.gis = (
None if "GisRef" not in data else Gis(data["GisRef"]["ref"], data["GisRoute"])
)
self.messages = []
self.index = data["idx"]
self.name = data["name"]
self.type = data["type"]
self.direction = data.get("direction")
self.number = data.get("number")
self.duration = parse_duration(data["duration"])
self.distance = data.get("dist")
if "Messages" in data:
self.messages.extend(Message(message) for message in data["Messages"]["Message"])