raw.trip_find and trip_find are now different

This commit is contained in:
Profitroll
2022-09-24 12:58:13 +02:00
parent 428442d1cb
commit 9641a4dab8
4 changed files with 200 additions and 13 deletions

View File

@@ -15,7 +15,6 @@ except ImportError:
def trip_find(accessId: str,
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "en",
json: bool = True,
raw_response: bool = False,
originId: str = None, # type: ignore
originExtId: str = None, # type: ignore
@@ -125,7 +124,7 @@ def trip_find(accessId: str,
trafficMessages: bool = False,
travellerProfileData: str = None, # type: ignore
withFreq: bool = True
) -> Union[dict, List[Trip]]:
) -> dict:
"""The trip service calculates a trip from a specified origin to a specified destination. These might be
stop/station IDs or coordinates based on addresses and points of interest validated by the location service or
coordinates freely defined by the client.
@@ -136,7 +135,6 @@ def trip_find(accessId: str,
* accessId (str): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
* lang (Literal["de","da","en","es","fr","hu","it","nl","no","pl","sv","tr"], optional): The language of response. Defaults to "en".
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Only matters if raw_response is True. Defaults to True.
* raw_response (bool, optional): Whether response should be returned as `dict` instead of `List[Trip]`. Defaults to False.
* originId (str, optional): Specifies the station/stop ID of the origin for the trip. Such ID can be retrieved from stopByName() or stopByCoords(). Defaults to None.
* originExtId (str, optional): Deprecated. Please use originId as it supports external IDs. Specifies the external station/stop ID of the origin for the trip. Such ID can be retrieved from stopByName() or stopByCoords(). Defaults to None.
* originCoordLat (Union[str, float], optional): Latitude of station/stop coordinate of the trip's origin. The coordinate can be retrieved from stopByName() or stopByCoords(). Defaults to None.
@@ -252,13 +250,7 @@ def trip_find(accessId: str,
find_exception(output.json())
if raw_response:
if json:
return output.json()
else:
return xmlparse(output.content)
if json:
return output.json()
else:
trips = []
for trip in output.json()["Trip"]:
trips.append(Trip(trip))
return trips
return xmlparse(output.content)