mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
add flags_pretty
This commit is contained in:
@ -101,7 +101,7 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
version = '1.1'
|
||||||
description = 'route command parser'
|
description = 'route command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -132,6 +132,9 @@ def process(proc_data):
|
|||||||
"gateway": string,
|
"gateway": string,
|
||||||
"genmask": string,
|
"genmask": string,
|
||||||
"flags": string,
|
"flags": string,
|
||||||
|
"flags_pretty": [
|
||||||
|
string,
|
||||||
|
]
|
||||||
"metric": integer,
|
"metric": integer,
|
||||||
"ref": integer,
|
"ref": integer,
|
||||||
"use": integer,
|
"use": integer,
|
||||||
@ -152,6 +155,29 @@ def process(proc_data):
|
|||||||
except (ValueError):
|
except (ValueError):
|
||||||
entry[key] = None
|
entry[key] = None
|
||||||
|
|
||||||
|
# add flags_pretty
|
||||||
|
# Flag mapping from https://www.man7.org/linux/man-pages/man8/route.8.html
|
||||||
|
if 'flags' in entry:
|
||||||
|
flag_map = {
|
||||||
|
'U': 'UP',
|
||||||
|
'H': 'HOST',
|
||||||
|
'G': 'GATEWAY',
|
||||||
|
'R': 'REINSTATE',
|
||||||
|
'D': 'DYNAMIC',
|
||||||
|
'M': 'MODIFIED',
|
||||||
|
'A': 'ADDRCONF',
|
||||||
|
'C': 'CACHE',
|
||||||
|
'!': 'REJECT'
|
||||||
|
}
|
||||||
|
|
||||||
|
pretty_flags = []
|
||||||
|
|
||||||
|
for flag in entry['flags']:
|
||||||
|
if flag in flag_map:
|
||||||
|
pretty_flags.append(flag_map[flag])
|
||||||
|
|
||||||
|
entry['flags_pretty'] = pretty_flags
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user