make decoder classes <<static>>

This commit is contained in:
Bastian Schroll 2018-09-09 16:34:44 +02:00
parent a6542f0b63
commit f1bf468c2a
6 changed files with 60 additions and 69 deletions

View file

@ -23,18 +23,21 @@ from boswatch.decoder.zveidecoder import ZveiDecoder
logging.debug("- %s loaded", __name__)
def decode(data):
"""!Choose the right decoder and return a bwPacket instance
class Decoder:
@param data: data to decode
@return bwPacket instance"""
logging.debug("search decoder")
if "FMS" in data:
return FmsDecoder.decode(data)
elif "POCSAG" in data:
return PocsagDecoder.decode(data)
elif "ZVEI" in data:
return ZveiDecoder.decode(data)
else:
logging.error("no decoder found for: %s", data)
return None
@staticmethod
def decode(data):
"""!Choose the right decoder and return a bwPacket instance
@param data: data to decode
@return bwPacket instance"""
logging.debug("search decoder")
if "FMS" in data:
return FmsDecoder.decode(data)
elif "POCSAG" in data:
return PocsagDecoder.decode(data)
elif "ZVEI" in data:
return ZveiDecoder.decode(data)
else:
logging.error("no decoder found for: %s", data)
return None