Compare commits
19 Commits
94472ba945
...
v0.4.0-rc.
Author | SHA1 | Date | |
---|---|---|---|
eb9a043c34
|
|||
819bd5ff40 | |||
c2e1fc54c1 | |||
29ebb4627d | |||
6b6299cd0a | |||
|
e91846edee | ||
|
9b6b2d6416 | ||
|
f8b13ccedf | ||
|
b47bc51365 | ||
|
f39da9b803 | ||
|
1b863c55f1 | ||
|
80a788933d | ||
|
3599a034dc | ||
|
e09e8f29fb | ||
|
d23d9a005d | ||
9c9489aee1 | |||
07925d15eb | |||
a13027614e | |||
ece22489ad |
17
.renovaterc
Normal file
17
.renovaterc
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchUpdateTypes": [
|
||||
"minor",
|
||||
"patch",
|
||||
"pin",
|
||||
"digest"
|
||||
],
|
||||
"automerge": true
|
||||
}
|
||||
]
|
||||
}
|
48
README.md
48
README.md
@@ -2,25 +2,27 @@
|
||||
|
||||
Small module that makes your journey with RMV REST API somehow easier. Based fully on official RMV API reference and HAFAS documentation.
|
||||
|
||||
# Requirements
|
||||
## Requirements
|
||||
|
||||
* RMV API key (Get it [here](https://opendata.rmv.de/site/start.html))
|
||||
* Python3 (Tested versions are 3.7.9 and 3.9.13)
|
||||
* git (Only for installation from source)
|
||||
|
||||
# Installation
|
||||
## Installation
|
||||
|
||||
If you have everything listed in [requirements](#requirements), then let's begin.
|
||||
|
||||
### Variant 1:
|
||||
### Variant 1
|
||||
|
||||
1. `python -m pip install pyrmv`
|
||||
|
||||
### Variant 2:
|
||||
### Variant 2
|
||||
|
||||
1. `git clone https://git.end-play.xyz/profitroll/PythonRMV.git`
|
||||
2. `cd PythonRMV`
|
||||
3. `python setup.py install`
|
||||
|
||||
# Usage
|
||||
## Usage
|
||||
|
||||
```py
|
||||
import pyrmv
|
||||
@@ -36,44 +38,26 @@ destination = client.stop_by_coords(50.099613, 8.685449, max_number=3)[0]
|
||||
trip = client.trip_find(origin_id=origin.id, dest_id=destination.id)
|
||||
```
|
||||
|
||||
# Frequently Asked Questions
|
||||
## Frequently Asked Questions
|
||||
|
||||
- [Why are there raw versions and formatted ones?](#why-are-there-raw-versions-and-formatted-ones)
|
||||
- [Some methods work slightly different](#some-methods-work-slightly-different)
|
||||
* [Why are there raw versions and formatted ones?](#why-are-there-raw-versions-and-formatted-ones)
|
||||
* [Some methods work slightly different](#some-methods-work-slightly-different)
|
||||
|
||||
## Why are there raw versions and formatted ones?
|
||||
### Why are there raw versions and formatted ones?
|
||||
|
||||
For the purposes of my projects I don't really need all the stuff RMV gives (even though it's not much).
|
||||
I only need some specific things. However I do understand that in some cases other users may find
|
||||
those methods quite useful so I implemented them as well.
|
||||
|
||||
|
||||
## Some methods work slightly different
|
||||
### Some methods work slightly different
|
||||
|
||||
Can be. Not all function arguments written may work perfectly because I simply did not test each and
|
||||
every request. Some of arguments may be irrelevant in my use-case and the others are used quite rare at all.
|
||||
Just [make an issue](https://git.end-play.xyz/profitroll/PythonRMV/issues/new) and I'll implement it correct when I'll have some free time.
|
||||
|
||||
# To-Do
|
||||
## General
|
||||
- [ ] Docs in Wiki
|
||||
## To-Do
|
||||
|
||||
## Raw methods
|
||||
- [x] arrivalBoard (board_arrival)
|
||||
- [x] departureBoard (board_departure)
|
||||
- [x] himsearch (him_search)
|
||||
- [x] journeyDetail (journey_detail)
|
||||
- [x] location.nearbystops (stop_by_coords)
|
||||
- [x] location.name (stop_by_name)
|
||||
- [x] trip (trip_find)
|
||||
- [x] recon (trip_recon)
|
||||
### General
|
||||
|
||||
## Normal methods
|
||||
- [x] arrivalBoard (board_arrival)
|
||||
- [x] departureBoard (board_departure)
|
||||
- [x] himsearch (him_search)
|
||||
- [x] journeyDetail (journey_detail)
|
||||
- [x] location.nearbystops (stop_by_coords)
|
||||
- [x] location.name (stop_by_name)
|
||||
- [x] trip (trip_find)
|
||||
- [x] recon (trip_recon)
|
||||
* [ ] Docs in Wiki
|
||||
* [ ] Tickets
|
||||
|
@@ -21,15 +21,10 @@ trip = client.trip_find(origin_id=origin.id, dest_id=destination.id)
|
||||
"""
|
||||
|
||||
__name__ = "pyrmv"
|
||||
__version__ = "0.3.0"
|
||||
__version__ = "0.3.5"
|
||||
__license__ = "MIT License"
|
||||
__author__ = "Profitroll"
|
||||
|
||||
from . import raw
|
||||
from . import const
|
||||
from . import enums
|
||||
from . import errors
|
||||
from . import utility
|
||||
from . import const, enums, errors, raw, utility
|
||||
from .classes import *
|
||||
from .classes.Client import Client
|
||||
# from .methods import *
|
@@ -3,17 +3,23 @@ from pyrmv.classes.Message import Message
|
||||
|
||||
class LineArrival():
|
||||
|
||||
def __init__(self, data, client):
|
||||
def __init__(self, data, client, retrieve_stops: bool = True):
|
||||
self.journey = client.journey_detail(data["JourneyDetailRef"]["ref"])
|
||||
self.status = data["JourneyStatus"]
|
||||
self.messages = []
|
||||
for message in data["Messages"]["Message"]:
|
||||
self.messages.append(Message(message))
|
||||
if "Messages" in data:
|
||||
self.messages.extend(
|
||||
Message(message) for message in data["Messages"]["Message"]
|
||||
)
|
||||
self.name = data["name"]
|
||||
self.type = data["type"]
|
||||
self.stop_name = data["stop"]
|
||||
self.stop_id = data["stopid"]
|
||||
self.stop_id_ext = data["stopExtId"]
|
||||
if retrieve_stops:
|
||||
self.stop = client.stop_by_id(self.stop_id)
|
||||
else:
|
||||
self.stop = None
|
||||
self.stop = client.stop_by_id(self.stop_id)
|
||||
self.time = datetime.strptime(data["time"], "%H:%M:%S")
|
||||
self.date = datetime.strptime(data["date"], "%Y-%m-%d")
|
||||
@@ -28,18 +34,23 @@ class LineArrival():
|
||||
|
||||
class LineDeparture():
|
||||
|
||||
def __init__(self, data, client):
|
||||
def __init__(self, data, client, retrieve_stops: bool = True):
|
||||
self.journey = client.journey_detail(data["JourneyDetailRef"]["ref"])
|
||||
self.status = data["JourneyStatus"]
|
||||
self.messages = []
|
||||
for message in data["Messages"]["Message"]:
|
||||
self.messages.append(Message(message))
|
||||
if "Messages" in data:
|
||||
self.messages.extend(
|
||||
Message(message) for message in data["Messages"]["Message"]
|
||||
)
|
||||
self.name = data["name"]
|
||||
self.type = data["type"]
|
||||
self.stop_name = data["stop"]
|
||||
self.stop_id = data["stopid"]
|
||||
self.stop_id_ext = data["stopExtId"]
|
||||
self.stop = client.stop_by_id(self.stop_id)
|
||||
if retrieve_stops:
|
||||
self.stop = client.stop_by_id(self.stop_id)
|
||||
else:
|
||||
self.stop = None
|
||||
self.time = datetime.strptime(data["time"], "%H:%M:%S")
|
||||
self.date = datetime.strptime(data["date"], "%Y-%m-%d")
|
||||
if ("rtTime" in data) and ("rtDate" in data):
|
||||
@@ -54,10 +65,12 @@ class LineDeparture():
|
||||
|
||||
class BoardArrival(list):
|
||||
|
||||
def __init__(self, data: dict, client):
|
||||
def __init__(self, data: dict, client, retrieve_stops: bool = True):
|
||||
super().__init__([])
|
||||
if "Arrival" not in data:
|
||||
return
|
||||
for line in data["Arrival"]:
|
||||
self.append(LineArrival(line, client))
|
||||
self.append(LineArrival(line, client, retrieve_stops=retrieve_stops))
|
||||
|
||||
def __str__(self) -> str:
|
||||
lines = []
|
||||
@@ -67,10 +80,12 @@ class BoardArrival(list):
|
||||
|
||||
class BoardDeparture(list):
|
||||
|
||||
def __init__(self, data: dict, client):
|
||||
def __init__(self, data: dict, client, retrieve_stops: bool = True):
|
||||
super().__init__([])
|
||||
if "Departure" not in data:
|
||||
return
|
||||
for line in data["Departure"]:
|
||||
self.append(LineDeparture(line, client))
|
||||
self.append(LineDeparture(line, client, retrieve_stops=retrieve_stops))
|
||||
|
||||
def __str__(self) -> str:
|
||||
lines = []
|
||||
|
@@ -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.him_search import him_search as raw_him_search
|
||||
from pyrmv.utility.find_exception import find_exception
|
||||
from pyrmv.errors.not_ready import NotReadyYetError
|
||||
|
||||
try:
|
||||
from typing import Literal
|
||||
@@ -19,22 +18,70 @@ except ImportError:
|
||||
from typing_extensions import Literal
|
||||
|
||||
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:
|
||||
self.access_id = access_id
|
||||
|
||||
def board_arrival(self,
|
||||
id: str = None, # type: ignore
|
||||
id_ext: str = None, # type: ignore
|
||||
direction: Union[str, Stop, StopTrip] = None, # type: ignore
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
time: Union[str, datetime] = None, # type: ignore
|
||||
id: Union[str, None] = None,
|
||||
id_ext: Union[str, None] = None,
|
||||
direction: Union[str, Stop, StopTrip, None] = None,
|
||||
date: Union[str, datetime, None] = None,
|
||||
time: Union[str, datetime, None] = None,
|
||||
duration: Union[int, timedelta] = 60,
|
||||
journeys_max: int = -1,
|
||||
operators: Union[str, list] = None, # type: ignore
|
||||
lines: Union[str, list] = None, # type: ignore
|
||||
operators: Union[str, list, None] = None,
|
||||
lines: Union[str, list, None] = None,
|
||||
passlist: bool = False,
|
||||
board_type: Literal[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION] = BoardArrivalType.ARR,
|
||||
retrieve_stops: bool = True
|
||||
) -> BoardArrival:
|
||||
"""Method returns a board with arriving transport.
|
||||
|
||||
@@ -52,6 +99,7 @@ class Client():
|
||||
* lines (`Union[str, list]`, **optional**): Only journeys running the given line are part of the result. To filter multiple lines, provide a list or separate the codes by comma or provide a list. If the line should not be part of the be trip, negate it by putting ! in front of it. Defaults to `None`.
|
||||
* passlist (`bool`, **optional**): Include a list of all passed waystops. Defaults to `False`.
|
||||
* board_type (`Union[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION]`, optional): Set the station arrival board type to be used. Defaults to `BoardArrivalType.ARR`.
|
||||
* retrieve_stops (`bool`, **optional**): Whether the stops should be retrieved as a `Stop` objects. Using `False` will drastically increase processing speed and decrease number of requests made (good for low access_key rate limit). Defaults to `True`.
|
||||
|
||||
### Returns:
|
||||
* BoardArrival: Instance of `BoardArrival` object.
|
||||
@@ -64,7 +112,7 @@ class Client():
|
||||
accessId=self.access_id,
|
||||
id=id,
|
||||
extId=id_ext,
|
||||
direction=direction,
|
||||
direction=direction, # type: ignore
|
||||
date=date,
|
||||
time=time,
|
||||
duration=duration,
|
||||
@@ -77,20 +125,21 @@ class Client():
|
||||
|
||||
find_exception(board_raw)
|
||||
|
||||
return BoardArrival(board_raw, self)
|
||||
return BoardArrival(board_raw, self, retrieve_stops=retrieve_stops)
|
||||
|
||||
def board_departure(self,
|
||||
id: str = None, # type: ignore
|
||||
id_ext: str = None, # type: ignore
|
||||
direction: Union[str, Stop, StopTrip] = None, # type: ignore
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
time: Union[str, datetime] = None, # type: ignore
|
||||
id: Union[str, None] = None,
|
||||
id_ext: Union[str, None] = None,
|
||||
direction: Union[str, Stop, StopTrip, None] = None,
|
||||
date: Union[str, datetime, None] = None,
|
||||
time: Union[str, datetime, None] = None,
|
||||
duration: Union[int, timedelta] = 60,
|
||||
journeys_max: int = -1,
|
||||
operators: Union[str, list] = None, # type: ignore
|
||||
lines: Union[str, list] = None, # type: ignore
|
||||
operators: Union[str, list, None] = None,
|
||||
lines: Union[str, list, None] = None,
|
||||
passlist: bool = False,
|
||||
board_type: Literal[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION] = BoardDepartureType.DEP,
|
||||
retrieve_stops: bool = True
|
||||
) -> BoardDeparture:
|
||||
"""Method returns a board with departing transport.
|
||||
|
||||
@@ -108,6 +157,7 @@ class Client():
|
||||
* lines (`Union[str, list]`, **optional**): Only journeys running the given line are part of the result. To filter multiple lines, provide a list or separate the codes by comma or provide a list. If the line should not be part of the be trip, negate it by putting ! in front of it. Defaults to `None`.
|
||||
* passlist (`bool`, **optional**): Include a list of all passed waystops. Defaults to `False`.
|
||||
* board_type (`Union[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION]`, optional): Set the station departure board type to be used. Defaults to `BoardDepartureType.DEP`.
|
||||
* retrieve_stops (`bool`, **optional**): Whether the stops should be retrieved as a `Stop` objects. Using `False` will drastically increase processing speed and decrease number of requests made (good for low access_key rate limit). Defaults to `True`.
|
||||
|
||||
### Returns:
|
||||
* BoardDeparture: Instance of `BoardDeparture` object.
|
||||
@@ -120,7 +170,7 @@ class Client():
|
||||
accessId=self.access_id,
|
||||
id=id,
|
||||
extId=id_ext,
|
||||
direction=direction,
|
||||
direction=direction, # type: ignore
|
||||
date=date,
|
||||
time=time,
|
||||
duration=duration,
|
||||
@@ -133,31 +183,31 @@ class Client():
|
||||
|
||||
find_exception(board_raw)
|
||||
|
||||
return BoardDeparture(board_raw, self)
|
||||
return BoardDeparture(board_raw, self, retrieve_stops=retrieve_stops)
|
||||
|
||||
def him_search(self,
|
||||
date_begin: Union[str, datetime] = None,
|
||||
date_end: Union[str, datetime] = None,
|
||||
time_begin: Union[str, datetime] = None,
|
||||
time_end: Union[str, datetime] = None,
|
||||
weekdays: Union[str, OrderedDict[str, bool]] = None,
|
||||
ids: list = None,
|
||||
operators: list = None,
|
||||
categories: list = None,
|
||||
channels: list = None,
|
||||
companies: list = None,
|
||||
lines: list = None,
|
||||
line_ids: list = None,
|
||||
stations: Union[list, List[Stop]] = None,
|
||||
station_from: Union[str, Stop] = None,
|
||||
station_to: Union[str, Stop] = None,
|
||||
both_ways: bool = None,
|
||||
train_names: list = None,
|
||||
search_mode: Literal[SearchMode.MATCH, SearchMode.NOMATCH, SearchMode.TFMATCH] = None,
|
||||
affected_journey_mode: Literal[AffectedJourneyMode.ALL, AffectedJourneyMode.OFF] = None,
|
||||
affected_journey_stop_mode: Literal[AffectedJourneyStopMode.ALL, AffectedJourneyStopMode.IMP, AffectedJourneyStopMode.OFF] = None,
|
||||
priority_min: int = None,
|
||||
priority_max: int = None
|
||||
date_begin: Union[str, datetime, None] = None,
|
||||
date_end: Union[str, datetime, None] = None,
|
||||
time_begin: Union[str, datetime, None] = None,
|
||||
time_end: Union[str, datetime, None] = None,
|
||||
weekdays: Union[str, OrderedDict[str, bool], None] = None,
|
||||
ids: Union[list, None] = None,
|
||||
operators: Union[list, None] = None,
|
||||
categories: Union[list, None] = None,
|
||||
channels: Union[list, None] = None,
|
||||
companies: Union[list, None] = None,
|
||||
lines: Union[list, None] = None,
|
||||
line_ids: Union[list, None] = None,
|
||||
stations: Union[list, List[Stop], None] = None,
|
||||
station_from: Union[str, Stop, None] = None,
|
||||
station_to: Union[str, Stop, None] = None,
|
||||
both_ways: Union[bool, None] = None,
|
||||
train_names: Union[list, None] = None,
|
||||
search_mode: Union[Literal[SearchMode.MATCH, SearchMode.NOMATCH, SearchMode.TFMATCH], None] = None,
|
||||
affected_journey_mode: Union[Literal[AffectedJourneyMode.ALL, AffectedJourneyMode.OFF], None] = None,
|
||||
affected_journey_stop_mode: Union[Literal[AffectedJourneyStopMode.ALL, AffectedJourneyStopMode.IMP, AffectedJourneyStopMode.OFF], None] = None,
|
||||
priority_min: Union[int, None] = None,
|
||||
priority_max: Union[int, None] = None
|
||||
) -> List[Message]:
|
||||
"""The him_search method will deliver a list of HIM messages if matched by the given criteria as
|
||||
well as affected products if any.
|
||||
@@ -238,32 +288,33 @@ class Client():
|
||||
lines=lines,
|
||||
lineids=line_ids,
|
||||
stations=stations,
|
||||
fromstation=station_from,
|
||||
tostation=station_to,
|
||||
fromstation=station_from, # type: ignore
|
||||
tostation=station_to, # type: ignore
|
||||
bothways=both_ways,
|
||||
trainnames=train_names,
|
||||
searchmode=search_mode,
|
||||
affectedJourneyMode=affected_journey_mode,
|
||||
affectedJourneyStopMode=affected_journey_stop_mode,
|
||||
searchmode=search_mode, # type: ignore
|
||||
affectedJourneyMode=affected_journey_mode, # type: ignore
|
||||
affectedJourneyStopMode=affected_journey_stop_mode, # type: ignore
|
||||
maxprio=priority_max,
|
||||
minprio=priority_min
|
||||
)
|
||||
|
||||
find_exception(messages_raw)
|
||||
|
||||
for message in messages_raw["Message"]:
|
||||
messages.append(Message(message))
|
||||
if "Message" in messages_raw:
|
||||
for message in messages_raw["Message"]:
|
||||
messages.append(Message(message))
|
||||
|
||||
return messages
|
||||
|
||||
def journey_detail(self,
|
||||
id: str,
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
real_time_mode: Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT] = None, # type: ignore
|
||||
from_id: str = None, # type: ignore
|
||||
from_index: int = None, # type: ignore
|
||||
to_id: str = None, # type: ignore
|
||||
to_index: int = None # type: ignore
|
||||
date: Union[str, datetime, None] = None,
|
||||
real_time_mode: Union[Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT], None] = None,
|
||||
from_id: Union[str, None] = None,
|
||||
from_index: Union[int, None] = None,
|
||||
to_id: Union[str, None] = None,
|
||||
to_index: Union[int, None] = None
|
||||
) -> Journey:
|
||||
"""The journey_detail method will deliver information about the complete route of a vehicle. The journey
|
||||
identifier is part of a trip or `board_departure()` response. It contains a list of all stops/stations of this journey
|
||||
@@ -294,7 +345,7 @@ class Client():
|
||||
accessId=self.access_id,
|
||||
id=id,
|
||||
date=date,
|
||||
rtMode=real_time_mode,
|
||||
rtMode=real_time_mode, # type: ignore
|
||||
fromId=from_id,
|
||||
fromIdx=from_index,
|
||||
toId=to_id,
|
||||
@@ -313,7 +364,7 @@ class Client():
|
||||
radius: Union[int, float] = 1000,
|
||||
max_number: int = 10,
|
||||
stop_type: Literal[LocationType.S, LocationType.P, LocationType.SP, LocationType.SE, LocationType.SPE] = LocationType.S,
|
||||
selection_mode: Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N] = None, # type: ignore
|
||||
selection_mode: Union[Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N], None] = None,
|
||||
) -> List[Stop]:
|
||||
"""Method returns a list of stops around a given center coordinate.
|
||||
The returned results are ordered by their distance to the center coordinate.
|
||||
@@ -347,16 +398,17 @@ class Client():
|
||||
radius=radius,
|
||||
maxNo=max_number,
|
||||
stopType=stop_type.code,
|
||||
locationSelectionMode=selection_mode
|
||||
locationSelectionMode=selection_mode # type: ignore
|
||||
)
|
||||
|
||||
find_exception(stops_raw)
|
||||
|
||||
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
||||
if "StopLocation" in stop:
|
||||
stops.append(Stop(stop["StopLocation"]))
|
||||
elif "CoordLocation" in stop:
|
||||
stops.append(Stop(stop["CoordLocation"]))
|
||||
if "stopLocationOrCoordLocation" in stops_raw:
|
||||
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
||||
if "StopLocation" in stop:
|
||||
stops.append(Stop(stop["StopLocation"]))
|
||||
elif "CoordLocation" in stop:
|
||||
stops.append(Stop(stop["CoordLocation"]))
|
||||
|
||||
return stops
|
||||
|
||||
@@ -371,7 +423,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`.
|
||||
|
||||
### 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(
|
||||
@@ -400,12 +452,12 @@ 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] = Language.EN,
|
||||
max_number: int = 10,
|
||||
stop_type: Literal[LocationType.A, LocationType.ALL, LocationType.AP, LocationType.P, LocationType.S, LocationType.SA, LocationType.SP] = LocationType.ALL,
|
||||
selection_mode: Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N] = None, # type: ignore
|
||||
coord_lat: Union[str, float] = None, # type: ignore
|
||||
coord_lon: Union[str, float] = None, # type: ignore
|
||||
selection_mode: Union[Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N], None] = None,
|
||||
coord_lat: Union[str, float, None] = None,
|
||||
coord_lon: Union[str, float, None] = None,
|
||||
radius: Union[int, float] = 1000,
|
||||
refine_id: str = None, # type: ignore
|
||||
stations: Union[str, list] = None, # type: ignore
|
||||
refine_id: Union[str, None] = None,
|
||||
stations: Union[str, list, None] = None,
|
||||
filter_mode: Literal[FilterMode.DIST_PERI, FilterMode.EXCL_PERI, FilterMode.SLCT_PERI] = FilterMode.DIST_PERI
|
||||
) -> List[Stop]:
|
||||
"""Method can be used to perform a pattern matching of a user input and to retrieve a list
|
||||
@@ -443,7 +495,7 @@ class Client():
|
||||
lang=lang.code,
|
||||
maxNo=max_number,
|
||||
stopType=stop_type.code,
|
||||
locationSelectionMode=selection_mode,
|
||||
locationSelectionMode=selection_mode, # type: ignore
|
||||
coordLat=coord_lat,
|
||||
coordLong=coord_lon,
|
||||
radius=radius,
|
||||
@@ -454,58 +506,59 @@ class Client():
|
||||
|
||||
find_exception(stops_raw)
|
||||
|
||||
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
||||
if "StopLocation" in stop:
|
||||
stops.append(Stop(stop["StopLocation"]))
|
||||
elif "CoordLocation" in stop:
|
||||
stops.append(Stop(stop["CoordLocation"]))
|
||||
if "stopLocationOrCoordLocation" in stops_raw:
|
||||
for stop in stops_raw["stopLocationOrCoordLocation"]:
|
||||
if "StopLocation" in stop:
|
||||
stops.append(Stop(stop["StopLocation"]))
|
||||
elif "CoordLocation" in stop:
|
||||
stops.append(Stop(stop["CoordLocation"]))
|
||||
|
||||
return stops
|
||||
|
||||
def trip_find(self,
|
||||
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] = Language.EN,
|
||||
|
||||
origin_id: str = None, # type: ignore
|
||||
origin_id_ext: str = None, # type: ignore
|
||||
origin_coord_lat: Union[str, float] = None, # type: ignore
|
||||
origin_coord_lon: Union[str, float] = None, # type: ignore
|
||||
origin_coord_name: str = None, # type: ignore
|
||||
origin_id: Union[str, None] = None,
|
||||
origin_id_ext: Union[str, None] = None,
|
||||
origin_coord_lat: Union[str, float, None] = None,
|
||||
origin_coord_lon: Union[str, float, None] = None,
|
||||
origin_coord_name: Union[str, None] = None,
|
||||
|
||||
destination_id: str = None, # type: ignore
|
||||
destination_id_ext: str = None, # type: ignore
|
||||
destination_coord_lat: Union[str, float] = None, # type: ignore
|
||||
destination_coord_lon: Union[str, float] = None, # type: ignore
|
||||
destination_coord_name: str = None, # type: ignore
|
||||
destination_id: Union[str, None] = None,
|
||||
destination_id_ext: Union[str, None] = None,
|
||||
destination_coord_lat: Union[str, float, None] = None,
|
||||
destination_coord_lon: Union[str, float, None] = None,
|
||||
destination_coord_name: Union[str, None] = None,
|
||||
|
||||
via: str = None, # type: ignore
|
||||
via_id: str = None, # type: ignore
|
||||
via_gis: str = None, # type: ignore
|
||||
via: Union[str, None] = None,
|
||||
via_id: Union[str, None] = None,
|
||||
via_gis: Union[str, None] = None,
|
||||
via_wait_time: int = 0,
|
||||
|
||||
avoid: str = None, # type: ignore
|
||||
avoid_id: str = None, # type: ignore
|
||||
avoid: Union[str, None] = None,
|
||||
avoid_id: Union[str, None] = None,
|
||||
|
||||
change_time_percent: int = 100,
|
||||
change_time_min: int = None, # type: ignore
|
||||
change_time_max: int = None, # type: ignore
|
||||
change_time_add: int = None, # type: ignore
|
||||
change_max: int = None, # type: ignore
|
||||
change_time_min: Union[int, None] = None,
|
||||
change_time_max: Union[int, None] = None,
|
||||
change_time_add: Union[int, None] = None,
|
||||
change_max: Union[int, None] = None,
|
||||
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
time: Union[str, datetime] = None, # type: ignore
|
||||
date: Union[str, datetime, None] = None,
|
||||
time: Union[str, datetime, None] = None,
|
||||
|
||||
search_arrival: bool = False,
|
||||
|
||||
trips_after_time: int = None, # type: ignore
|
||||
trips_before_time: int = None, # type: ignore
|
||||
trips_after_time: Union[int, None] = None,
|
||||
trips_before_time: Union[int, None] = None,
|
||||
|
||||
context: str = None, # type: ignore
|
||||
context: Union[str, None] = None,
|
||||
|
||||
passlist: bool = False,
|
||||
operators: Union[str, list] = None, # type: ignore
|
||||
operators: Union[str, list, None] = None,
|
||||
|
||||
lines: Union[str, list] = None, # type: ignore
|
||||
lineids: Union[str, list] = None, # type: ignore
|
||||
lines: Union[str, list, None] = None,
|
||||
lineids: Union[str, list, None] = None,
|
||||
|
||||
iv_include: bool = False,
|
||||
iv_only: bool = False,
|
||||
@@ -514,11 +567,11 @@ class Client():
|
||||
|
||||
passing_points: bool = False,
|
||||
|
||||
real_time_mode: Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT] = None, # type: ignore
|
||||
real_time_mode: Union[Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT], None] = None,
|
||||
|
||||
include_earlier: bool = False,
|
||||
ict_alternatives: bool = False,
|
||||
tariff: bool = None, # type: ignore
|
||||
tariff: Union[bool, None] = None,
|
||||
messages: bool = False,
|
||||
frequency: bool = True
|
||||
) -> List[Trip]:
|
||||
@@ -636,7 +689,7 @@ class Client():
|
||||
|
||||
showPassingPoints=passing_points,
|
||||
|
||||
rtMode=real_time_mode,
|
||||
rtMode=real_time_mode, # type: ignore
|
||||
|
||||
includeEarlier=include_earlier,
|
||||
withICTAlternatives=ict_alternatives,
|
||||
@@ -647,24 +700,25 @@ class Client():
|
||||
|
||||
find_exception(trips_raw)
|
||||
|
||||
for trip in trips_raw["Trip"]:
|
||||
trips.append(Trip(trip))
|
||||
if "Trip" in trips_raw:
|
||||
for trip in trips_raw["Trip"]:
|
||||
trips.append(Trip(trip))
|
||||
|
||||
return trips
|
||||
|
||||
def trip_recon(self,
|
||||
context: Union[str, Journey],
|
||||
date: Union[str, datetime] = None,
|
||||
match_real_time: bool = None,
|
||||
enable_replacements: bool = None,
|
||||
arrival_dev_lower: int = None,
|
||||
arrival_dev_upper: int = None,
|
||||
departure_dev_lower: int = None,
|
||||
departure_dev_upper: int = None,
|
||||
passlist: bool = None,
|
||||
context: Union[str, Trip],
|
||||
date: Union[str, datetime, None] = None,
|
||||
match_real_time: Union[bool, None] = None,
|
||||
enable_replacements: Union[bool, None] = None,
|
||||
arrival_dev_lower: Union[int, None] = None,
|
||||
arrival_dev_upper: Union[int, None] = None,
|
||||
departure_dev_lower: Union[int, None] = None,
|
||||
departure_dev_upper: Union[int, None] = None,
|
||||
passlist: bool = False,
|
||||
passing_points: bool = False,
|
||||
real_time_mode: Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT] = None,
|
||||
tariff: bool = None,
|
||||
real_time_mode: Union[Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT], None] = None,
|
||||
tariff: Union[bool, None] = None,
|
||||
messages: bool = False
|
||||
) -> List[Trip]:
|
||||
"""Reconstructing a trip can be achieved using the reconstruction context provided by any trip result in the
|
||||
@@ -703,7 +757,7 @@ class Client():
|
||||
trips = []
|
||||
trips_raw = raw_trip_recon(
|
||||
accessId=self.access_id,
|
||||
ctx=context,
|
||||
ctx=context, # type: ignore
|
||||
date=date,
|
||||
matchRtType=match_real_time,
|
||||
enableReplacements=enable_replacements,
|
||||
@@ -713,14 +767,15 @@ class Client():
|
||||
depU=departure_dev_upper,
|
||||
passlist=passlist,
|
||||
showPassingPoints=passing_points,
|
||||
rtMode=real_time_mode,
|
||||
rtMode=real_time_mode, # type: ignore
|
||||
tariff=tariff,
|
||||
trafficMessages=messages,
|
||||
)
|
||||
|
||||
find_exception(trips_raw)
|
||||
|
||||
for trip in trips_raw["Trip"]:
|
||||
trips.append(Trip(trip))
|
||||
if "Trip" in trips_raw:
|
||||
for trip in trips_raw["Trip"]:
|
||||
trips.append(Trip(trip))
|
||||
|
||||
return trips
|
@@ -11,11 +11,12 @@ class Journey():
|
||||
self.direction_flag = data["Directions"]["Direction"][0]["flag"]
|
||||
self.messages = []
|
||||
|
||||
for stop in data["Stops"]["Stop"]:
|
||||
self.stops.append(Stop(stop))
|
||||
self.stops.extend(Stop(stop) for stop in data["Stops"]["Stop"])
|
||||
|
||||
for message in data["Messages"]["Message"]:
|
||||
self.messages.append(Message(message))
|
||||
if "Messages" in data:
|
||||
self.messages.extend(
|
||||
Message(message) for message in data["Messages"]["Message"]
|
||||
)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Journey with total of {len(self.stops)} stops and {len(self.messages)} messages heading {self.direction} ({self.direction_flag})"
|
@@ -61,7 +61,7 @@ class Message():
|
||||
self.text = data["text"]
|
||||
self.company = data["company"]
|
||||
self.category = data["category"]
|
||||
self.priority = data["priority"]
|
||||
self.priority = None if "priority" not in data else data["priority"]
|
||||
self.products = data["products"]
|
||||
self.icon = data["icon"]
|
||||
self.time_start = datetime.strptime(data["sTime"], "%H:%M:%S")
|
||||
|
@@ -11,19 +11,19 @@ except ImportError:
|
||||
# 2.25. Arrival Board (arrivalBoard)
|
||||
def board_arrival(accessId: str,
|
||||
json: bool = True,
|
||||
id: str = None, # type: ignore
|
||||
extId: str = None, # type: ignore
|
||||
direction: str = None, # type: ignore
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
time: Union[str, datetime] = None, # type: ignore
|
||||
duration: int = 60,
|
||||
id: Union[str, None] = None,
|
||||
extId: Union[str, None] = None,
|
||||
direction: Union[str, None] = None,
|
||||
date: Union[str, datetime, None] = None,
|
||||
time: Union[str, datetime, None] = None,
|
||||
duration: Union[int, timedelta] = 60,
|
||||
maxJourneys: int = -1,
|
||||
products: int = None, # type: ignore
|
||||
operators: Union[str, list] = None, # type: ignore
|
||||
lines: Union[str, list] = None, # type: ignore
|
||||
products: Union[int, None] = None,
|
||||
operators: Union[str, list, None] = None,
|
||||
lines: Union[str, list, None] = None,
|
||||
filterEquiv: bool = True,
|
||||
attributes: Union[str, list] = None, # type: ignore
|
||||
platforms: Union[str, list] = None, # type: ignore
|
||||
attributes: Union[str, list, None] = None,
|
||||
platforms: Union[str, list, None] = None,
|
||||
passlist: bool = False,
|
||||
boardType: Literal["ARR", "ARR_EQUIVS", "ARR_MAST", "ARR_STATION"] = "ARR"
|
||||
) -> dict:
|
||||
@@ -81,7 +81,7 @@ def board_arrival(accessId: str,
|
||||
elif str(var) == "duration":
|
||||
if val != None:
|
||||
if isinstance(val, timedelta):
|
||||
payload[str(var)] = val.minutes
|
||||
payload[str(var)] = val.minutes # type: ignore
|
||||
else:
|
||||
payload[str(var)] = val
|
||||
elif str(var) == "boardType":
|
||||
@@ -93,10 +93,6 @@ def board_arrival(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/arrivalBoard", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -11,19 +11,19 @@ except ImportError:
|
||||
# 2.24. Departure Board (departureBoard)
|
||||
def board_departure(accessId: str,
|
||||
json: bool = True,
|
||||
id: str = None, # type: ignore
|
||||
extId: str = None, # type: ignore
|
||||
direction: str = None, # type: ignore
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
time: Union[str, datetime] = None, # type: ignore
|
||||
duration: int = 60,
|
||||
id: Union[str, None] = None,
|
||||
extId: Union[str, None] = None,
|
||||
direction: Union[str, None] = None,
|
||||
date: Union[str, datetime, None] = None,
|
||||
time: Union[str, datetime, None] = None,
|
||||
duration: Union[int, timedelta] = 60,
|
||||
maxJourneys: int = -1,
|
||||
products: int = None, # type: ignore
|
||||
operators: Union[str, list] = None, # type: ignore
|
||||
lines: Union[str, list] = None, # type: ignore
|
||||
products: Union[int, None] = None,
|
||||
operators: Union[str, list, None] = None,
|
||||
lines: Union[str, list, None] = None,
|
||||
filterEquiv: bool = True,
|
||||
attributes: Union[str, list] = None, # type: ignore
|
||||
platforms: Union[str, list] = None, # type: ignore
|
||||
attributes: Union[str, list, None] = None,
|
||||
platforms: Union[str, list, None] = None,
|
||||
passlist: bool = False,
|
||||
boardType: Literal["DEP", "DEP_EQUIVS", "DEP_MAST", "DEP_STATION"] = "DEP"
|
||||
) -> dict:
|
||||
@@ -82,7 +82,7 @@ def board_departure(accessId: str,
|
||||
elif str(var) == "duration":
|
||||
if val != None:
|
||||
if isinstance(val, timedelta):
|
||||
payload[str(var)] = val.minutes
|
||||
payload[str(var)] = val.minutes # type: ignore
|
||||
else:
|
||||
payload[str(var)] = val
|
||||
elif str(var) == "boardType":
|
||||
@@ -94,10 +94,6 @@ def board_departure(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/departureBoard", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -13,38 +13,38 @@ except ImportError:
|
||||
# 2.37. HIM Search (himsearch)
|
||||
def him_search(accessId: str,
|
||||
json: bool = True,
|
||||
dateB: Union[str, datetime] = None, # type: ignore
|
||||
dateE: Union[str, datetime] = None, # type: ignore
|
||||
timeB: Union[str, datetime] = None, # type: ignore
|
||||
timeE: Union[str, datetime] = None, # type: ignore
|
||||
weekdays: Union[str, OrderedDict[str, bool]] = None, # type: ignore
|
||||
himIds: Union[str, list] = None, # type: ignore
|
||||
dateB: Union[str, datetime, None] = None,
|
||||
dateE: Union[str, datetime, None] = None,
|
||||
timeB: Union[str, datetime, None] = None,
|
||||
timeE: Union[str, datetime, None] = None,
|
||||
weekdays: Union[str, OrderedDict[str, bool], None] = None,
|
||||
himIds: Union[str, list, None] = None,
|
||||
hierarchicalView: bool = False,
|
||||
operators: Union[str, list] = None, # type: ignore
|
||||
categories: Union[str, list] = None, # type: ignore
|
||||
channels: Union[str, list] = None, # type: ignore
|
||||
companies: Union[str, list] = None, # type: ignore
|
||||
lines: Union[str, list] = None, # type: ignore
|
||||
lineids: Union[str, list] = None, # type: ignore
|
||||
stations: Union[str, list] = None, # type: ignore
|
||||
fromstation: str = None, # type: ignore
|
||||
tostation: str = None, # type: ignore
|
||||
bothways: bool = None, # type: ignore
|
||||
trainnames: Union[str, list] = None, # type: ignore
|
||||
metas: Union[str, list] = None, # type: ignore
|
||||
himcategory: str = None, # type: ignore
|
||||
himtags: Union[str, list] = None, # type: ignore
|
||||
regions: Union[str, list] = None, # type: ignore
|
||||
himtext: Union[str, list] = None, # type: ignore
|
||||
himtexttags: Union[str, list] = None, # type: ignore
|
||||
additionalfields: Union[str, list, dict] = None, # type: ignore
|
||||
operators: Union[str, list, None] = None,
|
||||
categories: Union[str, list, None] = None,
|
||||
channels: Union[str, list, None] = None,
|
||||
companies: Union[str, list, None] = None,
|
||||
lines: Union[str, list, None] = None,
|
||||
lineids: Union[str, list, None] = None,
|
||||
stations: Union[str, list, None] = None,
|
||||
fromstation: Union[str, None] = None,
|
||||
tostation: Union[str, None] = None,
|
||||
bothways: Union[bool, None] = None,
|
||||
trainnames: Union[str, list, None] = None,
|
||||
metas: Union[str, list, None] = None,
|
||||
himcategory: Union[str, None] = None,
|
||||
himtags: Union[str, list, None] = None,
|
||||
regions: Union[str, list, None] = None,
|
||||
himtext: Union[str, list, None] = None,
|
||||
himtexttags: Union[str, list, None] = None,
|
||||
additionalfields: Union[str, list, dict, None] = None,
|
||||
poly: bool = False,
|
||||
searchmode: Literal["MATCH", "NOMATCH", "TFMATCH"] = None, # type: ignore
|
||||
affectedJourneyMode: Literal["ALL", "OFF"] = None, # type: ignore
|
||||
affectedJourneyStopMode: Literal["ALL", "IMP", "OFF"] = None, # type: ignore
|
||||
orderBy: Union[str, list] = None, # type: ignore
|
||||
minprio: Union[str, int] = None, # type: ignore
|
||||
maxprio: Union[str, int] = None # type: ignore
|
||||
searchmode: Union[Literal["MATCH", "NOMATCH", "TFMATCH"], None] = None,
|
||||
affectedJourneyMode: Union[Literal["ALL", "OFF"], None] = None,
|
||||
affectedJourneyStopMode: Union[Literal["ALL", "IMP", "OFF"], None] = None,
|
||||
orderBy: Union[str, list, None] = None,
|
||||
minprio: Union[str, int, None] = None,
|
||||
maxprio: Union[str, int, None] = None
|
||||
) -> dict:
|
||||
"""The himSearch will return a list of HIM messages if matched by the given criteria as well as affected
|
||||
products if any.
|
||||
@@ -132,10 +132,6 @@ def him_search(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/himsearch", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -12,15 +12,15 @@ except ImportError:
|
||||
def journey_detail(accessId: str,
|
||||
id: str,
|
||||
json: bool = True,
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
date: Union[str, datetime, None] = None,
|
||||
poly: bool = False,
|
||||
polyEnc: Literal["DLT", "GPA", "N"] = "N",
|
||||
showPassingPoints: bool = False,
|
||||
rtMode: Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"] = None, # type: ignore
|
||||
fromId: str = None, # type: ignore
|
||||
fromIdx: str = None, # type: ignore
|
||||
toId: str = None, # type: ignore
|
||||
toIdx: str = None, # type: ignore
|
||||
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
|
||||
@@ -66,10 +66,6 @@ def journey_detail(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/journeyDetail", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -16,11 +16,11 @@ def stop_by_coords(accessId: str,
|
||||
radius: Union[int, float] = 1000,
|
||||
maxNo: int = 10,
|
||||
stopType: Literal["S", "P", "SP", "SE", "SPE"] = "S",
|
||||
locationSelectionMode: Literal["SLCT_N", "SLCT_A"] = None, # type: ignore
|
||||
products: int = None, # type: ignore
|
||||
meta: str = None, # type: ignore
|
||||
sattributes: Union[str, list] = None, # type: ignore
|
||||
sinfotexts: Union[str, list] = None # type: ignore
|
||||
locationSelectionMode: Union[Literal["SLCT_N", "SLCT_A"], None] = None,
|
||||
products: Union[int, None] = None,
|
||||
meta: Union[str, None] = None,
|
||||
sattributes: Union[str, list, None] = None,
|
||||
sinfotexts: Union[str, list, None] = None
|
||||
) -> 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.
|
||||
@@ -66,10 +66,6 @@ def stop_by_coords(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/location.nearbystops", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -14,15 +14,15 @@ def stop_by_name(accessId: str,
|
||||
json: bool = True,
|
||||
maxNo: int = 10,
|
||||
stopType: Literal["A", "ALL", "AP", "P", "S", "SA", "SP"] = "ALL",
|
||||
locationSelectionMode: Literal["SLCT_N", "SLCT_A"] = None, # type: ignore
|
||||
products: int = None, # type: ignore
|
||||
coordLat: Union[str, float] = None, # type: ignore
|
||||
coordLong: Union[str, float] = None, # type: ignore
|
||||
locationSelectionMode: Union[Literal["SLCT_N", "SLCT_A"], None] = None,
|
||||
products: Union[int, None] = None,
|
||||
coordLat: Union[str, float, None] = None,
|
||||
coordLong: Union[str, float, None] = None,
|
||||
radius: Union[int, float] = 1000,
|
||||
refineId: str = None, # type: ignore
|
||||
meta: str = None, # type: ignore
|
||||
stations: Union[str, list] = None, # type: ignore
|
||||
sattributes: Union[str, list] = None, # type: ignore
|
||||
refineId: Union[str, None] = None,
|
||||
meta: Union[str, None] = None,
|
||||
stations: Union[str, list, None] = None,
|
||||
sattributes: Union[str, list, None] = None,
|
||||
filterMode: Literal["DIST_PERI", "EXCL_PERI", "SLCT_PERI"] = "DIST_PERI"
|
||||
) -> dict:
|
||||
"""The location.name service can be used to perform a pattern matching of a user input and to retrieve a list
|
||||
@@ -80,10 +80,6 @@ def stop_by_name(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/location.name", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -13,87 +13,87 @@ def trip_find(accessId: str,
|
||||
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "en",
|
||||
json: bool = True,
|
||||
|
||||
originId: str = None, # type: ignore
|
||||
originExtId: str = None, # type: ignore
|
||||
originCoordLat: Union[str, float] = None, # type: ignore
|
||||
originCoordLong: Union[str, float] = None, # type: ignore
|
||||
originCoordName: str = None, # type: ignore
|
||||
originId: Union[str, None] = None,
|
||||
originExtId: Union[str, None] = None,
|
||||
originCoordLat: Union[str, float, None] = None,
|
||||
originCoordLong: Union[str, float, None] = None,
|
||||
originCoordName: Union[str, None] = None,
|
||||
|
||||
destId: str = None, # type: ignore
|
||||
destExtId: str = None, # type: ignore
|
||||
destCoordLat: Union[str, float] = None, # type: ignore
|
||||
destCoordLong: Union[str, float] = None, # type: ignore
|
||||
destCoordName: str = None, # type: ignore
|
||||
destId: Union[str, None] = None,
|
||||
destExtId: Union[str, None] = None,
|
||||
destCoordLat: Union[str, float, None] = None,
|
||||
destCoordLong: Union[str, float, None] = None,
|
||||
destCoordName: Union[str, None] = None,
|
||||
|
||||
via: str = None, # type: ignore
|
||||
viaId: str = None, # type: ignore
|
||||
via: Union[str, None] = None,
|
||||
viaId: Union[str, None] = None,
|
||||
viaWaitTime: int = 0,
|
||||
|
||||
avoid: str = None, # type: ignore
|
||||
avoidId: str = None, # type: ignore
|
||||
avoid: Union[str, None] = None,
|
||||
avoidId: Union[str, None] = None,
|
||||
|
||||
viaGis: str = None, # type: ignore
|
||||
viaGis: Union[str, None] = None,
|
||||
|
||||
changeTimePercent: int = 100,
|
||||
minChangeTime: int = None, # type: ignore
|
||||
maxChangeTime: int = None, # type: ignore
|
||||
addChangeTime: int = None, # type: ignore
|
||||
maxChange: int = None, # type: ignore
|
||||
minChangeTime: Union[int, None] = None,
|
||||
maxChangeTime: Union[int, None] = None,
|
||||
addChangeTime: Union[int, None] = None,
|
||||
maxChange: Union[int, None] = None,
|
||||
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
time: Union[str, datetime] = None, # type: ignore
|
||||
date: Union[str, datetime, None] = None,
|
||||
time: Union[str, datetime, None] = None,
|
||||
|
||||
searchForArrival: bool = False,
|
||||
|
||||
numF: int = None, # type: ignore
|
||||
numB: int = None, # type: ignore
|
||||
numF: Union[int, None] = None,
|
||||
numB: Union[int, None] = None,
|
||||
|
||||
context: str = None, # type: ignore
|
||||
context: Union[str, None] = None,
|
||||
|
||||
poly: bool = False,
|
||||
polyEnc: Literal["DLT", "GPA", "N"] = "N",
|
||||
|
||||
passlist: bool = False,
|
||||
products: int = None, # type: ignore
|
||||
operators: Union[str, list] = None, # type: ignore
|
||||
products: Union[int, None] = None,
|
||||
operators: Union[str, list, None] = None,
|
||||
|
||||
attributes: Union[str, list] = None, # type: ignore
|
||||
sattributes: Union[str, list] = None, # type: ignore
|
||||
fattributes: Union[str, list] = None, # type: ignore
|
||||
lines: Union[str, list] = None, # type: ignore
|
||||
lineids: Union[str, list] = None, # type: ignore
|
||||
attributes: Union[str, list, None] = None,
|
||||
sattributes: Union[str, list, None] = None,
|
||||
fattributes: Union[str, list, None] = None,
|
||||
lines: Union[str, list, None] = None,
|
||||
lineids: Union[str, list, None] = None,
|
||||
|
||||
avoidPaths: List[Literal["SW", "EA", "ES", "RA", "CB"]] = None, # type: ignore
|
||||
avoidPaths: Union[List[Literal["SW", "EA", "ES", "RA", "CB"]], None] = None,
|
||||
|
||||
originWalk: Union[str, list] = None, # type: ignore
|
||||
originBike: Union[str, list] = None, # type: ignore
|
||||
originCar: Union[str, list] = None, # type: ignore
|
||||
originTaxi: Union[str, list] = None, # type: ignore
|
||||
originPark: Union[str, list] = None, # type: ignore
|
||||
originMeta: Union[str, list] = None, # type: ignore
|
||||
originWalk: Union[str, list, None] = None,
|
||||
originBike: Union[str, list, None] = None,
|
||||
originCar: Union[str, list, None] = None,
|
||||
originTaxi: Union[str, list, None] = None,
|
||||
originPark: Union[str, list, None] = None,
|
||||
originMeta: Union[str, list, None] = None,
|
||||
|
||||
destWalk: Union[str, list] = None, # type: ignore
|
||||
destBike: Union[str, list] = None, # type: ignore
|
||||
destCar: Union[str, list] = None, # type: ignore
|
||||
destTaxi: Union[str, list] = None, # type: ignore
|
||||
destPark: Union[str, list] = None, # type: ignore
|
||||
destMeta: Union[str, list] = None, # type: ignore
|
||||
destWalk: Union[str, list, None] = None,
|
||||
destBike: Union[str, list, None] = None,
|
||||
destCar: Union[str, list, None] = None,
|
||||
destTaxi: Union[str, list, None] = None,
|
||||
destPark: Union[str, list, None] = None,
|
||||
destMeta: Union[str, list, None] = None,
|
||||
|
||||
totalWalk: Union[str, list] = None, # type: ignore
|
||||
totalBike: Union[str, list] = None, # type: ignore
|
||||
totalCar: Union[str, list] = None, # type: ignore
|
||||
totalTaxi: Union[str, list] = None, # type: ignore
|
||||
totalMeta: Union[str, list] = None, # type: ignore
|
||||
totalWalk: Union[str, list, None] = None,
|
||||
totalBike: Union[str, list, None] = None,
|
||||
totalCar: Union[str, list, None] = None,
|
||||
totalTaxi: Union[str, list, None] = None,
|
||||
totalMeta: Union[str, list, None] = None,
|
||||
|
||||
gisProducts: str = None, # type: ignore
|
||||
gisProducts: Union[str, None] = None,
|
||||
|
||||
includeIv: bool = False,
|
||||
ivOnly: bool = False,
|
||||
|
||||
mobilityProfile: str = None, # type: ignore
|
||||
mobilityProfile: Union[str, None] = None,
|
||||
|
||||
bikeCarriage: bool = False,
|
||||
bikeCarriageType: Literal["SINGLEBIKES", "SMALLGROUPS", "LARGEGROUPS"] = None, # type: ignore
|
||||
bikeCarriageType: Union[Literal["SINGLEBIKES", "SMALLGROUPS", "LARGEGROUPS"], None] = None,
|
||||
|
||||
sleepingCar: bool = False,
|
||||
couchetteCoach: bool = False,
|
||||
@@ -102,24 +102,24 @@ def trip_find(accessId: str,
|
||||
|
||||
eco: bool = False,
|
||||
ecoCmp: bool = False,
|
||||
ecoParams: str = None, # type: ignore
|
||||
ecoParams: Union[str, None] = None,
|
||||
|
||||
rtMode: Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"] = None, # type: ignore
|
||||
rtMode: Union[Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"], None] = None,
|
||||
|
||||
unsharp: bool = False,
|
||||
trainFilter: str = None, # type: ignore
|
||||
trainFilter: Union[str, None] = None,
|
||||
economic: bool = False,
|
||||
groupFilter: str = None, # type: ignore
|
||||
groupFilter: Union[str, None] = None,
|
||||
|
||||
blockingList: str = None, # type: ignore
|
||||
blockedEdges: str = None, # type: ignore
|
||||
blockingList: Union[str, None] = None,
|
||||
blockedEdges: Union[str, None] = None,
|
||||
|
||||
trainComposition: bool = False,
|
||||
includeEarlier: bool = False,
|
||||
withICTAlternatives: bool = False,
|
||||
tariff: bool = None, # type: ignore
|
||||
tariff: Union[bool, None] = None,
|
||||
trafficMessages: bool = False,
|
||||
travellerProfileData: str = None, # type: ignore
|
||||
travellerProfileData: Union[str, None] = None,
|
||||
withFreq: bool = True
|
||||
) -> dict:
|
||||
"""The trip service calculates a trip from a specified origin to a specified destination. These might be
|
||||
@@ -248,10 +248,6 @@ def trip_find(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/trip", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -14,31 +14,31 @@ def trip_recon(accessId: str,
|
||||
json: bool = True,
|
||||
poly: bool = False,
|
||||
polyEnc: Literal["DLT", "GPA", "N"] = "N",
|
||||
date: Union[str, datetime] = None, # type: ignore
|
||||
useCombinedComparison: bool = None, # type: ignore
|
||||
acceptGaps: bool = None, # type: ignore
|
||||
allowDummySections: bool = None, # type: ignore
|
||||
flagAllNonReachable: bool = None, # type: ignore
|
||||
matchCatStrict: bool = None, # type: ignore
|
||||
matchIdNonBlank: bool = None, # type: ignore
|
||||
matchIdStrict: bool = None, # type: ignore
|
||||
matchNumStrict: bool = None, # type: ignore
|
||||
matchRtType: bool = None, # type: ignore
|
||||
enableRtFullSearch: bool = None, # type: ignore
|
||||
enableReplacements: bool = None, # type: ignore
|
||||
arrL: int = None, # type: ignore
|
||||
arrU: int = None, # type: ignore
|
||||
depL: int = None, # type: ignore
|
||||
depU: int = None, # type: ignore
|
||||
date: Union[str, datetime, None] = None,
|
||||
useCombinedComparison: Union[bool, None] = None,
|
||||
acceptGaps: Union[bool, None] = None,
|
||||
allowDummySections: Union[bool, None] = None,
|
||||
flagAllNonReachable: Union[bool, None] = None,
|
||||
matchCatStrict: Union[bool, None] = None,
|
||||
matchIdNonBlank: Union[bool, None] = None,
|
||||
matchIdStrict: Union[bool, None] = None,
|
||||
matchNumStrict: Union[bool, None] = None,
|
||||
matchRtType: Union[bool, None] = None,
|
||||
enableRtFullSearch: Union[bool, None] = None,
|
||||
enableReplacements: Union[bool, None] = None,
|
||||
arrL: Union[int, None] = None,
|
||||
arrU: Union[int, None] = None,
|
||||
depL: Union[int, None] = None,
|
||||
depU: Union[int, None] = None,
|
||||
passlist: bool = False,
|
||||
showPassingPoints: bool = False,
|
||||
rtMode: Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"] = None, # type: ignore
|
||||
rtMode: Union[Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"], None] = None,
|
||||
eco: bool = False,
|
||||
ecoCmp: bool = False,
|
||||
ecoParams: str = None, # type: ignore
|
||||
tariff: bool = None, # type: ignore
|
||||
trafficMessages: bool = None, # type: ignore
|
||||
travellerProfileData: str = None # type: ignore
|
||||
ecoParams: Union[str, None] = None,
|
||||
tariff: Union[bool, None] = None,
|
||||
trafficMessages: Union[bool, None] = None,
|
||||
travellerProfileData: Union[str, None] = None
|
||||
) -> dict:
|
||||
"""Reconstructing a trip can be achieved using the reconstruction context provided by any trip result in the
|
||||
ctxRecon attribute of Trip element. The result will be a true copy of the original trip search result given
|
||||
@@ -102,10 +102,6 @@ def trip_recon(accessId: str,
|
||||
|
||||
output = get("https://www.rmv.de/hapi/recon", params=payload, headers=headers)
|
||||
|
||||
# Exceptions checker moved to normal methods
|
||||
# and exceptions will no longer raise in raw ones.
|
||||
# find_exception(output.json())
|
||||
|
||||
if json:
|
||||
return output.json()
|
||||
else:
|
||||
|
@@ -1,3 +1,3 @@
|
||||
requests
|
||||
xmltodict
|
||||
isodate
|
||||
requests~=2.31.0
|
||||
xmltodict~=0.13.0
|
||||
isodate~=0.6.1
|
18
setup.py
18
setup.py
@@ -2,10 +2,10 @@ from setuptools import setup
|
||||
|
||||
setup(
|
||||
name="pyrmv",
|
||||
version="0.3.0",
|
||||
version="0.3.5",
|
||||
author="Profitroll",
|
||||
description="Small module that makes your journey with RMV REST API somehow easier.",
|
||||
long_description="Small module that makes your journey with RMV REST API somehow easier. Based fully on official RMV API reference and HAFAS documentation.\n\n# Usage\n\n```py\nimport pyrmv\n\n# Define a Client with API key\nclient = pyrmv.Client(\"AcessId\")\n\n# Get origin's and destination's location\norigin = client.stop_by_name(\"Frankfurt Hauptbahnhof\", max_number=3)[0]\ndestination = client.stop_by_coords(50.099613, 8.685449, max_number=3)[0]\n\n# Find a trip by locations got\ntrip = client.trip_find(origin_id=origin.id, dest_id=destination.id)\n```\n\n# Frequently Asked Questions\n\n- Why are there raw versions and formatted ones?\n- Some methods work slightly different\n\n## Why are there raw versions and formatted ones?\n\nFor the purposes of my projects I don't really need all the stuff RMV gives (even though it's not much).\nI only need some specific things. However I do understand that in some cases other users may find\nthose methods quite useful so I implemented them as well.\n\n\n## Some methods work slightly different\n\nCan be. Not all function arguments written may work perfectly because I simply did not test each and\nevery request. Some of arguments may be irrelevant in my use-case and the others are used quite rare at all.\nJust [make an issue](https://git.end-play.xyz/profitroll/PythonRMV/issues/new) and I'll implement it correct when I'll have some free time.\n\n# To-Do\n## General\n- [ ] Docs in Wiki\n\n## Raw methods\n- [x] arrivalBoard (board_arrival) \n- [x] departureBoard (board_departure) \n- [x] himsearch (him_search) \n- [x] journeyDetail (journey_detail)\n- [x] location.nearbystops (stop_by_coords) \n- [x] location.name (stop_by_name) \n- [x] trip (trip_find) \n- [x] recon (trip_recon)\n\n## Normal methods\n- [x] arrivalBoard (board_arrival) \n- [x] departureBoard (board_departure) \n- [x] himsearch (him_search) \n- [x] journeyDetail (journey_detail)\n- [x] location.nearbystops (stop_by_coords) \n- [x] location.name (stop_by_name) \n- [x] trip (trip_find) \n- [x] recon (trip_recon)",
|
||||
long_description="Small module that makes your journey with RMV REST API somehow easier. Based fully on official RMV API reference and HAFAS documentation.\n\n## Requirements\n\n* RMV API key (Get it [here](https://opendata.rmv.de/site/start.html))\n* Python3 (Tested versions are 3.7.9 and 3.9.13)\n* git (Only for installation from source)\n\n## Installation\n\nIf you have everything listed in [requirements](#requirements), then let's begin.\n\n### Variant 1\n\n1. `python -m pip install pyrmv`\n\n### Variant 2\n\n1. `git clone https://git.end-play.xyz/profitroll/PythonRMV.git`\n2. `cd PythonRMV`\n3. `python setup.py install`\n\n## Usage\n\n```py\nimport pyrmv\n\n# Define a Client with API key\nclient = pyrmv.Client(\"AcessId\")\n\n# Get origin's and destination's location\norigin = client.stop_by_name(\"Frankfurt Hauptbahnhof\", max_number=3)[0]\ndestination = client.stop_by_coords(50.099613, 8.685449, max_number=3)[0]\n\n# Find a trip by locations got\ntrip = client.trip_find(origin_id=origin.id, dest_id=destination.id)\n```\n\n## Frequently Asked Questions\n\n* [Why are there raw versions and formatted ones?](#why-are-there-raw-versions-and-formatted-ones)\n* [Some methods work slightly different](#some-methods-work-slightly-different)\n\n### Why are there raw versions and formatted ones?\n\nFor the purposes of my projects I don't really need all the stuff RMV gives (even though it's not much).\nI only need some specific things. However I do understand that in some cases other users may find\nthose methods quite useful so I implemented them as well.\n\n### Some methods work slightly different\n\nCan be. Not all function arguments written may work perfectly because I simply did not test each and\nevery request. Some of arguments may be irrelevant in my use-case and the others are used quite rare at all.\nJust [make an issue](https://git.end-play.xyz/profitroll/PythonRMV/issues/new) and I'll implement it correct when I'll have some free time.\n\n## To-Do\n\n### General\n\n* [ ] Docs in Wiki\n* [ ] Tickets",
|
||||
long_description_content_type="text/markdown",
|
||||
author_email="profitroll@end-play.xyz",
|
||||
url="https://git.end-play.xyz/profitroll/PythonRMV",
|
||||
@@ -21,13 +21,9 @@ setup(
|
||||
"pyrmv.enums",
|
||||
"pyrmv.errors",
|
||||
"pyrmv.utility",
|
||||
"pyrmv.classes"
|
||||
],
|
||||
install_requires=[
|
||||
"requests",
|
||||
"xmltodict",
|
||||
"isodate"
|
||||
"pyrmv.classes",
|
||||
],
|
||||
install_requires=["requests", "xmltodict", "isodate"],
|
||||
classifiers=[
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
@@ -35,6 +31,6 @@ setup(
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
"Topic :: Utilities"
|
||||
]
|
||||
)
|
||||
"Topic :: Utilities",
|
||||
],
|
||||
)
|
||||
|
12
test.py
12
test.py
@@ -1,6 +1,6 @@
|
||||
from datetime import datetime, timedelta
|
||||
from os import makedirs
|
||||
from typing import Union
|
||||
from typing import Any
|
||||
from ujson import loads, dumps, JSONDecodeError
|
||||
from test_colors import *
|
||||
|
||||
@@ -24,7 +24,7 @@ except FileNotFoundError:
|
||||
print("To skip entering your key every time create file 'test_key.json' with your apikey as a value for 'key' dict key.", flush=True)
|
||||
|
||||
|
||||
def test(name: str, data: Union[str, dict], raw: bool = False) -> None:
|
||||
def test(name: str, data: Any, raw: bool = False) -> None:
|
||||
|
||||
makedirs("tests", exist_ok=True)
|
||||
|
||||
@@ -56,7 +56,7 @@ def test(name: str, data: Union[str, dict], raw: bool = False) -> None:
|
||||
file.close()
|
||||
|
||||
if data in ["", "\n"]:
|
||||
print(f"{BBLACK}[{BRED}ER{BBLACK}] {RESET}Test of {YELLOW}{name} {RESET}did not go well. ErrorCode is {BRED}{data['errorCode']}{RESET}. Check {CYAN}tests/{name}.txt {RESET}for more information.", flush=True)
|
||||
print(f"{BBLACK}[{BRED}ER{BBLACK}] {RESET}Test of {YELLOW}{name} {RESET}did not go well. ErrorCode is {BRED}{data['errorCode']}{RESET}. Check {CYAN}tests/{name}.txt {RESET}for more information.", flush=True) # type: ignore
|
||||
else:
|
||||
print(f"{BBLACK}[{BGREEN}OK{BBLACK}] {RESET}Test of {YELLOW}{name} {RESET}is not empty, so might be fine. Check {CYAN}tests/{name}.txt {RESET}for more information.", flush=True)
|
||||
|
||||
@@ -69,14 +69,14 @@ test("raw_journey_detail", pyrmv.raw.journey_detail(key, id="2|#VN#1#ST#16649065
|
||||
test("raw_stop_by_name", pyrmv.raw.stop_by_name(key, "Groß Karben", maxNo=3), raw=True)
|
||||
test("raw_stop_by_coords", pyrmv.raw.stop_by_coords(key, 50.131140, 8.733362, radius=300, maxNo=3), raw=True)
|
||||
test("raw_trip_find", pyrmv.raw.trip_find(key, originCoordLat="50.084659", originCoordLong="8.785948", destCoordLat=50.1233048, destCoordLong=8.6129742, trafficMessages=True, numF=3), raw=True)
|
||||
test("raw_trip_recon", pyrmv.raw.trip_recon(key, ctx="¶HKI¶G@F$A=2@O=50.084659, 8.785948@X=8785948@Y=50084659@u=0@a=128@$A=1@O=Offenbach (Main)-Tempelsee Wilhelm-Schramm-Straße@L=3008012@a=128@$202210061243$202210061247$$$1$$$$$$§T$A=1@O=Offenbach (Main)-Tempelsee Wilhelm-Schramm-Straße@L=3008012@a=128@$A=1@O=Offenbach (Main)-Zentrum Marktplatz\/Frankf. Straße@L=3002510@a=128@$202210061247$202210061300$Bus 101 $$1$$$$$$§W$A=1@O=Offenbach (Main)-Zentrum Marktplatz\/Frankf. Straße@L=3002510@a=128@$A=1@O=Offenbach (Main)-Zentrum Marktplatz@L=3011265@a=128@$202210061300$202210061304$$$1$$$$$$§T$A=1@O=Offenbach (Main)-Zentrum Marktplatz@L=3011265@a=128@$A=1@O=Frankfurt (Main) Taunusanlage@L=3000011@a=128@$202210061306$202210061319$ S2$$1$$$$$$§T$A=1@O=Frankfurt (Main) Taunusanlage@L=3000011@a=128@$A=1@O=Frankfurt (Main) Rödelheim Bahnhof@L=3001217@a=128@$202210061322$202210061333$ S5$$1$$$$$$§G@F$A=1@O=Frankfurt (Main) Rödelheim Bahnhof@L=3001217@a=128@$A=2@O=50.123304, 8.612974@X=8612974@Y=50123304@u=0@a=128@$202210061333$202210061344$$$1$$$$$$¶GP¶ft@0@2000@120@1@100@1@@0@@@@@false@0@-1@0@-1@-1@$f@$f@$f@$f@$f@$§bt@0@2000@120@1@100@1@@0@@@@@false@0@-1@0@-1@-1@$f@$f@$f@$f@$f@$§tt@0@2000@120@1@100@1@@0@@@@@false@0@-1@0@-1@-1@$f@$f@$f@$f@$f@$§¶KRCC¶#VE#1#"), raw=True)
|
||||
test("raw_trip_recon", pyrmv.raw.trip_recon(key, ctx="¶HKI¶G@F$A=2@O=50.084659, 8.785948@X=8785948@Y=50084659@u=0@a=128@$A=1@O=Offenbach (Main)-Tempelsee Wilhelm-Schramm-Straße@L=3008012@a=128@$202210061243$202210061247$$$1$$$$$$§T$A=1@O=Offenbach (Main)-Tempelsee Wilhelm-Schramm-Straße@L=3008012@a=128@$A=1@O=Offenbach (Main)-Zentrum Marktplatz/Frankf. Straße@L=3002510@a=128@$202210061247$202210061300$Bus 101 $$1$$$$$$§W$A=1@O=Offenbach (Main)-Zentrum Marktplatz/Frankf. Straße@L=3002510@a=128@$A=1@O=Offenbach (Main)-Zentrum Marktplatz@L=3011265@a=128@$202210061300$202210061304$$$1$$$$$$§T$A=1@O=Offenbach (Main)-Zentrum Marktplatz@L=3011265@a=128@$A=1@O=Frankfurt (Main) Taunusanlage@L=3000011@a=128@$202210061306$202210061319$ S2$$1$$$$$$§T$A=1@O=Frankfurt (Main) Taunusanlage@L=3000011@a=128@$A=1@O=Frankfurt (Main) Rödelheim Bahnhof@L=3001217@a=128@$202210061322$202210061333$ S5$$1$$$$$$§G@F$A=1@O=Frankfurt (Main) Rödelheim Bahnhof@L=3001217@a=128@$A=2@O=50.123304, 8.612974@X=8612974@Y=50123304@u=0@a=128@$202210061333$202210061344$$$1$$$$$$¶GP¶ft@0@2000@120@1@100@1@@0@@@@@false@0@-1@0@-1@-1@$f@$f@$f@$f@$f@$§bt@0@2000@120@1@100@1@@0@@@@@false@0@-1@0@-1@-1@$f@$f@$f@$f@$f@$§tt@0@2000@120@1@100@1@@0@@@@@false@0@-1@0@-1@-1@$f@$f@$f@$f@$f@$§¶KRCC¶#VE#1#"), raw=True)
|
||||
|
||||
test("board_arrival", client.board_arrival("A=1@O=Frankfurt (Main) Taunusanlage@X=8668765@Y=50113478@U=80@L=3000011@", journeys_max=5))
|
||||
test("board_departure", client.board_departure("A=1@O=Frankfurt (Main) Taunusanlage@X=8668765@Y=50113478@U=80@L=3000011@", journeys_max=5))
|
||||
test("board_departure", client.board_departure("A=1@O=Frankfurt (Main) Taunusanlage@X=8668765@Y=50113478@U=80@L=3000011@", journeys_max=5, retrieve_stops=False))
|
||||
test("him_search", client.him_search(date_end=datetime.now()+timedelta(days=10), priority_min=2, train_names=["S9"]))
|
||||
test("journey_detail", 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))
|
||||
test("stop_by_coords", client.stop_by_coords(50.131140, 8.733362, radius=300, max_number=3))
|
||||
test("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@"))
|
||||
test("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@"))
|
||||
test("stop_by_name", client.stop_by_name("Groß Karben", max_number=3))
|
||||
test("trip_find", 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))
|
||||
test("trip_recon", client.trip_recon( 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, trips_after_time=1)[0] ))
|
30
wiki/Client.md
Normal file
30
wiki/Client.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# PythonRMV Client
|
||||
You are now viewing the main class of the module, its heart. The main Client class, all available normal methods can be found here.
|
||||
|
||||
This page is about the Client class, which exposes high-level methods for an easy access to the API.
|
||||
|
||||
```py
|
||||
from pyrmv import Client
|
||||
|
||||
client = Client("SampleAPIKey")
|
||||
|
||||
print(client.stop_by_id("A=1@O=Offenbach (Main)-Zentrum Marktplatz\/Frankf. Straße@X=8764456@Y=50105181@U=80@L=3002510@"))
|
||||
```
|
||||
|
||||
# Details
|
||||
|
||||
## `class pyrmv.Client`
|
||||
|
||||
### Parameters
|
||||
* access_key (`str`) – Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
|
||||
|
||||
### Methods:
|
||||
* [board_arrival](https://git.end-play.xyz/profitroll/PythonRMV/wiki/board_arrival) -> `BoardArrival`
|
||||
* [board_departure](https://git.end-play.xyz/profitroll/PythonRMV/wiki/board_departure) -> `BoardDeparture`
|
||||
* [him_search](https://git.end-play.xyz/profitroll/PythonRMV/wiki/him_search) -> `List[Message]`
|
||||
* [journey_detail](https://git.end-play.xyz/profitroll/PythonRMV/wiki/journey_detail) -> `Journey`
|
||||
* [stop_by_coords](https://git.end-play.xyz/profitroll/PythonRMV/wiki/stop_by_coords) -> `List[Stop]`
|
||||
* [stop_by_id](https://git.end-play.xyz/profitroll/PythonRMV/wiki/stop_by_id) -> `Union[Stop, None]`
|
||||
* [stop_by_name](https://git.end-play.xyz/profitroll/PythonRMV/wiki/stop_by_name) -> `List[Stop]`
|
||||
* [trip_find](https://git.end-play.xyz/profitroll/PythonRMV/wiki/trip_find) -> `List[Trip]`
|
||||
* [trip_recon](https://git.end-play.xyz/profitroll/PythonRMV/wiki/trip_recon) -> `List[Trip]`
|
5
wiki/Home.md
Normal file
5
wiki/Home.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# PythonRMV
|
||||
|
||||
Welcome to the project's Wiki.
|
||||
|
||||
Conceptional there are two different types of methods. Normal and raw ones. Raw methods are only beautiful variant of HTTP requests, nothing except for that actually. Normal ones are meant to be used as objects. You can still provide strings here and there, but basic concept is focused on objects usage.
|
15
wiki/_Sidebar.md
Normal file
15
wiki/_Sidebar.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## [Home](https://git.end-play.xyz/profitroll/PythonRMV/wiki)
|
||||
|
||||
### Classes
|
||||
* [Client](https://git.end-play.xyz/profitroll/PythonRMV/wiki/Client)
|
||||
|
||||
### Methods
|
||||
* [board_arrival](https://git.end-play.xyz/profitroll/PythonRMV/wiki/board_arrival)
|
||||
* [board_departure](https://git.end-play.xyz/profitroll/PythonRMV/wiki/board_departure)
|
||||
* [him_search](https://git.end-play.xyz/profitroll/PythonRMV/wiki/him_search)
|
||||
* [journey_detail](https://git.end-play.xyz/profitroll/PythonRMV/wiki/journey_detail)
|
||||
* [stop_by_coords](https://git.end-play.xyz/profitroll/PythonRMV/wiki/stop_by_coords)
|
||||
* [stop_by_id](https://git.end-play.xyz/profitroll/PythonRMV/wiki/stop_by_id)
|
||||
* [stop_by_name](https://git.end-play.xyz/profitroll/PythonRMV/wiki/stop_by_name)
|
||||
* [trip_find](https://git.end-play.xyz/profitroll/PythonRMV/wiki/trip_find)
|
||||
* [trip_recon](https://git.end-play.xyz/profitroll/PythonRMV/wiki/trip_recon)
|
Reference in New Issue
Block a user