mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-17 01:32:37 +02:00
add human readable output support to the free parser
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
20240214 v1.25.2
|
20240226 v1.25.2
|
||||||
- TODO: add human output support to the `free` parser
|
- Enhance `free` parser to add human readable output support
|
||||||
- Enhance `df` parser to include `_bytes` fields for `size`, `used`, and `available`.
|
- Enhance `df` parser to include `_bytes` fields for `size`, `used`, and `available`.
|
||||||
This provides normalized output when human readable `df` output is used
|
This provides normalized output when human readable `df` output is used
|
||||||
- Fix `iwconfig` parser to handle more special characters in the SSID name
|
- Fix `iwconfig` parser to handle more special characters in the SSID name
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
jc - JSON Convert `free` command output parser
|
jc - JSON Convert `free` command output parser
|
||||||
|
|
||||||
|
Values are normalized to bytes when using `free -h`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ free | jc --free
|
$ free | jc --free
|
||||||
@ -97,4 +99,4 @@ Compatibility: linux
|
|||||||
|
|
||||||
Source: [`jc/parsers/free.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/free.py)
|
Source: [`jc/parsers/free.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/free.py)
|
||||||
|
|
||||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""jc - JSON Convert `free` command output parser
|
"""jc - JSON Convert `free` command output parser
|
||||||
|
|
||||||
|
Values are normalized to bytes when using `free -h`.
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
$ free | jc --free
|
$ free | jc --free
|
||||||
@ -73,7 +75,7 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.7'
|
version = '1.8'
|
||||||
description = '`free` command parser'
|
description = '`free` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -102,7 +104,7 @@ def _process(proc_data):
|
|||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
for key in entry:
|
for key in entry:
|
||||||
if key in int_list:
|
if key in int_list:
|
||||||
entry[key] = jc.utils.convert_to_int(entry[key])
|
entry[key] = jc.utils.convert_size_to_int(entry[key])
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
@ -138,7 +140,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
for entry in raw_output:
|
for entry in raw_output:
|
||||||
entry['type'] = entry['type'].rstrip(':')
|
entry['type'] = entry['type'].rstrip(':')
|
||||||
|
|
||||||
if raw:
|
return raw_output if raw else _process(raw_output)
|
||||||
return raw_output
|
|
||||||
else:
|
|
||||||
return _process(raw_output)
|
|
||||||
|
2
tests/fixtures/centos-7.7/free-h.json
vendored
2
tests/fixtures/centos-7.7/free-h.json
vendored
@ -1 +1 @@
|
|||||||
[{"type":"Mem","total":3,"used":217,"free":3,"shared":11,"buff_cache":267,"available":3},{"type":"Swap","total":2,"used":0,"free":2}]
|
[{"type":"Mem","total":3700000000,"used":217000000,"free":3200000000,"shared":11000000,"buff_cache":267000000,"available":3200000000},{"type":"Swap","total":2000000000,"used":0,"free":2000000000}]
|
||||||
|
2
tests/fixtures/ubuntu-18.04/free-h.json
vendored
2
tests/fixtures/ubuntu-18.04/free-h.json
vendored
@ -1 +1 @@
|
|||||||
[{"type":"Mem","total":1,"used":237,"free":466,"shared":1,"buff_cache":1,"available":1},{"type":"Swap","total":2,"used":268,"free":2}]
|
[{"type":"Mem","total":1900000000,"used":237000000,"free":466000000,"shared":1200000,"buff_cache":1200000000,"available":1500000000},{"type":"Swap","total":2000000000,"used":268000,"free":2000000000}]
|
||||||
|
Reference in New Issue
Block a user