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

formatting

This commit is contained in:
Kelly Brazil
2022-01-19 19:19:25 -08:00
parent bd391d979c
commit 299a9c6d88
2 changed files with 25 additions and 57 deletions

View File

@ -4,8 +4,8 @@
jc - JSON CLI output utility `csv` file parser
The `csv` parser will attempt to automatically detect the delimiter
character. If the delimiter cannot be detected it will default to comma. The
first row of the file must be a header row.
character. If the delimiter cannot be detected it will default to comma.
The first row of the file must be a header row.
Usage (cli):

View File

@ -5,59 +5,13 @@ JC - JSON CLI output utility
* kellyjonbrazil@gmail.com
This package serializes the output of many standard unix command line tools
to JSON format.
to dictionaries and lists of dictionaries.
For documentation on each parser, see the
[documentation site](https://kellyjonbrazil.github.io/jc/).
[documentation site](https://kellyjonbrazil.github.io/jc/) or use
`jc.get_help('parser_module_name')`
CLI Example:
$ dig example.com | jc --dig -p
[
{
"id": 2951,
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
"qr",
"rd",
"ra"
],
"query_num": 1,
"answer_num": 1,
"authority_num": 0,
"additional_num": 1,
"opt_pseudosection": {
"edns": {
"version": 0,
"flags": [],
"udp": 4096
}
},
"question": {
"name": "example.com.",
"class": "IN",
"type": "A"
},
"answer": [
{
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": 39302,
"data": "93.184.216.34"
}
],
"query_time": 49,
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Fri Apr 16 16:05:10 PDT 2021",
"rcvd": 56,
"when_epoch": 1618614310,
"when_epoch_utc": null
}
]
Module Example:
Example:
>>> import subprocess
>>> import jc
@ -65,7 +19,6 @@ Module Example:
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
text=True)
>>> data = jc.parse('dig', cmd_output)
>>>
>>> data
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
@ -78,11 +31,26 @@ modules directly:
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
text=True)
>>> data = jc.parsers.dig.parse(cmd_output)
>>>
>>> data
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
To get a list of all available parser module names, use
`jc.parser_mod_list()`. For a list of plugin parser module names only,
use the `jc.plugin_parser_mod_list()` function.
Available Functions:
* Use `help(jc.lib)` for details
parse(parser_module_name: str, data: str | iterable)
High-level API to easily access the parser. This API will find both
built-in parsers and local plugin parsers.
get_help(parser_module_name: str)
Convenience function to display the help screen for a parser using its
module name.
parser_mod_list()
Get a list of all available parser module names to be used in parse()
and get_help().
plugin_parser_mod_list()
Get a list of plugin parser module names. This list is a subset of
parser_mod_list().