kopia lustrzana https://github.com/glidernet/python-ogn-client
refactoring
rodzic
34cb2182a6
commit
14cf4848c8
|
@ -8,7 +8,7 @@ from ogn_parser import parse as rust_parse
|
||||||
positions = {}
|
positions = {}
|
||||||
server_timestamp = None
|
server_timestamp = None
|
||||||
|
|
||||||
mapping = {
|
dstcall_beacontype_mapping = {
|
||||||
'OGCAPT': 'capturs',
|
'OGCAPT': 'capturs',
|
||||||
'OGNFNT': 'fanet',
|
'OGNFNT': 'fanet',
|
||||||
'OGFLR': 'flarm',
|
'OGFLR': 'flarm',
|
||||||
|
@ -49,7 +49,7 @@ def parse(aprs_message, reference_timestamp=None, calculate_relations=False, use
|
||||||
elif aprs_packet := rust_message.get('aprs_packet'):
|
elif aprs_packet := rust_message.get('aprs_packet'):
|
||||||
message.update({
|
message.update({
|
||||||
'aprs_type': 'position',
|
'aprs_type': 'position',
|
||||||
'beacon_type': mapping.get(aprs_packet['to'], 'unknown'),
|
'beacon_type': dstcall_beacontype_mapping.get(aprs_packet['to'], 'unknown'),
|
||||||
'name': aprs_packet['from'],
|
'name': aprs_packet['from'],
|
||||||
'dstcall': aprs_packet['to'],
|
'dstcall': aprs_packet['to'],
|
||||||
})
|
})
|
||||||
|
@ -129,7 +129,7 @@ def parse(aprs_message, reference_timestamp=None, calculate_relations=False, use
|
||||||
|
|
||||||
if 'unparsed' in status: message["user_comment"] = status['unparsed']
|
if 'unparsed' in status: message["user_comment"] = status['unparsed']
|
||||||
else:
|
else:
|
||||||
raise ValueError("WTF")
|
raise ValueError("Raised unreachable exception")
|
||||||
elif server_comment := rust_message.get('server_comment'):
|
elif server_comment := rust_message.get('server_comment'):
|
||||||
message.update({
|
message.update({
|
||||||
'version': server_comment['version'],
|
'version': server_comment['version'],
|
||||||
|
@ -144,7 +144,7 @@ def parse(aprs_message, reference_timestamp=None, calculate_relations=False, use
|
||||||
'comment': comment['comment'],
|
'comment': comment['comment'],
|
||||||
'aprs_type': 'comment'})
|
'aprs_type': 'comment'})
|
||||||
else:
|
else:
|
||||||
raise ValueError("WTF")
|
raise ValueError("Raised unreachable exception")
|
||||||
|
|
||||||
if message['aprs_type'].startswith('position') and calculate_relations is True:
|
if message['aprs_type'].startswith('position') and calculate_relations is True:
|
||||||
positions[message['name']] = (message['longitude'], message['latitude'])
|
positions[message['name']] = (message['longitude'], message['latitude'])
|
||||||
|
|
Ładowanie…
Reference in New Issue