2017-10-05 08:36:53 +00:00
|
|
|
class BaseParser():
|
|
|
|
def __init__(self):
|
|
|
|
self.beacon_type = 'unknown'
|
|
|
|
|
|
|
|
def parse(self, aprs_comment, aprs_type):
|
2020-10-13 18:42:53 +00:00
|
|
|
if aprs_type.startswith('position'):
|
2017-10-05 08:36:53 +00:00
|
|
|
data = self.parse_position(aprs_comment)
|
2020-10-13 18:42:53 +00:00
|
|
|
elif aprs_type.startswith('status'):
|
2017-10-05 08:36:53 +00:00
|
|
|
data = self.parse_status(aprs_comment)
|
|
|
|
else:
|
|
|
|
raise ValueError("aprs_type {} unknown".format(aprs_type))
|
|
|
|
data.update({'beacon_type': self.beacon_type})
|
|
|
|
return data
|
|
|
|
|
|
|
|
def parse_position(self, aprs_comment):
|
|
|
|
raise NotImplementedError("Position parser for parser '{}' not yet implemented".format(self.beacon_type))
|
|
|
|
|
|
|
|
def parse_status(self, aprs_comment):
|
|
|
|
raise NotImplementedError("Status parser for parser '{}' not yet implemented".format(self.beacon_type))
|