1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

change buff/cache key to buff_cache

This commit is contained in:
Kelly Brazil
2019-10-25 09:46:03 -07:00
parent 6d047486d9
commit c8c5564b29
2 changed files with 6 additions and 3 deletions

View File

@ -147,7 +147,7 @@ $ free | jc --free -p
"used": "213104",
"free": "1148452",
"shared": "1176",
"buff/cache": "655744",
"buff_cache": "655744",
"available": "1622204"
},
{

View File

@ -13,7 +13,7 @@ $ free | jc --free -p
"used": "213104",
"free": "1148452",
"shared": "1176",
"buff/cache": "655744",
"buff_cache": "655744",
"available": "1622204"
},
{
@ -33,9 +33,12 @@ def parse(data):
cleandata = data.splitlines()
headers = [h for h in ' '.join(cleandata[0].strip().split()).split() if h]
headers.insert(0, "type")
# clean up 'buff/cache' header
# even though forward slash in a key is valid json, it can make things difficult
headers = ['buff_cache' if x == 'buff/cache' else x for x in headers]
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
output = [dict(zip(headers, r)) for r in raw_data]