From fa2a70efbf7b76904bede2d56d5b25a057f6cc3f Mon Sep 17 00:00:00 2001 From: profitroll Date: Sun, 18 Aug 2024 22:51:57 +0200 Subject: [PATCH] Added PlatformType and PlatformTypeType (for #4) --- src/pyrmv/classes/__init__.py | 1 + src/pyrmv/classes/platform_type.py | 17 +++++++++ src/pyrmv/enums/__init__.py | 1 + src/pyrmv/enums/platform_type_type.py | 51 +++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 src/pyrmv/classes/platform_type.py create mode 100644 src/pyrmv/enums/platform_type_type.py diff --git a/src/pyrmv/classes/__init__.py b/src/pyrmv/classes/__init__.py index c87171b..356d8ea 100644 --- a/src/pyrmv/classes/__init__.py +++ b/src/pyrmv/classes/__init__.py @@ -3,6 +3,7 @@ from .gis import Gis from .journey import Journey from .leg import Leg from .message import Channel, Message, Url +from .platform_type import PlatformType from .stop import Stop, StopTrip from .ticket import Ticket from .trip import Trip diff --git a/src/pyrmv/classes/platform_type.py b/src/pyrmv/classes/platform_type.py new file mode 100644 index 0000000..a1afe49 --- /dev/null +++ b/src/pyrmv/classes/platform_type.py @@ -0,0 +1,17 @@ +from typing import Any, Mapping, Union + +from pyrmv.enums.platform_type_type import PlatformTypeType + + +class PlatformType: + """Platform information.""" + + def __init__(self, data: Mapping[str, Any]): + self.type: PlatformTypeType = ( + PlatformTypeType.U if "type" not in data else PlatformTypeType(data.get("type")) + ) + self.text: Union[str, None] = data.get("text") + self.hidden: bool = bool(data.get("hidden")) + self.lon: float = data["lon"] + self.lat: float = data["lat"] + self.alt: int = data["alt"] diff --git a/src/pyrmv/enums/__init__.py b/src/pyrmv/enums/__init__.py index 92cffb6..d8d4b74 100644 --- a/src/pyrmv/enums/__init__.py +++ b/src/pyrmv/enums/__init__.py @@ -4,6 +4,7 @@ from .board_type import BoardArrivalType, BoardDepartureType from .filter_mode import FilterMode from .lang import Language from .location_type import LocationType +from .platform_type_type import PlatformTypeType from .product import Product from .rt_mode import RealTimeMode from .search_mode import SearchMode diff --git a/src/pyrmv/enums/platform_type_type.py b/src/pyrmv/enums/platform_type_type.py new file mode 100644 index 0000000..4658bde --- /dev/null +++ b/src/pyrmv/enums/platform_type_type.py @@ -0,0 +1,51 @@ +from enum import Enum, auto + + +class PlatformTypeType(Enum): + """Enumeration used to declare types of platform type. + + * U - Undefined + * PL - Platform/track at train station + * ST - Stop at bus or tram station + * GA - Terminal/Gate at airport + * PI - Pier if ship or ferry + * SL - Slot/parking space if bike or car + * FL - Floor in buildings or at footpath + * CI - Check-in/entrance + * CO - Check-out/exit + * X - No explicit type + * H - Hide platform information + """ + + U = auto() + "Undefined" + + PL = auto() + "Platform/track at train station" + + ST = auto() + "Stop at bus or tram station" + + GA = auto() + "Terminal/Gate at airport" + + PI = auto() + "Pier if ship or ferry" + + SL = auto() + "Slot/parking space if bike or car" + + FL = auto() + "Floor in buildings or at footpath" + + CI = auto() + "Check-in/entrance" + + CO = auto() + "Check-out/exit" + + X = auto() + "No explicit type" + + H = auto() + "Hide platform information"