X-Git-Url: http://www.average.org/gitweb/?a=blobdiff_plain;f=gps303%2Fgps303proto.py;h=ab03c6829ccc94b025504ddb79208c5fcac4945b;hb=bd031f87f4d3f640ce8862271aa69107f31a06d5;hp=cee1bfaf512fb90321ab85083dc5e985fdb8657c;hpb=2ddbb639a1bb1164d56367c369a97da507abf964;p=loctrkd.git diff --git a/gps303/gps303proto.py b/gps303/gps303proto.py index cee1bfa..ab03c68 100755 --- a/gps303/gps303proto.py +++ b/gps303/gps303proto.py @@ -105,6 +105,8 @@ def hhmm(x: str) -> str: def l3str(x: Union[str, List[str]]) -> List[str]: if isinstance(x, str): lx = x.split(",") + else: + lx = x if len(lx) != 3 or not all(isinstance(el, str) for el in x): raise ValueError(str(lx) + " is not a list of three strings") return lx @@ -113,6 +115,8 @@ def l3str(x: Union[str, List[str]]) -> List[str]: def l3int(x: Union[str, List[int]]) -> List[int]: if isinstance(x, str): lx = [int(el) for el in x.split(",")] + else: + lx = x if len(lx) != 3 or not all(isinstance(el, int) for el in lx): raise ValueError(str(lx) + " is not a list of three integers") return lx @@ -665,7 +669,9 @@ if True: # just to indent the code, sorry! PROTOS[cls.__name__] = cls.PROTO -def class_by_prefix(prefix: str) -> Union[type, List[Tuple[str, int]]]: +def class_by_prefix( + prefix: str, +) -> Union[Type[GPS303Pkt], List[Tuple[str, int]]]: lst = [ (name, proto) for name, proto in PROTOS.items()