From 201fcba766beb9723a650183e1ed77a730ae348e Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 6 Oct 2022 15:04:03 +0200 Subject: [PATCH] him_search() WIP --- pyrmv/enums/__init__.py | 5 +++- pyrmv/enums/aff_journey_mode.py | 11 ++++++++ pyrmv/enums/aff_journey_stop_mode.py | 14 ++++++++++ pyrmv/enums/search_mode.py | 14 ++++++++++ pyrmv/methods/him_search.py | 39 +++++++++++++++++++++++++++- 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 pyrmv/enums/aff_journey_mode.py create mode 100644 pyrmv/enums/aff_journey_stop_mode.py create mode 100644 pyrmv/enums/search_mode.py diff --git a/pyrmv/enums/__init__.py b/pyrmv/enums/__init__.py index d31d73b..425b262 100644 --- a/pyrmv/enums/__init__.py +++ b/pyrmv/enums/__init__.py @@ -3,5 +3,8 @@ from .rt_mode import RealTimeMode from .lang import Language from .location_type import LocationType from .selection_mode import SelectionMode +from .search_mode import SearchMode from .filter_mode import FilterMode -from .board_type import BoardArrivalType, BoardDepartureType \ No newline at end of file +from .board_type import BoardArrivalType, BoardDepartureType +from .aff_journey_mode import AffectedJourneyMode +from .aff_journey_stop_mode import AffectedJourneyStopMode \ No newline at end of file diff --git a/pyrmv/enums/aff_journey_mode.py b/pyrmv/enums/aff_journey_mode.py new file mode 100644 index 0000000..cf67c93 --- /dev/null +++ b/pyrmv/enums/aff_journey_mode.py @@ -0,0 +1,11 @@ +from enum import auto +from .auto_name import AutoName + +class AffectedJourneyMode(AutoName): + """Enumeration used to declare types of HIM search modes.""" + + ALL = auto() + "Return affected journeys." + + OFF = auto() + "Do not return affected journeys." \ No newline at end of file diff --git a/pyrmv/enums/aff_journey_stop_mode.py b/pyrmv/enums/aff_journey_stop_mode.py new file mode 100644 index 0000000..85066ae --- /dev/null +++ b/pyrmv/enums/aff_journey_stop_mode.py @@ -0,0 +1,14 @@ +from enum import auto +from .auto_name import AutoName + +class AffectedJourneyStopMode(AutoName): + """Enumeration used to declare types of affected journey stops return modes.""" + + ALL = auto() + "Return all affected stops of affected journeys." + + IMP = auto() + "Return important stops of affected journeys." + + OFF = auto() + "Do not return stops of affected journeys." \ No newline at end of file diff --git a/pyrmv/enums/search_mode.py b/pyrmv/enums/search_mode.py new file mode 100644 index 0000000..e6956b9 --- /dev/null +++ b/pyrmv/enums/search_mode.py @@ -0,0 +1,14 @@ +from enum import auto +from .auto_name import AutoName + +class SearchMode(AutoName): + """Enumeration used to declare types of HIM search modes.""" + + MATCH = auto() + "Iterate over all trips to find HIM messages." + + NOMATCH = auto() + "Iterate over all HIM messages available." + + TFMATCH = auto() + "Uses filters defined `metas` parameter." \ No newline at end of file diff --git a/pyrmv/methods/him_search.py b/pyrmv/methods/him_search.py index 4833dca..abbf2e3 100644 --- a/pyrmv/methods/him_search.py +++ b/pyrmv/methods/him_search.py @@ -1,5 +1,42 @@ + +from datetime import datetime +from typing import OrderedDict, Union +from pyrmv.classes.Stop import Stop from pyrmv.errors.not_ready import NotReadyYetError +from pyrmv.enums.search_mode import SearchMode +from pyrmv.enums.aff_journey_mode import AffectedJourneyMode +from pyrmv.enums.aff_journey_stop_mode import AffectedJourneyStopMode +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal + +def him_search( + + access_id: str, + 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, + lineids: list = None, + stations: list = None, + station_from: Union[str, Stop] = None, + station_to: Union[str, Stop] = None, + bothways: bool = None, + trainnames: 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 + ) -> None: #List[Message]: -def him_search(): raise NotReadyYetError() \ No newline at end of file