This commit is contained in:
Profitroll 2022-09-28 15:21:07 +02:00
commit e5a608ff14
15 changed files with 298 additions and 76 deletions

View File

@ -26,6 +26,8 @@ __license__ = "MIT License"
__author__ = "Profitroll"
from . import raw
from . import const
from . import enums
from . import errors
from . import utility
from . import classes

0
pyrmv/const/__init__.py Normal file
View File

20
pyrmv/const/product.py Normal file
View File

@ -0,0 +1,20 @@
from typing import Dict
# Constant is taken from source of PyRMVtransport:
# https://github.com/cgtobi/PyRMVtransport/blob/development/RMVtransport/const.py
PRODUCTS: Dict[str, int] = {
"ice": 1,
"ic": 2,
"ec": 2,
"r": 4,
"rb": 4,
"re": 4,
"sbahn": 8,
"ubahn": 16,
"tram": 32,
"bus": 64,
"bus2": 128,
"ferry": 256,
"taxi": 512,
"bahn": 1024,
}

6
pyrmv/enums/__init__.py Normal file
View File

@ -0,0 +1,6 @@
from .product import Product
from .rt_mode import RealTimeMode
from .lang import Language
from .location_type import LocationType
from .selection_mode import SelectionMode
from .filter_mode import FilterMode

19
pyrmv/enums/auto_name.py Normal file
View File

@ -0,0 +1,19 @@
# Class is taken from source code of Pyrogram:
# https://github.com/pyrogram/pyrogram/blob/master/pyrogram/enums/auto_name.py
from enum import Enum
from pyrmv.const.product import PRODUCTS
class AutoName(Enum):
def __init__(self, code) -> None:
self.code = code
def _generate_next_value_(self, *args):
return self.lower()
def __repr__(self):
return f"pyrmv.enums.{self}"
class AutoNameProduct(AutoName):
def __init__(self, code) -> None:
self.code = PRODUCTS[code]

View File

@ -0,0 +1,14 @@
from enum import auto
from .auto_name import AutoName
class FilterMode(AutoName):
"""Enumeration used to declare filters for nearby searches."""
DIST_PERI = auto()
"Accentuate matches. Matches in the radius are first."
EXCL_PERI = auto()
"Returns matches inside the radius only."
SLCT_PERI = auto()
"Matches in the radius are excluded. Returns matches outside the radius only."

41
pyrmv/enums/lang.py Normal file
View File

@ -0,0 +1,41 @@
from enum import auto
from .auto_name import AutoName
class Language(AutoName):
"""Enumeration used to declare locales as ISO-3166 codes (but only available in HAFAS ones)."""
DE = auto()
"German"
DA = auto()
"Danish"
EN = auto()
"English"
ES = auto()
"Spanish"
FR = auto()
"French"
HU = auto()
"Hungarian"
IT = auto()
"Italian"
NL = auto()
"Dutch"
NO = auto()
"Norwegian"
PL = auto()
"Polish"
SV = auto()
"Swedish"
TR = auto()
"Turkish"

View File

@ -0,0 +1,32 @@
from enum import auto
from .auto_name import AutoName
class LocationType(AutoName):
"""Enumeration used to declare types of location filter."""
S = auto()
"Search for station/stops only"
A = auto()
"Search for addresses only"
P = auto()
"Search for POIs only"
AP = auto()
"Search for addresses and POIs"
SA = auto()
"Search for station/stops and addresses"
SE = auto()
"Search for stations/stops and entrypoints"
SP = auto()
"Search for stations/stops and POIs"
ALL = auto()
"Search in all existing location pools"
SPE = auto()
"Search for stations/stops, POIs and entrypoints"

47
pyrmv/enums/product.py Normal file
View File

@ -0,0 +1,47 @@
from enum import auto
from .auto_name import AutoNameProduct
class Product(AutoNameProduct):
"""Enumeration used to declare types of transport."""
ICE = auto()
"The Intercity Express (commonly known as ICE) is a system of high-speed trains predominantly running in Germany."
IC = auto()
"InterCity (commonly abbreviated IC on timetables and tickets) is the classification applied to certain long-distance passenger train services in Europe. Such trains (in contrast to regional, local, or commuter trains) generally call at major stations only."
EC = auto()
"EuroCity, abbreviated as EC, is a cross-border train category within the European inter-city rail network. In contrast to trains allocated to the lower-level \"IC\" (InterCity) category, EC trains are international services that meet 20 criteria covering comfort, speed, food service, and cleanliness."
R = auto()
"Regional rail, also known as local trains and stopping trains, are passenger rail services that operate between towns and cities. These trains operate with more stops over shorter distances than inter-city rail, but fewer stops and faster service than commuter rail."
RB = auto()
"The Regionalbahn (lit. Regional train; abbreviated RB) is a type of local passenger train (stopping train) in Germany. It is similar to the Regionalzug (R) and Regio (R) train categories in neighboring Austria and Switzerland, respectively."
RE = auto()
"In Germany, Luxembourg and Austria, the Regional-Express (RE, or in Austria: REX) is a type of regional train. It is similar to a semi-fast train, with average speed at about 70-90 km/h (top speed often 160 km/h) as it calls at fewer stations than Regionalbahn or S-Bahn trains, but stops more often than InterCity services."
SBAHN = auto()
"The S-Bahn is the name of hybrid urban-suburban rail systems serving a metropolitan region in German-speaking countries. Some of the larger S-Bahn systems provide service similar to rapid transit systems, while smaller ones often resemble commuter or even regional rail. The term derives from Schnellbahn, Stadtbahn or Stadtschnellbahn."
UBAHN = auto()
"A U-Bahn (short for subway, underground express train or metropolitan) is a usually underground, rail-bound means of transport for urban public transport (ÖPNV, city transport)."
TRAM = auto()
"A tram (also known as a streetcar or trolley in North America) is a rail vehicle that travels on tramway tracks on public urban streets; some include segments on segregated right-of-way."
BUS = auto()
"A bus (contracted from omnibus, with variants multibus, motorbus, autobus, etc.) is a road vehicle that carries significantly more passengers than an average car or van."
BUS2 = auto()
"Also a bus, but now idea why it exists anyway."
FERRY = auto()
"A ferry is a ship used to carry passengers, and sometimes vehicles and cargo, across a body of water."
TAXI = auto()
"A taxi, also known as a taxicab or simply a cab, is a type of vehicle for hire with a driver, used by a single passenger or small group of passengers, often for a non-shared ride."
BAHN = auto()
"Rail transport (also known as train transport) is a means of transport that transfers passengers and goods on wheeled vehicles running on rails, which are located on tracks. In contrast to road transport, where the vehicles run on a prepared flat surface, rail vehicles (rolling stock) are directionally guided by the tracks on which they run."

20
pyrmv/enums/rt_mode.py Normal file
View File

@ -0,0 +1,20 @@
from enum import auto
from .auto_name import AutoName
class RealTimeMode(AutoName):
"""Enumeration used to declare types of real-time traffic."""
FULL = auto()
"Combined search on planned and real-time data This search consists of two steps: i. Search on scheduled data ii. If the result of step (i) contains a non-feasible connection, a search on real-time data is performed and all results are combined"
INFOS = auto()
"Search on planned data, use real-time information for display only: Connections are computed on the basis of planned data. Delays and feasibility of the connections are integrated into the result. Note that additional trains (supplied via realtime feed) will not be part of the resulting connections."
OFF = auto()
"Search on planned data, ignore real-time information completely: Connections are computed on the basis of planned data. No real-time information is shown."
REALTIME = auto()
"Search on real-time data: Connections are computed on the basis of real-time data, using planned schedule only whenever no real-time data is available. All connections computed are feasible with respect to the currently known real-time situation. Additional trains (supplied via real-time feed) will be found if these are part of a fast, comfortable, or direct connection (or economic connection, if economic search is activated)."
SERVER_DEFAULT = auto()
"One of the other real-times modes used by default for RMV."

View File

@ -0,0 +1,11 @@
from enum import auto
from .auto_name import AutoName
class SelectionMode(AutoName):
"""Enumeration used to declare location selection modes."""
SLCT_A = auto()
"Selectable"
SLCT_N = auto()
"Not selectable"

View File

@ -1,5 +1,8 @@
from typing import List, Union
from pyrmv.classes.Stop import Stop
from pyrmv.enums.location_type import LocationType
from pyrmv.enums.lang import Language
from pyrmv.enums.selection_mode import SelectionMode
from pyrmv.raw.stop_by_coords import stop_by_coords as raw_stop_by_coords
try:
@ -13,11 +16,11 @@ def stop_by_coords(
coords_lat: Union[str, float],
coords_lon: Union[str, float],
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "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] = Language.EN,
radius: Union[int, float] = 1000,
max_number: int = 10,
stop_type: Literal["S", "P", "SP", "SE", "SPE"] = "S",
selection_mode: Literal["SLCT_N", "SLCT_A"] = None, # type: ignore
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
) -> 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.
@ -28,11 +31,11 @@ def stop_by_coords(
* access_id (`str`): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
* coords_lat (`Union[str, float]`): Latitude of centre coordinate.
* coords_lon (`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".
* radius (`Union[int, float]`, **optional**): Search radius in meter around the given coordinate if any. Defaults to 1000.
* max_number (`int`, **optional**): Maximum number of returned stops. Defaults to 10.
* stop_type (`Literal["S", "P", "SP", "SE", "SPE"]`, **optional**): Type filter for location types. Defaults to "S".
* selection_mode (`Literal["SLCT_N", "SLCT_A"]`, **optional**): Selection mode for locations. Defaults to None.
* 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`.
* radius (`Union[int, float]`, **optional**): Search radius in meter around the given coordinate if any. Defaults to `1000`.
* max_number (`int`, **optional**): Maximum number of returned stops. Defaults to `10`.
* stop_type (`Literal[LocationType.S, LocationType.P, LocationType.SP, LocationType.SE, LocationType.SPE]`, **optional**): Type filter for location types. Defaults to `LocationType.S`.
* selection_mode (`Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N]`, **optional**): Selection mode for locations. `SelectionMode.SLCT_N`: Not selectable, `SelectionMode.SLCT_A`: Selectable. Defaults to `None`.
### Returns:
* dict: Output from RMV. Dict will contain "errorCode" and "errorText" if exception occurs.
@ -43,11 +46,11 @@ def stop_by_coords(
accessId=access_id,
originCoordLat=coords_lat,
originCoordLong=coords_lon,
lang=lang,
lang=lang.code,
radius=radius,
maxNo=max_number,
stopType=stop_type,
locationSelectionMode=selection_mode
stopType=(stop_type.code).upper(),
locationSelectionMode=(selection_mode.code).upper()
)
for stop in stops_raw["stopLocationOrCoordLocation"]:

View File

@ -1,5 +1,9 @@
from typing import List, Union
from pyrmv.classes.Stop import Stop
from pyrmv.enums.location_type import LocationType
from pyrmv.enums.lang import Language
from pyrmv.enums.selection_mode import SelectionMode
from pyrmv.enums.filter_mode import FilterMode
from pyrmv.raw.stop_by_name import stop_by_name as raw_stop_by_name
try:
@ -12,16 +16,16 @@ def stop_by_name(
access_id: str,
query: str,
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "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] = Language.EN,
max_number: int = 10,
stop_type: Literal["A", "ALL", "AP", "P", "S", "SA", "SP"] = "ALL",
selection_mode: Literal["SLCT_N", "SLCT_A"] = None, # type: ignore
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
radius: Union[int, float] = 1000,
refine_id: str = None, # type: ignore
stations: Union[str, list] = None, # type: ignore
filter_mode: Literal["DIST_PERI", "EXCL_PERI", "SLCT_PERI"] = "DIST_PERI"
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
of possible matches in the journey planner database. Possible matches might be stops/stations,
@ -30,18 +34,18 @@ def stop_by_name(
More detailed request is available as raw.stop_by_name(), however returns dict instead of List[Stop].
### Args:
* access_id (str): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
* query (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".
* max_number (int, optional): Maximum number of returned stops. In range 1-1000. Defaults to 10.
* stop_type (Literal["A", "ALL", "AP", "P", "S", "SA", "SP"], optional): Type filter for location types. Defaults to "ALL".
* selection_mode (str, optional): Selection mode for locations. "SLCT_N": Not selectable, "SLCT_A": Selectable. Defaults to None.
* coord_lat (Union[str, float], optional): Latitude of centre coordinate. Defaults to None.
* coord_lon (Union[str, float], optional): Longitude of centre coordinate. Defaults to None.
* radius (Union[int, float], optional): Search radius in meter around the given coordinate if any. Defaults to 1000.
* refine_id (str, optional): In case of an refinable location, this value takes the ID of the refinable one of a previous result. Defaults to None.
* stations (Union[str, list], optional): Filter for stations. Matches if the given value is prefix of any station in the itinerary. As a list or as a string separated by comma. Defaults to None.
* filter_mode (Literal["DIST_PERI", "EXCL_PERI", "SLCT_PERI"], optional): Filter modes for nearby searches. Defaults to "DIST_PERI".
* access_id (`str`): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
* query (`str`): Search for that token.
* 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`.
* max_number (`int`, **optional**): Maximum number of returned stops. In range 1-1000. Defaults to `10`.
* stop_type (`Literal[LocationType.A, LocationType.ALL, LocationType.AP, LocationType.P, LocationType.S, LocationType.SA, LocationType.SP]`, **optional**): Type filter for location types. Defaults to `LocationType.ALL`.
* selection_mode (`Literal[SelectionMode.SLCT_A, SelectionMode.SLCT_N]`, **optional**): Selection mode for locations. `SelectionMode.SLCT_N`: Not selectable, `SelectionMode.SLCT_A`: Selectable. Defaults to `None`.
* coord_lat (`Union[str, float]`, **optional**): Latitude of centre coordinate. Defaults to `None`.
* coord_lon (`Union[str, float]`, **optional**): Longitude of centre coordinate. Defaults to `None`.
* radius (`Union[int, float]`, **optional**): Search radius in meter around the given coordinate if any. Defaults to `1000`.
* refine_id (`str`, **optional**): In case of an refinable location, this value takes the ID of the refinable one of a previous result. Defaults to `None`.
* stations (`Union[str, list]`, **optional**): Filter for stations. Matches if the given value is prefix of any station in the itinerary. As a list or as a string separated by comma. Defaults to `None`.
* filter_mode (`Literal[FilterMode.DIST_PERI, FilterMode.EXCL_PERI, FilterMode.SLCT_PERI]`, **optional**): Filter modes for nearby searches. Defaults to `FilterMode.DIST_PERI`.
### Returns:
* dict: Output from RMV. Dict will contain "errorCode" and "errorText" if exception occurs.
@ -51,10 +55,10 @@ def stop_by_name(
stops_raw = raw_stop_by_name(
accessId=access_id,
inputString=query,
lang=lang,
lang=lang.code,
maxNo=max_number,
stopType=stop_type,
locationSelectionMode=selection_mode,
stopType=(stop_type.code).upper(),
locationSelectionMode=(selection_mode.code).upper(),
coordLat=coord_lat,
coordLong=coord_lon,
radius=radius,

View File

@ -2,6 +2,8 @@ from datetime import datetime
from typing import List, Union
from pyrmv.classes.Trip import Trip
from pyrmv.raw.trip_find import trip_find as raw_trip_find
from pyrmv.enums.rt_mode import RealTimeMode
from pyrmv.enums.lang import Language
try:
from typing import Literal
@ -11,7 +13,7 @@ except ImportError:
def trip_find(
access_id: str,
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "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] = Language.EN,
origin_id: str = None, # type: ignore
origin_id_ext: str = None, # type: ignore
@ -62,7 +64,7 @@ def trip_find(
passing_points: bool = False,
real_time_mode: Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"] = None, # type: ignore
real_time_mode: Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT] = None, # type: ignore
include_earlier: bool = False,
ict_alternatives: bool = False,
@ -78,48 +80,48 @@ def trip_find(
### Args:
* access_id (`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".
* origin_id (`str`, **optional**): Specifies the station/stop ID of the origin for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). Defaults to None.
* origin_id_ext (`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 stop_by_name() or stop_by_coords(). Defaults to None.
* origin_coord_lat (`Union[str, float]`, **optional**): Latitude of station/stop coordinate of the trip's origin. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to None.
* origin_coord_lon (`Union[str, float]`, **optional**): Longitude of station/stop coordinate of the trip's origin. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to None.
* origin_coord_name (`str`, **optional**): Name of the trip's origin if coordinate cannot be resolved to an address or poi. Defaults to None.
* destination_id (`str`, **optional**): Specifies the station/stop ID of the destination for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). Defaults to None.
* destination_id_ext (`str`, **optional**): Deprecated. Please use destId as it supports external IDs. Specifies the external station/stop ID of the destination for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). Defaults to None.
* destination_coord_lat (`Union[str, float]`, **optional**): Latitude of station/stop coordinate of the trip's destination. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to None.
* destination_coord_lon (`Union[str, float]`, **optional**): Longitude of station/stop coordinate of the trip's destination. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to None.
* destination_coord_name (`str`, **optional**): Name of the trip's destination if coordinate cannot be resolved to an address or poi. Defaults to None.
* via (`str`, **optional**): Complex structure to provide multiple via points separated by semicolon. This structure is build like this: `viaId|waittime|viastatus|products|direct|sleepingCar|couchetteCoach|attributes`. Read more about this in HAFAS ReST Documentation. Defaults to None.
* via_id (`str`, **optional**): ID of a station/stop used as a via for the trip. Specifying a via station forces the trip search to look for trips which must pass through this station. Such ID can be retrieved from stop_by_name() or stop_by_coords(). If `via` is used, `via_id` and `via_wait_time ` are having no effect. Defaults to None.
* via_gis (`str`, **optional**): Complex structure to provide multiple GIS via locations separated by semicolon. This structure is build like this: `locationId|locationMode|transportMode|placeType|usageType|mode|durationOfStay`. Read more about this in HAFAS ReST Documentation. Defaults to None.
* 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`.
* origin_id (`str`, **optional**): Specifies the station/stop ID of the origin for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). Defaults to `None`.
* origin_id_ext (`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 stop_by_name() or stop_by_coords(). Defaults to `None`.
* origin_coord_lat (`Union[str, float]`, **optional**): Latitude of station/stop coordinate of the trip's origin. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to `None`.
* origin_coord_lon (`Union[str, float]`, **optional**): Longitude of station/stop coordinate of the trip's origin. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to `None`.
* origin_coord_name (`str`, **optional**): Name of the trip's origin if coordinate cannot be resolved to an address or poi. Defaults to `None`.
* destination_id (`str`, **optional**): Specifies the station/stop ID of the destination for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). Defaults to `None`.
* destination_id_ext (`str`, **optional**): Deprecated. Please use destId as it supports external IDs. Specifies the external station/stop ID of the destination for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). Defaults to `None`.
* destination_coord_lat (`Union[str, float]`, **optional**): Latitude of station/stop coordinate of the trip's destination. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to `None`.
* destination_coord_lon (`Union[str, float]`, **optional**): Longitude of station/stop coordinate of the trip's destination. The coordinate can be retrieved from stop_by_name() or stop_by_coords(). Defaults to `None`.
* destination_coord_name (`str`, **optional**): Name of the trip's destination if coordinate cannot be resolved to an address or poi. Defaults to `None`.
* via (`str`, **optional**): Complex structure to provide multiple via points separated by semicolon. This structure is build like this: `viaId|waittime|viastatus|products|direct|sleepingCar|couchetteCoach|attributes`. Read more about this in HAFAS ReST Documentation. Defaults to `None`.
* via_id (`str`, **optional**): ID of a station/stop used as a via for the trip. Specifying a via station forces the trip search to look for trips which must pass through this station. Such ID can be retrieved from stop_by_name() or stop_by_coords(). If `via` is used, `via_id` and `via_wait_time ` are having no effect. Defaults to `None`.
* via_gis (`str`, **optional**): Complex structure to provide multiple GIS via locations separated by semicolon. This structure is build like this: `locationId|locationMode|transportMode|placeType|usageType|mode|durationOfStay`. Read more about this in HAFAS ReST Documentation. Defaults to `None`.
* via_wait_time (`int`, **optional**): Defines the waiting time spent at via station in minutes. If `via` is used, `via_id` and `via_wait_time` are having no effect. Defaults to 0.
* avoid (`str`, **optional**): Complex structure to provide multiple points to be avoided separated by semicolon. This structure is build like this: `avoidId|avoidstatus` avoidId: id, extId or altId of the avoid, mandatory avoidstatus: one of NPAVM (do not run through if this is a meta station), NPAVO (do not run through), NCAVM (do not change if this is a meta station), NCAVO (do not change), optional but defaults to NCAVM Example: Just define three avoids by extId: `avoid="801234;801235;801236"`. Defaults to None.
* avoid_id (`str`, **optional**): ID of a station/stop to be avoided as transfer stop for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). If `avoid` is used, `avoid_id` has no effect. Defaults to None.
* change_time_percent (`int`, **optional**): Configures the walking speed when changing from one leg of the journey to the next one. It extends the time required for changes by a specified percentage. A value of 200 doubles the change time as initially calculated by the system. In the response, change time is presented in full minutes. If the calculation based on changeTime-Percent does not result in a full minute, it is rounded using "round half up" method. Defaults to 100.
* change_time_min (`int`, **optional**): Minimum change time at stop in minutes. Defaults to None.
* change_time_max (`int`, **optional**): Maximum change time at stop in minutes. Defaults to None.
* change_time_add (`int`, **optional**): This amount of minutes is added to the change time at each stop. Defaults to None.
* change_max (`int`, **optional**): Maximum number of changes. In range 0-11. Defaults to None.
* date (`str`, **optional**): Sets the start date for which the departures shall be retrieved. Represented in the format `YYYY-MM-DD`. By default the current server date is used. Defaults to None.
* time (`str`, **optional**): Sets the start time for which the departures shall be retrieved. Represented in the format `hh:mm[:ss]` in 24h nomenclature. Seconds will be ignored for requests. By default the current server time is used. Defaults to None.
* search_arrival (`bool`, **optional**): If set, the date and time parameters specify the arrival time for the trip search instead of the departure time. Defaults to False.
* trips_after_time (`int`, **optional**): Minimum number of trips after the search time. Sum of `trips_after_time` and `trips_before_time` has to be less or equal 6. Read more about this in HAFAS ReST Documentation. In range 1-6. Defaults to None.
* trips_before_time (`int`, **optional**): Minimum number of trips before the search time. Sum of `trips_after_time` and `trips_before_time` has to be less or equal 6. Read more about this in HAFAS ReST Documentation. In range 0-6. Defaults to None.
* context (`str`, **optional**): Defines the starting point for the scroll back or forth operation. Use the scrB value from a previous result to scroll backwards in time and use the scrF value to scroll forth. Defaults to None.
* passlist (`bool`, **optional**): Enables/disables the return of the passlist for each leg of the trip. Defaults to False.
* operators (`Union[str, list]`, **optional**): Only trips provided by the given operators are part of the result. If the operator should not be part of the be trip, negate it by putting ! in front of it. Example: Filter for operator A and B: `operators=["A","B"]`. Defaults to None.
* lines (`Union[str, list]`, **optional**): Only journeys running the given line are part of the result. If the line should not be part of the be trip, negate it by putting ! in front of it. Defaults to None.
* lineids (`Union[str, list]`, **optional**): Only journeys running the given line (identified by its line ID) are part of the result. If the line should not be part of the be trip, negate it by putting ! in front of it. Defaults to None.
* iv_include (`bool`, **optional**): Enables/disables search for individual transport routes. Defaults to False.
* iv_only (`bool`, **optional**): Enables/disables search for individual transport routes only. Defaults to False.
* bike_carriage (`bool`, **optional**): Enables/disables search for trips explicit allowing bike carriage. This will only work in combination with `change_max=0` as those trips are always meant to be direct connections. Defaults to False.
* passing_points (`bool`, **optional**): Enables/disables the return of stops having no alighting and boarding in its passlist for each leg of the trip. Needs passlist enabled. Defaults to False.
* real_time_mode (`Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"]`, **optional**): Set the realtime mode to be used. Read more about this in HAFAS ReST Documentation. Defaults to None.
* include_earlier (`bool`, **optional**): Disables search optimization in relation of duration. Defaults to False.
* ict_alternatives (`bool`, **optional**): Enables/disables the search for alternatives with individualized change times (ICT). Defaults to False.
* tariff (`bool`, **optional**): Enables/disables the output of tariff data. The default is configurable via provisioning. Defaults to None.
* messages (`bool`, **optional**): Enables/disables the output of traffic messages. The default is configurable via provisioning. Defaults to False.
* frequency (`bool`, **optional**): Enables/disables the calculation of frequency information. Defaults to True.
* avoid (`str`, **optional**): Complex structure to provide multiple points to be avoided separated by semicolon. This structure is build like this: `avoidId|avoidstatus` avoidId: id, extId or altId of the avoid, mandatory avoidstatus: one of NPAVM (do not run through if this is a meta station), NPAVO (do not run through), NCAVM (do not change if this is a meta station), NCAVO (do not change), optional but defaults to NCAVM Example: Just define three avoids by extId: `avoid="801234;801235;801236"`. Defaults to `None`.
* avoid_id (`str`, **optional**): ID of a station/stop to be avoided as transfer stop for the trip. Such ID can be retrieved from stop_by_name() or stop_by_coords(). If `avoid` is used, `avoid_id` has no effect. Defaults to `None`.
* change_time_percent (`int`, **optional**): Configures the walking speed when changing from one leg of the journey to the next one. It extends the time required for changes by a specified percentage. A value of 200 doubles the change time as initially calculated by the system. In the response, change time is presented in full minutes. If the calculation based on changeTime-Percent does not result in a full minute, it is rounded using "round half up" method. Defaults to `100`.
* change_time_min (`int`, **optional**): Minimum change time at stop in minutes. Defaults to `None`.
* change_time_max (`int`, **optional**): Maximum change time at stop in minutes. Defaults to `None`.
* change_time_add (`int`, **optional**): This amount of minutes is added to the change time at each stop. Defaults to `None`.
* change_max (`int`, **optional**): Maximum number of changes. In range 0-11. Defaults to `None`.
* date (`str`, **optional**): Sets the start date for which the departures shall be retrieved. Represented in the format `YYYY-MM-DD`. By default the current server date is used. Defaults to `None`.
* time (`str`, **optional**): Sets the start time for which the departures shall be retrieved. Represented in the format `hh:mm[:ss]` in 24h nomenclature. Seconds will be ignored for requests. By default the current server time is used. Defaults to `None`.
* search_arrival (`bool`, **optional**): If set, the date and time parameters specify the arrival time for the trip search instead of the departure time. Defaults to `False`.
* trips_after_time (`int`, **optional**): Minimum number of trips after the search time. Sum of `trips_after_time` and `trips_before_time` has to be less or equal 6. Read more about this in HAFAS ReST Documentation. In range 1-6. Defaults to `None`.
* trips_before_time (`int`, **optional**): Minimum number of trips before the search time. Sum of `trips_after_time` and `trips_before_time` has to be less or equal 6. Read more about this in HAFAS ReST Documentation. In range 0-6. Defaults to `None`.
* context (`str`, **optional**): Defines the starting point for the scroll back or forth operation. Use the scrB value from a previous result to scroll backwards in time and use the scrF value to scroll forth. Defaults to `None`.
* passlist (`bool`, **optional**): Enables/disables the return of the passlist for each leg of the trip. Defaults to `False`.
* operators (`Union[str, list]`, **optional**): Only trips provided by the given operators are part of the result. If the operator should not be part of the be trip, negate it by putting ! in front of it. Example: Filter for operator A and B: `operators=["A","B"]`. Defaults to `None`.
* lines (`Union[str, list]`, **optional**): Only journeys running the given line are part of the result. If the line should not be part of the be trip, negate it by putting ! in front of it. Defaults to `None`.
* lineids (`Union[str, list]`, **optional**): Only journeys running the given line (identified by its line ID) are part of the result. If the line should not be part of the be trip, negate it by putting ! in front of it. Defaults to `None`.
* iv_include (`bool`, **optional**): Enables/disables search for individual transport routes. Defaults to `False`.
* iv_only (`bool`, **optional**): Enables/disables search for individual transport routes only. Defaults to `False`.
* bike_carriage (`bool`, **optional**): Enables/disables search for trips explicit allowing bike carriage. This will only work in combination with `change_max=0` as those trips are always meant to be direct connections. Defaults to `False`.
* passing_points (`bool`, **optional**): Enables/disables the return of stops having no alighting and boarding in its passlist for each leg of the trip. Needs passlist enabled. Defaults to `False`.
* real_time_mode (`Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT]`, **optional**): Set the realtime mode to be used. Read more about this in HAFAS ReST Documentation. Defaults to `None`.
* include_earlier (`bool`, **optional**): Disables search optimization in relation of duration. Defaults to `False`.
* ict_alternatives (`bool`, **optional**): Enables/disables the search for alternatives with individualized change times (ICT). Defaults to `False`.
* tariff (`bool`, **optional**): Enables/disables the output of tariff data. The default is configurable via provisioning. Defaults to `None`.
* messages (`bool`, **optional**): Enables/disables the output of traffic messages. The default is configurable via provisioning. Defaults to `False`.
* frequency (`bool`, **optional**): Enables/disables the calculation of frequency information. Defaults to `True`.
### Returns:
* List[Trip]: List of Trip objects. Empty list if none found.
@ -129,7 +131,7 @@ def trip_find(
trips_raw = raw_trip_find(
accessId=access_id,
lang=lang,
lang=lang.code,
originId=origin_id,
originExtId=origin_id_ext,
@ -180,7 +182,7 @@ def trip_find(
showPassingPoints=passing_points,
rtMode=real_time_mode,
rtMode=(real_time_mode.code).upper(),
includeEarlier=include_earlier,
withICTAlternatives=ict_alternatives,

View File

@ -17,6 +17,7 @@ setup(
packages=[
"pyrmv",
"pyrmv.raw",
"pyrmv.const",
"pyrmv.errors",
"pyrmv.methods",
"pyrmv.utility",
@ -28,7 +29,7 @@ setup(
"isodate"
],
classifiers=[
"Development Status :: 1 - Planning",
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",