Merge branch 'wsmitchell3-dev'; Close #43
This commit is contained in:
commit
a3e205f001
|
|
@ -44,6 +44,25 @@ from aprslib.parsing.telemetry import *
|
||||||
from aprslib.parsing.thirdparty import *
|
from aprslib.parsing.thirdparty import *
|
||||||
from aprslib.parsing.weather import *
|
from aprslib.parsing.weather import *
|
||||||
|
|
||||||
|
unsupported_formats = {
|
||||||
|
'#':'raw weather report',
|
||||||
|
'$':'raw gps',
|
||||||
|
'%':'agrelo',
|
||||||
|
'&':'reserved',
|
||||||
|
'(':'unused',
|
||||||
|
')':'item report',
|
||||||
|
'*':'complete weather report',
|
||||||
|
'+':'reserved',
|
||||||
|
'-':'unused',
|
||||||
|
'.':'reserved',
|
||||||
|
'<':'station capabilities',
|
||||||
|
'?':'general query format',
|
||||||
|
'T':'telemetry report',
|
||||||
|
'[':'maidenhead locator beacon',
|
||||||
|
'\\':'unused',
|
||||||
|
']':'unused',
|
||||||
|
'^':'unused',
|
||||||
|
}
|
||||||
|
|
||||||
def _unicode_packet(packet):
|
def _unicode_packet(packet):
|
||||||
# attempt utf-8
|
# attempt utf-8
|
||||||
|
|
@ -139,27 +158,8 @@ def parse(packet):
|
||||||
def _try_toparse_body(packet_type, body, parsed):
|
def _try_toparse_body(packet_type, body, parsed):
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
# NOT SUPPORTED FORMATS
|
if packet_type in unsupported_formats:
|
||||||
#
|
raise UnknownFormat("Format is not supported: '{}' {}".format(packet_type, unsupported_formats[packet_type]))
|
||||||
# # - raw weather report
|
|
||||||
# $ - raw gps
|
|
||||||
# % - agrelo
|
|
||||||
# & - reserved
|
|
||||||
# ( - unused
|
|
||||||
# ) - item report
|
|
||||||
# * - complete weather report
|
|
||||||
# + - reserved
|
|
||||||
# - - unused
|
|
||||||
# . - reserved
|
|
||||||
# < - station capabilities
|
|
||||||
# ? - general query format
|
|
||||||
# T - telemetry report
|
|
||||||
# [ - maidenhead locator beacon
|
|
||||||
# \ - unused
|
|
||||||
# ] - unused
|
|
||||||
# ^ - unused
|
|
||||||
if packet_type in '#$%)*<?T[':
|
|
||||||
raise UnknownFormat("format is not supported")
|
|
||||||
|
|
||||||
# 3rd party traffic
|
# 3rd party traffic
|
||||||
elif packet_type == '}':
|
elif packet_type == '}':
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ class ParseTestCase(unittest.TestCase):
|
||||||
self.fail("empty status packet shouldn't raise exception")
|
self.fail("empty status packet shouldn't raise exception")
|
||||||
|
|
||||||
def test_unsupported_formats_raising(self):
|
def test_unsupported_formats_raising(self):
|
||||||
with self.assertRaises(UnknownFormat):
|
for packet_type in parsing.unsupported_formats:
|
||||||
for packet_type in '#$%)*,<?T[_{':
|
with self.assertRaises(UnknownFormat):
|
||||||
packet = "A>B:%saaa" % packet_type
|
packet = "A>B:%saaa" % packet_type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue