From 5e4ca078770e557ae28a099e708875511b26a996 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 28 Sep 2022 12:31:41 +0200 Subject: [PATCH] Started work on enums --- pyrmv/__init__.py | 3 ++- pyrmv/classes/Product.py | 4 ---- pyrmv/const/product.py | 28 +++++++++++------------ pyrmv/enums/__init__.py | 2 ++ pyrmv/enums/auto_name.py | 19 ++++++++++++++++ pyrmv/enums/product.py | 48 ++++++++++++++++++++++++++++++++++++++++ pyrmv/enums/rt_mode.py | 20 +++++++++++++++++ setup.py | 2 +- 8 files changed, 106 insertions(+), 20 deletions(-) delete mode 100644 pyrmv/classes/Product.py create mode 100644 pyrmv/enums/__init__.py create mode 100644 pyrmv/enums/auto_name.py create mode 100644 pyrmv/enums/product.py create mode 100644 pyrmv/enums/rt_mode.py diff --git a/pyrmv/__init__.py b/pyrmv/__init__.py index 0639791..a44626f 100644 --- a/pyrmv/__init__.py +++ b/pyrmv/__init__.py @@ -26,8 +26,9 @@ __license__ = "MIT License" __author__ = "Profitroll" from . import raw +from . import const +from . import enums from . import errors from . import utility from . import classes -from . import const from .methods import * \ No newline at end of file diff --git a/pyrmv/classes/Product.py b/pyrmv/classes/Product.py deleted file mode 100644 index b19b967..0000000 --- a/pyrmv/classes/Product.py +++ /dev/null @@ -1,4 +0,0 @@ -class Product(): - - def __init__(self): - pass \ No newline at end of file diff --git a/pyrmv/const/product.py b/pyrmv/const/product.py index e635ae1..fe6087e 100644 --- a/pyrmv/const/product.py +++ b/pyrmv/const/product.py @@ -3,18 +3,18 @@ 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, - "S": 8, - "U-Bahn": 16, - "Tram": 32, - "Bus": 64, - "Bus2": 128, - "Fähre": 256, - "Taxi": 512, - "Bahn": 1024, + "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, } \ No newline at end of file diff --git a/pyrmv/enums/__init__.py b/pyrmv/enums/__init__.py new file mode 100644 index 0000000..986de86 --- /dev/null +++ b/pyrmv/enums/__init__.py @@ -0,0 +1,2 @@ +from .product import Product +from .rt_mode import RealTimeMode \ No newline at end of file diff --git a/pyrmv/enums/auto_name.py b/pyrmv/enums/auto_name.py new file mode 100644 index 0000000..fa8a5fe --- /dev/null +++ b/pyrmv/enums/auto_name.py @@ -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] \ No newline at end of file diff --git a/pyrmv/enums/product.py b/pyrmv/enums/product.py new file mode 100644 index 0000000..2beb60c --- /dev/null +++ b/pyrmv/enums/product.py @@ -0,0 +1,48 @@ +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() + "" + + FERRY = auto() + + + TAXI = auto() + + + BAHN = auto() + + \ No newline at end of file diff --git a/pyrmv/enums/rt_mode.py b/pyrmv/enums/rt_mode.py new file mode 100644 index 0000000..97c1b4b --- /dev/null +++ b/pyrmv/enums/rt_mode.py @@ -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." \ No newline at end of file diff --git a/setup.py b/setup.py index 03de73b..2823f36 100644 --- a/setup.py +++ b/setup.py @@ -29,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",