mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
add lib function docs
This commit is contained in:
@@ -3,59 +3,13 @@
|
|||||||
* kellyjonbrazil@gmail.com
|
* kellyjonbrazil@gmail.com
|
||||||
|
|
||||||
This package serializes the output of many standard unix command line tools
|
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
|
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:
|
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:
|
|
||||||
|
|
||||||
>>> import subprocess
|
>>> import subprocess
|
||||||
>>> import jc
|
>>> import jc
|
||||||
@@ -63,7 +17,6 @@ Module Example:
|
|||||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
|
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
|
||||||
text=True)
|
text=True)
|
||||||
>>> data = jc.parse('dig', cmd_output)
|
>>> data = jc.parse('dig', cmd_output)
|
||||||
>>>
|
|
||||||
>>> data
|
>>> data
|
||||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
|
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
|
||||||
|
|
||||||
@@ -76,13 +29,28 @@ modules directly:
|
|||||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
|
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
|
||||||
text=True)
|
text=True)
|
||||||
>>> data = jc.parsers.dig.parse(cmd_output)
|
>>> data = jc.parsers.dig.parse(cmd_output)
|
||||||
>>>
|
|
||||||
>>> data
|
>>> data
|
||||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
|
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
|
||||||
|
|
||||||
To get a list of all available parser module names, use
|
Available Functions:
|
||||||
`jc.parser_mod_list()`. For a list of plugin parser module names only,
|
|
||||||
use the `jc.plugin_parser_mod_list()` function.
|
* 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().
|
||||||
"""
|
"""
|
||||||
from .lib import (__version__, parse, parser_mod_list,
|
from .lib import (__version__, parse, parser_mod_list,
|
||||||
plugin_parser_mod_list, get_help)
|
plugin_parser_mod_list, get_help)
|
||||||
|
Reference in New Issue
Block a user