kopia lustrzana https://github.com/glidernet/python-ogn-client
commit
a07d07be9a
|
@ -0,0 +1,18 @@
|
||||||
|
import re
|
||||||
|
|
||||||
|
from ogn.parser.pattern import PATTERN_INREACH_POSITION_COMMENT
|
||||||
|
|
||||||
|
from .base import BaseParser
|
||||||
|
|
||||||
|
|
||||||
|
class InreachParser(BaseParser):
|
||||||
|
def __init__(self):
|
||||||
|
self.beacon_type = 'inreach'
|
||||||
|
self.position_pattern = re.compile(PATTERN_INREACH_POSITION_COMMENT)
|
||||||
|
|
||||||
|
def parse_position(self, aprs_comment):
|
||||||
|
ac_match = self.position_pattern.match(aprs_comment)
|
||||||
|
return {'address': ac_match.group('id'),
|
||||||
|
'model': ac_match.group('model') if ac_match.group('model') else None,
|
||||||
|
'status': ac_match.group('status') if ac_match.group('status') else None,
|
||||||
|
'pilot_name': ac_match.group('pilot_name') if ac_match.group('pilot_name') else None}
|
|
@ -15,6 +15,7 @@ from ogn.parser.aprs_comment.receiver_parser import ReceiverParser
|
||||||
from ogn.parser.aprs_comment.skylines_parser import SkylinesParser
|
from ogn.parser.aprs_comment.skylines_parser import SkylinesParser
|
||||||
from ogn.parser.aprs_comment.spider_parser import SpiderParser
|
from ogn.parser.aprs_comment.spider_parser import SpiderParser
|
||||||
from ogn.parser.aprs_comment.spot_parser import SpotParser
|
from ogn.parser.aprs_comment.spot_parser import SpotParser
|
||||||
|
from ogn.parser.aprs_comment.inreach_parser import InreachParser
|
||||||
from ogn.parser.aprs_comment.generic_parser import GenericParser
|
from ogn.parser.aprs_comment.generic_parser import GenericParser
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ dstcall_parser_mapping = {'APRS': OgnParser(),
|
||||||
'OGSKYL': SkylinesParser(),
|
'OGSKYL': SkylinesParser(),
|
||||||
'OGSPID': SpiderParser(),
|
'OGSPID': SpiderParser(),
|
||||||
'OGSPOT': SpotParser(),
|
'OGSPOT': SpotParser(),
|
||||||
|
'OGINREACH': InreachParser(),
|
||||||
'GENERIC': GenericParser(),
|
'GENERIC': GenericParser(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,13 @@ PATTERN_SPOT_POSITION_COMMENT = re.compile("""
|
||||||
(?P<status>[A-Z]+)
|
(?P<status>[A-Z]+)
|
||||||
""", re.VERBOSE | re.MULTILINE)
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
|
PATTERN_INREACH_POSITION_COMMENT = re.compile("""
|
||||||
|
id(?P<id>[\d]+)\s
|
||||||
|
(?P<model>inReac[A-Za-z\d]*)\s
|
||||||
|
(?P<status>[A-Za-z]+)\s?
|
||||||
|
(?P<pilot_name>.+)?
|
||||||
|
""", re.VERBOSE | re.MULTILINE)
|
||||||
|
|
||||||
PATTERN_TRACKER_POSITION_COMMENT = re.compile("""
|
PATTERN_TRACKER_POSITION_COMMENT = re.compile("""
|
||||||
id(?P<details>[\dA-F]{2})(?P<address>[\dA-F]{6}?)\s?
|
id(?P<details>[\dA-F]{2})(?P<address>[\dA-F]{6}?)\s?
|
||||||
(?:(?P<climb_rate>[+-]\d+?)fpm\s)?
|
(?:(?P<climb_rate>[+-]\d+?)fpm\s)?
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import unittest
|
||||||
|
from ogn.parser.aprs_comment.inreach_parser import InreachParser
|
||||||
|
|
||||||
|
|
||||||
|
class TestStringMethods(unittest.TestCase):
|
||||||
|
def test_position_comment(self):
|
||||||
|
message = InreachParser().parse_position("id300434060496190 inReac True")
|
||||||
|
self.assertEqual(message['address'], "300434060496190")
|
||||||
|
self.assertEqual(message['model'], 'inReac')
|
||||||
|
self.assertEqual(message['status'], "True")
|
||||||
|
self.assertEqual(message['pilot_name'], None)
|
||||||
|
|
||||||
|
message = InreachParser().parse_position("id300434060496190 inReac True Jim Bob")
|
||||||
|
self.assertEqual(message['address'], "300434060496190")
|
||||||
|
self.assertEqual(message['model'], 'inReac')
|
||||||
|
self.assertEqual(message['status'], "True")
|
||||||
|
self.assertEqual(message['pilot_name'], "Jim Bob")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Ładowanie…
Reference in New Issue