"""Trigger implementations.Author: Jendrik A. Potyka, Fabian A. Preiss"""importdatetimeasdtfromabcimportABC,abstractmethodfromtypingimportUnion
[docs]classWeekday(ABC):""" |Weekday| object with time. Parameters ---------- time : datetime.time Time on the clock at the specific |Weekday|. """__value:int__time:dt.time@abstractmethoddef__init__(self,time:dt.time,value:int)->None:"""|Weekday| object with time."""self.__time=timeself.__value=valuedef__repr__(self)->str:returnf"{self.__class__.__qualname__}(time={self.time!r})"@propertydeftime(self)->dt.time:""" Return time of the |Weekday|. Returns ------- datetime.time Time on the clock at the specific |Weekday|. """returnself.__time@propertydefvalue(self)->int:""" Return value of the given |Weekday|. Notes ----- Enumeration analogous to datetime library (0: Monday, ... 6: Sunday). Returns ------- int Value """returnself.__value
# NOTE: pylint missing-class-docstring is just silly here, given functionality and usuage of parent
[docs]defweekday(value:int,time:dt.time=dt.time())->Weekday:""" Return |Weekday| from given value with optional time. Notes ----- Enumeration analogous to datetime library (0: Monday, ... 6: Sunday). Parameters ---------- value : int Integer representation of |Weekday| time : datetime.time Time on the clock at the specific weekday. Returns ------- Weekday |Weekday| object with given time. """weekday_cls:type[_Weekday]=_weekday_mapping[value]weekday_instance=weekday_cls(time)returnweekday_instance