Started work on enums
This commit is contained in:
parent
cf642fc00f
commit
5e4ca07877
@ -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 *
|
@ -1,4 +0,0 @@
|
||||
class Product():
|
||||
|
||||
def __init__(self):
|
||||
pass
|
@ -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,
|
||||
}
|
2
pyrmv/enums/__init__.py
Normal file
2
pyrmv/enums/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .product import Product
|
||||
from .rt_mode import RealTimeMode
|
19
pyrmv/enums/auto_name.py
Normal file
19
pyrmv/enums/auto_name.py
Normal 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]
|
48
pyrmv/enums/product.py
Normal file
48
pyrmv/enums/product.py
Normal file
@ -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()
|
||||
|
||||
|
20
pyrmv/enums/rt_mode.py
Normal file
20
pyrmv/enums/rt_mode.py
Normal 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."
|
Loading…
Reference in New Issue
Block a user