Compare commits
3 Commits
651d709e66
...
3a23c058c3
Author | SHA1 | Date | |
---|---|---|---|
3a23c058c3 | |||
4136bbcddb | |||
366497d8fb |
@ -1,2 +1,8 @@
|
|||||||
class Board():
|
class Board():
|
||||||
|
pass
|
||||||
|
|
||||||
|
class BoardArrival(Board):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class BoardDeparture(Board):
|
||||||
pass
|
pass
|
@ -3,4 +3,5 @@ from .rt_mode import RealTimeMode
|
|||||||
from .lang import Language
|
from .lang import Language
|
||||||
from .location_type import LocationType
|
from .location_type import LocationType
|
||||||
from .selection_mode import SelectionMode
|
from .selection_mode import SelectionMode
|
||||||
from .filter_mode import FilterMode
|
from .filter_mode import FilterMode
|
||||||
|
from .board_type import BoardArrivalType, BoardDepartureType
|
@ -3,6 +3,7 @@ from .board_departure import board_departure
|
|||||||
from .him_search import him_search
|
from .him_search import him_search
|
||||||
from .journey_detail import journey_detail
|
from .journey_detail import journey_detail
|
||||||
from .stop_by_coords import stop_by_coords
|
from .stop_by_coords import stop_by_coords
|
||||||
|
from .stop_by_id import stop_by_id
|
||||||
from .stop_by_name import stop_by_name
|
from .stop_by_name import stop_by_name
|
||||||
from .trip_find import trip_find
|
from .trip_find import trip_find
|
||||||
from .trip_recon import trip_recon
|
from .trip_recon import trip_recon
|
@ -1,12 +1,17 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from pyrmv.classes.Board import Board
|
from pyrmv.classes.Board import BoardArrival
|
||||||
from pyrmv.classes.Stop import Stop, StopTrip
|
from pyrmv.classes.Stop import Stop, StopTrip
|
||||||
from pyrmv.enums.board_type import BoardArrivalType
|
from pyrmv.enums.board_type import BoardArrivalType
|
||||||
from pyrmv.errors.not_ready import NotReadyYetError
|
from pyrmv.errors.not_ready import NotReadyYetError
|
||||||
from pyrmv.raw import board_arrival as raw_board_arrival
|
from pyrmv.raw import board_arrival as raw_board_arrival
|
||||||
from pyrmv.utility.find_exception import find_exception
|
from pyrmv.utility.find_exception import find_exception
|
||||||
|
|
||||||
|
try:
|
||||||
|
from typing import Literal
|
||||||
|
except ImportError:
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
def board_arrival(
|
def board_arrival(
|
||||||
|
|
||||||
access_id: str,
|
access_id: str,
|
||||||
@ -20,8 +25,8 @@ def board_arrival(
|
|||||||
operators: Union[str, list] = None,
|
operators: Union[str, list] = None,
|
||||||
lines: Union[str, list] = None,
|
lines: Union[str, list] = None,
|
||||||
passlist: bool = False,
|
passlist: bool = False,
|
||||||
board_type: Union[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION] = BoardArrivalType.ARR,
|
board_type: Literal[BoardArrivalType.ARR, BoardArrivalType.ARR_EQUIVS, BoardArrivalType.ARR_MAST, BoardArrivalType.ARR_STATION] = BoardArrivalType.ARR,
|
||||||
) -> Board:
|
) -> BoardArrival:
|
||||||
"""Method returns a board with arriving transport.
|
"""Method returns a board with arriving transport.
|
||||||
|
|
||||||
More detailed request is available as `raw.board_arrival()`, however returns `dict` instead of `Board`.
|
More detailed request is available as `raw.board_arrival()`, however returns `dict` instead of `Board`.
|
||||||
@ -41,7 +46,7 @@ def board_arrival(
|
|||||||
* 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`.
|
* 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`.
|
||||||
|
|
||||||
### Returns:
|
### Returns:
|
||||||
* Board: Instance of Board object.
|
* BoardArrival: Instance of BoardArrival object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
board_raw = raw_board_arrival(
|
board_raw = raw_board_arrival(
|
||||||
@ -62,4 +67,4 @@ def board_arrival(
|
|||||||
find_exception(board_raw)
|
find_exception(board_raw)
|
||||||
|
|
||||||
raise NotReadyYetError()
|
raise NotReadyYetError()
|
||||||
# return Board(board_raw)
|
# return BoardArrival(board_raw)
|
@ -1,12 +1,17 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from pyrmv.classes.Board import Board
|
from pyrmv.classes.Board import BoardDeparture
|
||||||
from pyrmv.classes.Stop import Stop, StopTrip
|
from pyrmv.classes.Stop import Stop, StopTrip
|
||||||
from pyrmv.enums.board_type import BoardDepartureType
|
from pyrmv.enums.board_type import BoardDepartureType
|
||||||
from pyrmv.errors.not_ready import NotReadyYetError
|
from pyrmv.errors.not_ready import NotReadyYetError
|
||||||
from pyrmv.raw import board_departure as raw_board_departure
|
from pyrmv.raw import board_departure as raw_board_departure
|
||||||
from pyrmv.utility.find_exception import find_exception
|
from pyrmv.utility.find_exception import find_exception
|
||||||
|
|
||||||
|
try:
|
||||||
|
from typing import Literal
|
||||||
|
except ImportError:
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
def board_departure(
|
def board_departure(
|
||||||
|
|
||||||
access_id: str,
|
access_id: str,
|
||||||
@ -20,8 +25,8 @@ def board_departure(
|
|||||||
operators: Union[str, list] = None,
|
operators: Union[str, list] = None,
|
||||||
lines: Union[str, list] = None,
|
lines: Union[str, list] = None,
|
||||||
passlist: bool = False,
|
passlist: bool = False,
|
||||||
board_type: Union[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION] = BoardDepartureType.DEP,
|
board_type: Literal[BoardDepartureType.DEP, BoardDepartureType.DEP_EQUIVS, BoardDepartureType.DEP_MAST, BoardDepartureType.DEP_STATION] = BoardDepartureType.DEP,
|
||||||
) -> Board:
|
) -> BoardDeparture:
|
||||||
"""Method returns a board with departing transport.
|
"""Method returns a board with departing transport.
|
||||||
|
|
||||||
More detailed request is available as `raw.board_departure()`, however returns `dict` instead of `Board`.
|
More detailed request is available as `raw.board_departure()`, however returns `dict` instead of `Board`.
|
||||||
@ -41,7 +46,7 @@ def board_departure(
|
|||||||
* 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`.
|
* 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`.
|
||||||
|
|
||||||
### Returns:
|
### Returns:
|
||||||
* Board: Instance of Board object.
|
* BoardDeparture: Instance of BoardDeparture object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
board_raw = raw_board_departure(
|
board_raw = raw_board_departure(
|
||||||
@ -62,4 +67,4 @@ def board_departure(
|
|||||||
find_exception(board_raw)
|
find_exception(board_raw)
|
||||||
|
|
||||||
raise NotReadyYetError()
|
raise NotReadyYetError()
|
||||||
# return Board(board_raw)
|
# return BoardDeparture(board_raw)
|
@ -0,0 +1,5 @@
|
|||||||
|
from pyrmv.errors.not_ready import NotReadyYetError
|
||||||
|
|
||||||
|
|
||||||
|
def him_search():
|
||||||
|
raise NotReadyYetError()
|
@ -39,7 +39,7 @@ def stop_by_coords(
|
|||||||
* 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`.
|
* 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:
|
### Returns:
|
||||||
* dict: Output from RMV. Dict will contain "errorCode" and "errorText" if exception occurs.
|
* List[Stop]: List of Stop objects. Empty list if none found.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if selection_mode == None:
|
if selection_mode == None:
|
||||||
|
48
pyrmv/methods/stop_by_id.py
Normal file
48
pyrmv/methods/stop_by_id.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
from typing import List, Union
|
||||||
|
from pyrmv.classes.Stop import Stop
|
||||||
|
from pyrmv.enums.lang import Language
|
||||||
|
from pyrmv.raw.stop_by_name import stop_by_name as raw_stop_by_name
|
||||||
|
from pyrmv.utility.find_exception import find_exception
|
||||||
|
|
||||||
|
try:
|
||||||
|
from typing import Literal
|
||||||
|
except ImportError:
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
|
def stop_by_id(
|
||||||
|
|
||||||
|
access_id: str,
|
||||||
|
query: str,
|
||||||
|
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,
|
||||||
|
) -> Union[Stop, None]:
|
||||||
|
"""Method can be used to get Stop object whilst only having id available.
|
||||||
|
|
||||||
|
### 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[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.
|
||||||
|
"""
|
||||||
|
|
||||||
|
stops_raw = raw_stop_by_name(
|
||||||
|
accessId=access_id,
|
||||||
|
inputString=query,
|
||||||
|
lang=lang.code,
|
||||||
|
maxNo=1
|
||||||
|
)
|
||||||
|
|
||||||
|
find_exception(stops_raw)
|
||||||
|
|
||||||
|
if len(stops_raw["stopLocationOrCoordLocation"]) > 0:
|
||||||
|
stop = stops_raw["stopLocationOrCoordLocation"][0]
|
||||||
|
|
||||||
|
if "StopLocation" in stop:
|
||||||
|
return Stop(stop["StopLocation"])
|
||||||
|
elif "CoordLocation" in stop:
|
||||||
|
return Stop(stop["CoordLocation"])
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return 0
|
@ -49,7 +49,7 @@ def stop_by_name(
|
|||||||
* filter_mode (`Literal[FilterMode.DIST_PERI, FilterMode.EXCL_PERI, FilterMode.SLCT_PERI]`, **optional**): Filter modes for nearby searches. Defaults to `FilterMode.DIST_PERI`.
|
* filter_mode (`Literal[FilterMode.DIST_PERI, FilterMode.EXCL_PERI, FilterMode.SLCT_PERI]`, **optional**): Filter modes for nearby searches. Defaults to `FilterMode.DIST_PERI`.
|
||||||
|
|
||||||
### Returns:
|
### Returns:
|
||||||
* dict: Output from RMV. Dict will contain "errorCode" and "errorText" if exception occurs.
|
* List[Stop]: List of Stop objects. Empty list if none found.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if selection_mode == None:
|
if selection_mode == None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user