implement item and object parsing
This commit is contained in:
parent
b24e56803c
commit
de22169ea8
30
owrx/aprs.py
30
owrx/aprs.py
@ -240,13 +240,39 @@ class AprsParser(object):
|
|||||||
aprsData.update(self.parseMessage(information[1:]))
|
aprsData.update(self.parseMessage(information[1:]))
|
||||||
elif dti == ";":
|
elif dti == ";":
|
||||||
# object
|
# object
|
||||||
aprsData["type"] = "object"
|
aprsData.update(self.parseObject(information[1:]))
|
||||||
elif dti == ")":
|
elif dti == ")":
|
||||||
# item
|
# item
|
||||||
aprsData["type"] = "item"
|
aprsData.update(self.parseItem(information[1:]))
|
||||||
|
|
||||||
return aprsData
|
return aprsData
|
||||||
|
|
||||||
|
def parseObject(self, information):
|
||||||
|
result = {"type": "object"}
|
||||||
|
if len(information) > 16:
|
||||||
|
result["object"] = information[0:9].strip()
|
||||||
|
result["live"] = information[9] == "*"
|
||||||
|
result["timestamp"] = self.parseTimestamp(information[10:17])
|
||||||
|
result.update(self.parseRegularAprsData(information[17:]))
|
||||||
|
# override type, losing information about compression
|
||||||
|
result["type"] = "object"
|
||||||
|
return result
|
||||||
|
|
||||||
|
def parseItem(self, information):
|
||||||
|
result = {"type": "item"}
|
||||||
|
if len(information) > 3:
|
||||||
|
indexes = [information[0:9].find(p) for p in ["!", "_"]]
|
||||||
|
filtered = [i for i in indexes if i >= 3]
|
||||||
|
filtered.sort()
|
||||||
|
if len(filtered):
|
||||||
|
index = filtered[0]
|
||||||
|
result["item"] = information[0:index]
|
||||||
|
result["live"] = information[index] == "!"
|
||||||
|
result.update(self.parseRegularAprsData(information[index + 1:]))
|
||||||
|
# override type, losing information about compression
|
||||||
|
result["type"] = "item"
|
||||||
|
return result
|
||||||
|
|
||||||
def parseMessage(self, information):
|
def parseMessage(self, information):
|
||||||
result = {"type": "message"}
|
result = {"type": "message"}
|
||||||
if len(information) > 9 and information[9] == ":":
|
if len(information) > 9 and information[9] == ":":
|
||||||
|
Loading…
Reference in New Issue
Block a user