Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to clean WIDEn-N and * from path, leaving just digi callsigns #46

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Cleaned up remove_WIDEn_N function, moved to aprslib.util
wsmitchell3 committed Apr 6, 2018
commit 2384dbc9048b0fc17624490b7c648c25d384e7a6
16 changes: 0 additions & 16 deletions aprslib/parsing/common.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
'parse_data_extentions',
'parse_comment_altitude',
'parse_dao',
'remove_WIDEn_N',
]

def validate_callsign(callsign, prefix=""):
@@ -74,21 +73,6 @@ def parse_header(head):
return parsed


def remove_WIDEn_N(path):
"""
Remove WIDEn-N entries and * markers from path, leaving only digi names
path: path of parsed packet (list of strings)
returns: list of digipeaters that digipeated packet, in order
"""
digipath = []
for digi in path:
digi = re.sub('\*','',digi) # Get rid of * markers
if not re.match('WIDE[0-9]-*[0-9]*',digi): # check for not WIDEn-N
digipath.append(digi)

return digipath


def parse_timestamp(body, packet_type=''):
parsed = {}

8 changes: 8 additions & 0 deletions aprslib/util/__init__.py
Original file line number Diff line number Diff line change
@@ -34,3 +34,11 @@ def comment_altitude(altitude):
return "/A={0:06.0f}".format(altitude)


def remove_WIDEn_N(path):
"""
Remove WIDEn-N entries and asterisks from path, leaving only digi names
path: path of parsed packet (list of strings)
returns: list of digipeaters that digipeated packet, in order
"""
path = map(lambda x: re.sub('*$', '', x), path) # Remove asterisks
return(path = list(filter(lambda x: not re.match(r'WIDE[0-9\-\*]+$', x), path)))