diff --git a/pyrmv/classes/Client.py b/pyrmv/classes/Client.py index a8fc61d..a625026 100644 --- a/pyrmv/classes/Client.py +++ b/pyrmv/classes/Client.py @@ -301,8 +301,9 @@ class Client(): find_exception(messages_raw) - for message in messages_raw["Message"]: - messages.append(Message(message)) + if "Message" in messages_raw: + for message in messages_raw["Message"]: + messages.append(Message(message)) return messages @@ -402,11 +403,12 @@ class Client(): find_exception(stops_raw) - for stop in stops_raw["stopLocationOrCoordLocation"]: - if "StopLocation" in stop: - stops.append(Stop(stop["StopLocation"])) - elif "CoordLocation" in stop: - stops.append(Stop(stop["CoordLocation"])) + if "stopLocationOrCoordLocation" in stops_raw: + for stop in stops_raw["stopLocationOrCoordLocation"]: + if "StopLocation" in stop: + stops.append(Stop(stop["StopLocation"])) + elif "CoordLocation" in stop: + stops.append(Stop(stop["CoordLocation"])) return stops @@ -504,11 +506,12 @@ class Client(): find_exception(stops_raw) - for stop in stops_raw["stopLocationOrCoordLocation"]: - if "StopLocation" in stop: - stops.append(Stop(stop["StopLocation"])) - elif "CoordLocation" in stop: - stops.append(Stop(stop["CoordLocation"])) + if "stopLocationOrCoordLocation" in stops_raw: + for stop in stops_raw["stopLocationOrCoordLocation"]: + if "StopLocation" in stop: + stops.append(Stop(stop["StopLocation"])) + elif "CoordLocation" in stop: + stops.append(Stop(stop["CoordLocation"])) return stops @@ -697,8 +700,9 @@ class Client(): find_exception(trips_raw) - for trip in trips_raw["Trip"]: - trips.append(Trip(trip)) + if "Trip" in trips_raw: + for trip in trips_raw["Trip"]: + trips.append(Trip(trip)) return trips @@ -770,7 +774,8 @@ class Client(): find_exception(trips_raw) - for trip in trips_raw["Trip"]: - trips.append(Trip(trip)) + if "Trip" in trips_raw: + for trip in trips_raw["Trip"]: + trips.append(Trip(trip)) return trips \ No newline at end of file