DBFN = "/var/lib/gps303/gps303.sqlite"
-def init(log):
- opts, _ = getopt(argv[1:], "c:d")
+def init(log, opts=None):
+ if opts is None:
+ opts, _ = getopt(argv[1:], "c:d")
opts = dict(opts)
conf = readconfig(opts["-c"] if "-c" in opts else CONF)
if stdout.isatty():
from struct import pack, unpack
__all__ = (
+ "class_by_prefix",
"handle_packet",
"inline_response",
"make_object",
PROTOS[cls.__name__] = cls.PROTO
+def class_by_prefix(prefix):
+ lst = [(name, proto) for name, proto in PROTOS.items()
+ if name.upper().startswith(prefix.upper())]
+ if len(lst) != 1:
+ return lst
+ _, proto = lst[0]
+ return CLASSES[proto]
+
+
def proto_by_name(name):
return PROTOS.get(name, -1)