Empty attributes now return list instead of None
This commit is contained in:
parent
8cb28e9030
commit
deb49e174b
@ -9,10 +9,12 @@ class Leg():
|
|||||||
|
|
||||||
self.origin = StopTrip(data["Origin"])
|
self.origin = StopTrip(data["Origin"])
|
||||||
self.destination = StopTrip(data["Destination"])
|
self.destination = StopTrip(data["Destination"])
|
||||||
|
|
||||||
if "GisRef" in data:
|
if "GisRef" in data:
|
||||||
self.gis = Gis(data["GisRef"]["ref"], data["GisRoute"])
|
self.gis = Gis(data["GisRef"]["ref"], data["GisRoute"])
|
||||||
else:
|
else:
|
||||||
self.gis = None
|
self.gis = None
|
||||||
|
|
||||||
self.index = data["idx"]
|
self.index = data["idx"]
|
||||||
self.name = data["name"]
|
self.name = data["name"]
|
||||||
self.type = data["type"]
|
self.type = data["type"]
|
||||||
@ -22,13 +24,9 @@ class Leg():
|
|||||||
else:
|
else:
|
||||||
self.direction = None
|
self.direction = None
|
||||||
|
|
||||||
if "Messages" in data:
|
self.messages = []
|
||||||
messages = []
|
for message in data["Messages"]["Message"]:
|
||||||
for message in data["Messages"]["Message"]:
|
self.messages.append(Message(message))
|
||||||
messages.append(Message(message))
|
|
||||||
self.messages = messages
|
|
||||||
else:
|
|
||||||
self.messages = None
|
|
||||||
|
|
||||||
if "number" in data:
|
if "number" in data:
|
||||||
self.number = data["number"]
|
self.number = data["number"]
|
||||||
|
@ -32,18 +32,16 @@ class Message():
|
|||||||
|
|
||||||
def __init__(self, data: dict) -> None:
|
def __init__(self, data: dict) -> None:
|
||||||
|
|
||||||
affected_stops = []
|
self.affected_stops = []
|
||||||
for stop in data["affectedStops"]["StopLocation"]:
|
for stop in data["affectedStops"]["StopLocation"]:
|
||||||
affected_stops.append(Stop(stop))
|
self.affected_stops.append(Stop(stop))
|
||||||
self.affected_stops = affected_stops
|
|
||||||
|
|
||||||
self.valid_from_stop = Stop(data["validFromStop"])
|
self.valid_from_stop = Stop(data["validFromStop"])
|
||||||
self.valid_to_stop = Stop(data["validToStop"])
|
self.valid_to_stop = Stop(data["validToStop"])
|
||||||
|
|
||||||
channels = []
|
self.channels = []
|
||||||
for channel in data["channel"]:
|
for channel in data["channel"]:
|
||||||
channels.append(Channel(channel))
|
self.channels.append(Channel(channel))
|
||||||
self.channels = channels
|
|
||||||
|
|
||||||
self.id = data["id"]
|
self.id = data["id"]
|
||||||
self.active = data["act"]
|
self.active = data["act"]
|
||||||
|
@ -5,13 +5,15 @@ from isodate import parse_duration
|
|||||||
class Trip():
|
class Trip():
|
||||||
|
|
||||||
def __init__(self, data: dict):
|
def __init__(self, data: dict):
|
||||||
|
|
||||||
self.raw_data = data
|
self.raw_data = data
|
||||||
self.origin = StopTrip(data["Origin"])
|
self.origin = StopTrip(data["Origin"])
|
||||||
self.destination = StopTrip(data["Destination"])
|
self.destination = StopTrip(data["Destination"])
|
||||||
legs = []
|
|
||||||
|
self.legs = []
|
||||||
for leg in data["LegList"]["Leg"]:
|
for leg in data["LegList"]["Leg"]:
|
||||||
legs.append(Leg(leg))
|
self.legs.append(Leg(leg))
|
||||||
self.legs = legs
|
|
||||||
self.calculation = data["calculation"]
|
self.calculation = data["calculation"]
|
||||||
self.index = data["idx"]
|
self.index = data["idx"]
|
||||||
self.id = data["tripId"]
|
self.id = data["tripId"]
|
||||||
|
Loading…
Reference in New Issue
Block a user