mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
fixup arp parser
This commit is contained in:
@ -16,7 +16,15 @@ def parse(data):
|
|||||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
|
||||||
|
|
||||||
|
# remove final Entries row if -v was used
|
||||||
|
if cleandata[-1].find("Entries:") == 0:
|
||||||
|
cleandata.pop(-1)
|
||||||
|
|
||||||
|
# fix header row to change Flags Mask to flags_mask
|
||||||
|
cleandata[0] = cleandata[0].replace('Flags Mask', 'flags_mask')
|
||||||
|
|
||||||
|
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
||||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
||||||
|
|
||||||
return [dict(zip(headers, r)) for r in raw_data]
|
return [dict(zip(headers, r)) for r in raw_data]
|
||||||
|
Reference in New Issue
Block a user