2019-11-14 17:21:56 -08:00
|
|
|
# jc.parsers.stat
|
|
|
|
jc - JSON CLI output utility stats Parser
|
2019-11-13 07:45:37 -08:00
|
|
|
|
|
|
|
Usage:
|
2019-11-14 17:21:56 -08:00
|
|
|
specify --stats as the first argument if the piped input is coming from stats
|
2019-11-14 13:37:55 -08:00
|
|
|
|
2019-11-13 07:45:37 -08:00
|
|
|
Examples:
|
|
|
|
|
2019-11-14 17:21:56 -08:00
|
|
|
$ stat /bin/* | jc --stat -p
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"file": "/bin/bash",
|
|
|
|
"size": 1113504,
|
|
|
|
"blocks": 2176,
|
|
|
|
"io_blocks": 4096,
|
|
|
|
"type": "regular file",
|
|
|
|
"device": "802h/2050d",
|
|
|
|
"inode": 131099,
|
|
|
|
"links": 1,
|
|
|
|
"access": "0755",
|
|
|
|
"flags": "-rwxr-xr-x",
|
|
|
|
"uid": 0,
|
|
|
|
"user": "root",
|
|
|
|
"gid": 0,
|
|
|
|
"group": "root",
|
|
|
|
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
|
|
|
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
|
|
|
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
|
|
|
"birth_time": "-"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"file": "/bin/btrfs",
|
|
|
|
"size": 716464,
|
|
|
|
"blocks": 1400,
|
|
|
|
"io_blocks": 4096,
|
|
|
|
"type": "regular file",
|
|
|
|
"device": "802h/2050d",
|
|
|
|
"inode": 131100,
|
|
|
|
"links": 1,
|
|
|
|
"access": "0755",
|
|
|
|
"flags": "-rwxr-xr-x",
|
|
|
|
"uid": 0,
|
|
|
|
"user": "root",
|
|
|
|
"gid": 0,
|
|
|
|
"group": "root",
|
|
|
|
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
|
|
|
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
|
|
|
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
|
|
|
"birth_time": "-"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
2019-11-13 07:45:37 -08:00
|
|
|
|
2019-11-14 17:21:56 -08:00
|
|
|
$ stat /bin/* | jc --stat -p -r
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"file": "/bin/bash",
|
|
|
|
"size": "1113504",
|
|
|
|
"blocks": "2176",
|
|
|
|
"io_blocks": "4096",
|
|
|
|
"type": "regular file",
|
|
|
|
"device": "802h/2050d",
|
|
|
|
"inode": "131099",
|
|
|
|
"links": "1",
|
|
|
|
"access": "0755",
|
|
|
|
"flags": "-rwxr-xr-x",
|
|
|
|
"uid": "0",
|
|
|
|
"user": "root",
|
|
|
|
"gid": "0",
|
|
|
|
"group": "root",
|
|
|
|
"access_time": "2019-11-14 08:18:03.509681766 +0000",
|
|
|
|
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
|
|
|
|
"change_time": "2019-08-12 17:21:29.521945390 +0000",
|
|
|
|
"birth_time": "-"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"file": "/bin/btrfs",
|
|
|
|
"size": "716464",
|
|
|
|
"blocks": "1400",
|
|
|
|
"io_blocks": "4096",
|
|
|
|
"type": "regular file",
|
|
|
|
"device": "802h/2050d",
|
|
|
|
"inode": "131100",
|
|
|
|
"links": "1",
|
|
|
|
"access": "0755",
|
|
|
|
"flags": "-rwxr-xr-x",
|
|
|
|
"uid": "0",
|
|
|
|
"user": "root",
|
|
|
|
"gid": "0",
|
|
|
|
"group": "root",
|
|
|
|
"access_time": "2019-11-14 08:18:28.990834276 +0000",
|
|
|
|
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
|
|
|
|
"change_time": "2019-08-12 17:21:29.545944399 +0000",
|
|
|
|
"birth_time": "-"
|
|
|
|
},
|
|
|
|
..
|
|
|
|
]
|
2019-11-13 07:45:37 -08:00
|
|
|
|
|
|
|
## process
|
|
|
|
```python
|
|
|
|
process(proc_data)
|
|
|
|
```
|
|
|
|
|
|
|
|
Final processing to conform to the schema.
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
2019-11-13 08:04:40 -08:00
|
|
|
proc_data: (dictionary) raw structured data to process
|
2019-11-13 07:45:37 -08:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
dictionary structured data with the following schema:
|
|
|
|
|
|
|
|
[
|
|
|
|
{
|
2019-11-14 17:21:56 -08:00
|
|
|
"file": string,
|
|
|
|
"link_to" string,
|
|
|
|
"size": integer,
|
|
|
|
"blocks": integer,
|
|
|
|
"io_blocks": integer,
|
|
|
|
"type": string,
|
|
|
|
"device": string,
|
|
|
|
"inode": integer,
|
|
|
|
"links": integer,
|
|
|
|
"access": string,
|
|
|
|
"flags": string,
|
|
|
|
"uid": integer,
|
|
|
|
"user": string,
|
|
|
|
"gid": integer,
|
|
|
|
"group": string,
|
|
|
|
"access_time": string,
|
|
|
|
"modify_time": string,
|
|
|
|
"change_time": string,
|
|
|
|
"birth_time": string
|
2019-11-13 07:45:37 -08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
## parse
|
|
|
|
```python
|
|
|
|
parse(data, raw=False, quiet=False)
|
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) output preprocessed JSON if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
dictionary raw or processed structured data
|
|
|
|
|