X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=loctrkd%2Fzx303proto.py;h=8c21418cd7a13c9af9f03c57d9d345f8c5592a50;hb=e2e977603507f9121e5c60c5b69d98fb425fa833;hp=2c44a1382b1058b7b0a9e2f0325fde57c3b107a5;hpb=ba4cb894d37f24ac333b316cf9487dfc913eaf74;p=loctrkd.git diff --git a/loctrkd/zx303proto.py b/loctrkd/zx303proto.py index 2c44a13..8c21418 100755 --- a/loctrkd/zx303proto.py +++ b/loctrkd/zx303proto.py @@ -38,7 +38,6 @@ __all__ = ( "proto_handled", "parse_message", "probe_buffer", - "proto_by_name", "proto_name", "DecodeError", "Respond", @@ -865,6 +864,10 @@ if True: # just to indent the code, sorry! def class_by_prefix( prefix: str, ) -> Union[Type[GPS303Pkt], List[Tuple[str, int]]]: + if prefix.startswith(PROTO_PREFIX): + pname = prefix[len(PROTO_PREFIX) :] + else: + raise KeyError(pname) lst = [ (name, proto) for name, proto in PROTOS.items() @@ -886,10 +889,6 @@ def proto_name(obj: Union[MetaPkt, GPS303Pkt]) -> str: ) -def proto_by_name(name: str) -> int: - return PROTOS.get(name, -1) - - def proto_of_message(packet: bytes) -> str: return proto_name(CLASSES.get(packet[1], UNKNOWN))