PythonRMV/pyrmv/classes/Leg.py

20 lines
672 B
Python
Raw Normal View History

2022-09-23 23:58:45 +03:00
from pyrmv.classes.Gis import Gis
from pyrmv.classes.Stop import StopTrip
from isodate import parse_duration
class Leg():
def __init__(self, data: dict):
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"]
self.duration = parse_duration(data["duration"])
if "dist" in data:
self.distance = data["dist"]
else:
self.distance = None