New date and time behavior, improved typing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Mapping
|
||||
from typing import Any, List, Mapping, Union
|
||||
|
||||
from pyrmv.classes.message import Message
|
||||
from pyrmv.classes.stop import Stop
|
||||
@@ -9,16 +9,24 @@ class Journey:
|
||||
"""Journey object."""
|
||||
|
||||
def __init__(self, data: Mapping[str, Any]):
|
||||
self.stops = []
|
||||
self.stops: List[Stop] = []
|
||||
|
||||
# Upgrade is temporarily used due to RMV API mismatch
|
||||
# self.ref = data["ref"]
|
||||
self.ref = ref_upgrade(data["ref"])
|
||||
self.ref: str = ref_upgrade(data["ref"])
|
||||
|
||||
self.direction = data["Directions"]["Direction"][0]["value"]
|
||||
self.direction_flag = data["Directions"]["Direction"][0]["flag"]
|
||||
self.direction: Union[str, None] = (
|
||||
data["Directions"]["Direction"][0].get("value")
|
||||
if data["Directions"]["Direction"]
|
||||
else None
|
||||
)
|
||||
self.direction_flag: Union[str, None] = (
|
||||
data["Directions"]["Direction"][0].get("flag")
|
||||
if data["Directions"]["Direction"]
|
||||
else None
|
||||
)
|
||||
self.stops.extend(Stop(stop) for stop in data["Stops"]["Stop"])
|
||||
self.messages = []
|
||||
self.messages: List[Message] = []
|
||||
|
||||
if "Messages" in data:
|
||||
self.messages.extend(Message(message) for message in data["Messages"]["Message"])
|
||||
|
Reference in New Issue
Block a user