Compare commits
3 Commits
8cb28e9030
...
428442d1cb
Author | SHA1 | Date | |
---|---|---|---|
|
428442d1cb | ||
|
0bbda88433 | ||
|
deb49e174b |
@ -3,6 +3,7 @@ from isodate import parse_duration
|
||||
class Gis():
|
||||
|
||||
def __init__(self, ref: str, route: dict):
|
||||
|
||||
self.ref = ref
|
||||
self.dist = route["dist"]
|
||||
self.duration = parse_duration(route["durS"])
|
||||
|
@ -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"]
|
||||
|
@ -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"]
|
||||
|
@ -4,6 +4,7 @@ from datetime import datetime
|
||||
class Stop():
|
||||
|
||||
def __init__(self, data: dict):
|
||||
|
||||
self.name = data["name"]
|
||||
self.id = data["id"]
|
||||
if "extId" in data:
|
||||
@ -13,29 +14,17 @@ class Stop():
|
||||
self.lon = data["lon"]
|
||||
self.lat = data["lat"]
|
||||
|
||||
def get_id(self) -> str:
|
||||
if self.id != None:
|
||||
return self.id
|
||||
elif self.ext_id != None:
|
||||
return self.ext_id
|
||||
elif self.name != None:
|
||||
return self.name
|
||||
else:
|
||||
return f"{self.lon}, {self.lat}"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Stop {self.name} at {self.lon}, {self.lat}"
|
||||
|
||||
class StopTrip(Stop):
|
||||
|
||||
def __init__(self, data: dict):
|
||||
|
||||
self.type = data["type"]
|
||||
self.date = datetime.strptime(data["date"], "%Y-%m-%d")
|
||||
self.time = datetime.strptime(data["time"], "%H:%M:%S")
|
||||
super().__init__(data)
|
||||
|
||||
def get_id(self) -> str:
|
||||
return super().get_id()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Stop {self.name} at {self.lon}, {self.lat} at {self.time.time()} {self.date.date()}"
|
@ -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"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user