Improved docs

This commit is contained in:
Profitroll 2022-10-07 14:17:24 +02:00
parent 94472ba945
commit ece22489ad

View File

@ -11,7 +11,6 @@ from pyrmv.raw.trip_find import trip_find as raw_trip_find
from pyrmv.raw.trip_recon import trip_recon as raw_trip_recon from pyrmv.raw.trip_recon import trip_recon as raw_trip_recon
from pyrmv.raw.him_search import him_search as raw_him_search from pyrmv.raw.him_search import him_search as raw_him_search
from pyrmv.utility.find_exception import find_exception from pyrmv.utility.find_exception import find_exception
from pyrmv.errors.not_ready import NotReadyYetError
try: try:
from typing import Literal from typing import Literal
@ -19,6 +18,53 @@ except ImportError:
from typing_extensions import Literal from typing_extensions import Literal
class Client(): class Client():
"""The main class in the whole module. Is used to use all non-raw methods.
More detailed docs for each method can be found by using IDE's docstring
highlighting system or in project's wiki ([can be found here](https://git.end-play.xyz/profitroll/PythonRMV/wiki))
### Args:
* access_id (`str`): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
### Methods:
* board_arrival -> BoardArrival
* board_departure -> BoardDeparture
* him_search -> List[Message]
* journey_detail -> Journey
* stop_by_coords -> List[Stop]
* stop_by_id -> Union[Stop, None]
* stop_by_name -> List[Stop]
* trip_find -> List[Trip]
* trip_recon -> List[Trip]
### Examples:
```py
import pyrmv
from datetime import datetime, timedelta
# Create client object with you API key
client = pyrmv.Client("YourAccessId")
# Get arrival and departure boards for station "Frankfurt (Main) Taunusanlage"
board_arrival = client.board_arrival("A=1@O=Frankfurt (Main) Taunusanlage@X=8668765@Y=50113478@U=80@L=3000011@", journeys_max=5)
board_departure = client.board_departure("A=1@O=Frankfurt (Main) Taunusanlage@X=8668765@Y=50113478@U=80@L=3000011@", journeys_max=5)
# Search for HIM messages for S9
messages = client.him_search(date_end=datetime.now()+timedelta(days=10), priority_min=2, train_names=["S9"])
# Get detailed journey of Bus 101
journey = client.journey_detail("2|#VN#1#ST#1664906549#PI#0#ZI#12709#TA#0#DA#61022#1S#3008007#1T#1248#LS#3008043#LT#1323#PU#80#RT#1#CA#1aE#ZE#101#ZB#Bus 101 #PC#6#FR#3008007#FT#1248#TO#3008043#TT#1323#", real_time_mode=pyrmv.enums.RealTimeMode.FULL)
# Look for stops using all possible methods
stop_by_coords client.stop_by_coords(50.131140, 8.733362, radius=300, max_number=3)
stop_by_id = client.stop_by_id("A=1@O=Offenbach (Main)-Zentrum Marktplatz\/Frankf. Straße@X=8764456@Y=50105181@U=80@L=3002510@")
stop_by_name = client.stop_by_name("Groß Karben", max_number=3)
# Find a trip and reconstruct it
trip = client.trip_find(origin_coord_lat="50.084659", origin_coord_lon="8.785948", destination_coord_lat=50.1233048, destination_coord_lon=8.6129742, messages=True)[0]
trip_recon = client.trip_recon(trip)[0]
```
"""
def __init__(self, access_id: str) -> None: def __init__(self, access_id: str) -> None:
self.access_id = access_id self.access_id = access_id
@ -371,7 +417,7 @@ class Client():
* lang (`Literal[Language.DE, Language.DA, Language.EN, Language.ES, Language.FR, Language.HU, Language.IT, Language.NL, Language.NO, Language.PL, Language.SV, Language.TR]`, **optional**): The language of response. Defaults to `Language.EN`. * lang (`Literal[Language.DE, Language.DA, Language.EN, Language.ES, Language.FR, Language.HU, Language.IT, Language.NL, Language.NO, Language.PL, Language.SV, Language.TR]`, **optional**): The language of response. Defaults to `Language.EN`.
### Returns: ### Returns:
* Stop: Instance of `Stop` object or `None` if not found. * Union[Stop, None]: Instance of `Stop` object or `None` if not found.
""" """
stops_raw = raw_stop_by_name( stops_raw = raw_stop_by_name(