Small refactor and isort+black formatting
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from datetime import datetime
|
||||
from requests import get
|
||||
from typing import Union
|
||||
|
||||
from requests import get
|
||||
from xmltodict import parse as xmlparse
|
||||
|
||||
try:
|
||||
@@ -8,27 +9,29 @@ try:
|
||||
except ImportError:
|
||||
from typing_extensions import Literal
|
||||
|
||||
|
||||
# 2.26. Journey Detail (journeyDetail)
|
||||
def journey_detail(accessId: str,
|
||||
id: str,
|
||||
json: bool = True,
|
||||
date: Union[str, datetime, None] = None,
|
||||
poly: bool = False,
|
||||
polyEnc: Literal["DLT", "GPA", "N"] = "N",
|
||||
showPassingPoints: bool = False,
|
||||
rtMode: Union[Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"], None] = None,
|
||||
fromId: Union[str, None] = None,
|
||||
fromIdx: Union[int, None] = None,
|
||||
toId: Union[str, None] = None,
|
||||
toIdx: Union[int, None] = None,
|
||||
baim: bool = False
|
||||
) -> dict:
|
||||
def journey_detail(
|
||||
accessId: str,
|
||||
id: str,
|
||||
json: bool = True,
|
||||
date: Union[str, datetime, None] = None,
|
||||
poly: bool = False,
|
||||
polyEnc: Literal["DLT", "GPA", "N"] = "N",
|
||||
showPassingPoints: bool = False,
|
||||
rtMode: Union[Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"], None] = None,
|
||||
fromId: Union[str, None] = None,
|
||||
fromIdx: Union[int, None] = None,
|
||||
toId: Union[str, None] = None,
|
||||
toIdx: Union[int, None] = None,
|
||||
baim: bool = False,
|
||||
) -> dict:
|
||||
"""The journey_detail method will deliver information about the complete route of a vehicle. The journey
|
||||
identifier is part of a trip or departureBoard response. It contains a list of all stops/stations of this journey
|
||||
including all departure and arrival times (with real-time data if available) and additional information like
|
||||
specific attributes about facilities and other texts.
|
||||
specific attributes about facilities and other texts.
|
||||
|
||||
Read more about this in section 2.26. "Journey Detail (journeyDetail)" of HAFAS ReST Documentation.
|
||||
Read more about this in section 2.26. "Journey Detail (journeyDetail)" of HAFAS ReST Documentation.
|
||||
|
||||
### Args:
|
||||
* accessId (str): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
|
||||
@@ -47,14 +50,10 @@ def journey_detail(accessId: str,
|
||||
|
||||
### Returns:
|
||||
* dict: Output from RMV. Dict will contain "errorCode" and "errorText" if exception occurs.
|
||||
"""
|
||||
|
||||
if json:
|
||||
headers = {"Accept": "application/json"}
|
||||
else:
|
||||
headers = {"Accept": "application/xml"}
|
||||
"""
|
||||
|
||||
payload = {}
|
||||
headers = {"Accept": "application/json"} if json else {"Accept": "application/xml"}
|
||||
|
||||
for var, val in locals().items():
|
||||
if str(var) == "rtMode":
|
||||
@@ -66,7 +65,4 @@ def journey_detail(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/journeyDetail", params=payload, headers=headers)
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
return xmlparse(output.content)
|
||||
return output.json() if json else xmlparse(output.content)
|
||||
|
Reference in New Issue
Block a user