find_exception is only used in normal methods now
This commit is contained in:
parent
e5a608ff14
commit
1c68772ed4
@ -4,6 +4,7 @@ from pyrmv.enums.location_type import LocationType
|
|||||||
from pyrmv.enums.lang import Language
|
from pyrmv.enums.lang import Language
|
||||||
from pyrmv.enums.selection_mode import SelectionMode
|
from pyrmv.enums.selection_mode import SelectionMode
|
||||||
from pyrmv.raw.stop_by_coords import stop_by_coords as raw_stop_by_coords
|
from pyrmv.raw.stop_by_coords import stop_by_coords as raw_stop_by_coords
|
||||||
|
from pyrmv.utility.find_exception import find_exception
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
@ -53,6 +54,8 @@ def stop_by_coords(
|
|||||||
locationSelectionMode=(selection_mode.code).upper()
|
locationSelectionMode=(selection_mode.code).upper()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_exception(stops_raw)
|
||||||
|
|
||||||
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
||||||
if "StopLocation" in stop:
|
if "StopLocation" in stop:
|
||||||
stops.append(Stop(stop["StopLocation"]))
|
stops.append(Stop(stop["StopLocation"]))
|
||||||
|
@ -5,6 +5,7 @@ from pyrmv.enums.lang import Language
|
|||||||
from pyrmv.enums.selection_mode import SelectionMode
|
from pyrmv.enums.selection_mode import SelectionMode
|
||||||
from pyrmv.enums.filter_mode import FilterMode
|
from pyrmv.enums.filter_mode import FilterMode
|
||||||
from pyrmv.raw.stop_by_name import stop_by_name as raw_stop_by_name
|
from pyrmv.raw.stop_by_name import stop_by_name as raw_stop_by_name
|
||||||
|
from pyrmv.utility.find_exception import find_exception
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
@ -64,9 +65,11 @@ def stop_by_name(
|
|||||||
radius=radius,
|
radius=radius,
|
||||||
refineId=refine_id,
|
refineId=refine_id,
|
||||||
stations=stations,
|
stations=stations,
|
||||||
filterMode=filter_mode
|
filterMode=filter_mode.code
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_exception(stops_raw)
|
||||||
|
|
||||||
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
||||||
if "StopLocation" in stop:
|
if "StopLocation" in stop:
|
||||||
stops.append(Stop(stop["StopLocation"]))
|
stops.append(Stop(stop["StopLocation"]))
|
||||||
|
@ -4,6 +4,7 @@ from pyrmv.classes.Trip import Trip
|
|||||||
from pyrmv.raw.trip_find import trip_find as raw_trip_find
|
from pyrmv.raw.trip_find import trip_find as raw_trip_find
|
||||||
from pyrmv.enums.rt_mode import RealTimeMode
|
from pyrmv.enums.rt_mode import RealTimeMode
|
||||||
from pyrmv.enums.lang import Language
|
from pyrmv.enums.lang import Language
|
||||||
|
from pyrmv.utility.find_exception import find_exception
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
@ -191,6 +192,8 @@ def trip_find(
|
|||||||
withFreq=frequency
|
withFreq=frequency
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_exception(trips_raw)
|
||||||
|
|
||||||
for trip in trips_raw["Trip"]:
|
for trip in trips_raw["Trip"]:
|
||||||
trips.append(Trip(trip))
|
trips.append(Trip(trip))
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ from typing import Dict, OrderedDict, Union
|
|||||||
from xmltodict import parse as xmlparse
|
from xmltodict import parse as xmlparse
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from pyrmv.utility.find_exception import find_exception
|
|
||||||
from pyrmv.utility.weekdays_bitmask import weekdays_bitmask
|
from pyrmv.utility.weekdays_bitmask import weekdays_bitmask
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -124,7 +123,9 @@ def him_search(accessId: str,
|
|||||||
|
|
||||||
output = get("https://www.rmv.de/hapi/himsearch", params=payload, headers=headers)
|
output = get("https://www.rmv.de/hapi/himsearch", params=payload, headers=headers)
|
||||||
|
|
||||||
find_exception(output.json())
|
# Exceptions checker moved to normal methods
|
||||||
|
# and exceptions will no longer raise in raw ones.
|
||||||
|
# find_exception(output.json())
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
return output.json()
|
return output.json()
|
||||||
|
@ -2,8 +2,6 @@ from requests import get
|
|||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
from xmltodict import parse as xmlparse
|
from xmltodict import parse as xmlparse
|
||||||
|
|
||||||
from pyrmv.utility.find_exception import find_exception
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -28,7 +26,9 @@ def journey_detail(accessId: str,
|
|||||||
|
|
||||||
output = get("https://www.rmv.de/hapi/journeyDetail", params=payload, headers=headers)
|
output = get("https://www.rmv.de/hapi/journeyDetail", params=payload, headers=headers)
|
||||||
|
|
||||||
find_exception(output.json())
|
# Exceptions checker moved to normal methods
|
||||||
|
# and exceptions will no longer raise in raw ones.
|
||||||
|
# find_exception(output.json())
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
return output.json()
|
return output.json()
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
from requests import get
|
from requests import get
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
from xmltodict import parse as xmlparse
|
from xmltodict import parse as xmlparse
|
||||||
from pyrmv.classes.Stop import Stop
|
|
||||||
|
|
||||||
from pyrmv.utility.find_exception import find_exception
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
@ -63,7 +60,9 @@ def stop_by_coords(accessId: str,
|
|||||||
|
|
||||||
output = get("https://www.rmv.de/hapi/location.nearbystops", params=payload, headers=headers)
|
output = get("https://www.rmv.de/hapi/location.nearbystops", params=payload, headers=headers)
|
||||||
|
|
||||||
find_exception(output.json())
|
# Exceptions checker moved to normal methods
|
||||||
|
# and exceptions will no longer raise in raw ones.
|
||||||
|
# find_exception(output.json())
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
return output.json()
|
return output.json()
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
from requests import get
|
from requests import get
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
from xmltodict import parse as xmlparse
|
from xmltodict import parse as xmlparse
|
||||||
from pyrmv.classes.Stop import Stop
|
|
||||||
|
|
||||||
from pyrmv.utility.find_exception import find_exception
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
@ -77,7 +74,9 @@ def stop_by_name(accessId: str,
|
|||||||
|
|
||||||
output = get("https://www.rmv.de/hapi/location.name", params=payload, headers=headers)
|
output = get("https://www.rmv.de/hapi/location.name", params=payload, headers=headers)
|
||||||
|
|
||||||
find_exception(output.json())
|
# Exceptions checker moved to normal methods
|
||||||
|
# and exceptions will no longer raise in raw ones.
|
||||||
|
# find_exception(output.json())
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
return output.json()
|
return output.json()
|
||||||
|
@ -134,7 +134,7 @@ def trip_find(accessId: str,
|
|||||||
### Args:
|
### Args:
|
||||||
* accessId (str): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
|
* 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".
|
* 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.
|
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Defaults to True.
|
||||||
* 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.
|
* 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.
|
* 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.
|
* 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.
|
||||||
@ -242,13 +242,15 @@ def trip_find(accessId: str,
|
|||||||
payload[str(var)] = val.strftime("%H:%M")
|
payload[str(var)] = val.strftime("%H:%M")
|
||||||
else:
|
else:
|
||||||
payload[str(var)] = val
|
payload[str(var)] = val
|
||||||
elif str(var) not in ["json", "headers", "payload", "raw_response"]:
|
elif str(var) not in ["json", "headers", "payload"]:
|
||||||
if val != None:
|
if val != None:
|
||||||
payload[str(var)] = val
|
payload[str(var)] = val
|
||||||
|
|
||||||
output = get("https://www.rmv.de/hapi/trip", params=payload, headers=headers)
|
output = get("https://www.rmv.de/hapi/trip", params=payload, headers=headers)
|
||||||
|
|
||||||
find_exception(output.json())
|
# Exceptions checker moved to normal methods
|
||||||
|
# and exceptions will no longer raise in raw ones.
|
||||||
|
# find_exception(output.json())
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
return output.json()
|
return output.json()
|
||||||
|
@ -28,7 +28,9 @@ def trip_recon(accessId: str,
|
|||||||
|
|
||||||
output = get("https://www.rmv.de/hapi/recon", params=payload, headers=headers)
|
output = get("https://www.rmv.de/hapi/recon", params=payload, headers=headers)
|
||||||
|
|
||||||
find_exception(output.json())
|
# Exceptions checker moved to normal methods
|
||||||
|
# and exceptions will no longer raise in raw ones.
|
||||||
|
# find_exception(output.json())
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
return output.json()
|
return output.json()
|
||||||
|
Loading…
Reference in New Issue
Block a user