Divided raw and normal methods for stops
This commit is contained in:
@@ -16,7 +16,6 @@ def stop_by_coords(accessId: str,
|
||||
originCoordLong: Union[str, float],
|
||||
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "en",
|
||||
json: bool = True,
|
||||
raw_response: bool = False,
|
||||
radius: Union[int, float] = 1000,
|
||||
maxNo: int = 10,
|
||||
stopType: Literal["S", "P", "SP", "SE", "SPE"] = "S",
|
||||
@@ -25,7 +24,7 @@ def stop_by_coords(accessId: str,
|
||||
meta: str = None, # type: ignore
|
||||
sattributes: Union[str, list] = None, # type: ignore
|
||||
sinfotexts: Union[str, list] = None # type: ignore
|
||||
) -> Union[dict, List[Stop]]:
|
||||
) -> dict:
|
||||
"""The location.nearbystops service returns a list of stops around a given center coordinate (within a
|
||||
radius of 1000m). The returned results are ordered by their distance to the center coordinate.
|
||||
|
||||
@@ -37,7 +36,6 @@ def stop_by_coords(accessId: str,
|
||||
* originCoordLong (Union[str, float]): Longitude of centre coordinate.
|
||||
* 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[Stop]`. Defaults to False.
|
||||
* radius (Union[int, float], optional): Search radius in meter around the given coordinate if any. Defaults to 1000.
|
||||
* maxNo (int, optional): Maximum number of returned stops. Defaults to 10.
|
||||
* stopType (Literal["S", "P", "SP", "SE", "SPE"], optional): Type filter for location types. Defaults to "S".
|
||||
@@ -67,16 +65,7 @@ def stop_by_coords(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:
|
||||
stops = []
|
||||
for stop in output.json()["stopLocationOrCoordLocation"]:
|
||||
if "StopLocation" in stop:
|
||||
stops.append(Stop(stop["StopLocation"]))
|
||||
elif "CoordLocation" in stop:
|
||||
stops.append(Stop(stop["CoordLocation"]))
|
||||
return stops
|
||||
return xmlparse(output.content)
|
@@ -15,7 +15,6 @@ def stop_by_name(accessId: str,
|
||||
inputString: str,
|
||||
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "en",
|
||||
json: bool = True,
|
||||
raw_response: bool = False,
|
||||
maxNo: int = 10,
|
||||
stopType: Literal["A", "ALL", "AP", "P", "S", "SA", "SP"] = "ALL",
|
||||
locationSelectionMode: Literal["SLCT_N", "SLCT_A"] = None, # type: ignore
|
||||
@@ -28,7 +27,7 @@ def stop_by_name(accessId: str,
|
||||
stations: Union[str, list] = None, # type: ignore
|
||||
sattributes: Union[str, list] = None, # type: ignore
|
||||
filterMode: Literal["DIST_PERI", "EXCL_PERI", "SLCT_PERI"] = "DIST_PERI"
|
||||
) -> Union[dict, List[Stop]]:
|
||||
) -> dict:
|
||||
"""The location.name service can be used to perform a pattern matching of a user input and to retrieve a list
|
||||
of possible matches in the journey planner database. Possible matches might be stops/stations, points of
|
||||
interest and addresses.
|
||||
@@ -44,7 +43,6 @@ def stop_by_name(accessId: str,
|
||||
* inputString (str): Search for that token.
|
||||
* 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[Stop]`. Defaults to False.
|
||||
* maxNo (int, optional): Maximum number of returned stops. In range 1-1000. Defaults to 10.
|
||||
* stopType (Literal["A", "ALL", "AP", "P", "S", "SA", "SP"], optional): Type filter for location types. Defaults to "ALL".
|
||||
* locationSelectionMode (str, optional): Selection mode for locations. "SLCT_N": Not selectable, "SLCT_A": Selectable. Defaults to None.
|
||||
@@ -81,16 +79,7 @@ def stop_by_name(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:
|
||||
stops = []
|
||||
for stop in output.json()["stopLocationOrCoordLocation"]:
|
||||
if "StopLocation" in stop:
|
||||
stops.append(Stop(stop["StopLocation"]))
|
||||
elif "CoordLocation" in stop:
|
||||
stops.append(Stop(stop["CoordLocation"]))
|
||||
return stops
|
||||
return xmlparse(output.content)
|
Reference in New Issue
Block a user