1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs
Kelly Brazil 299a9c6d88 formatting
2022-01-19 19:19:25 -08:00
..
2022-01-19 19:19:25 -08:00
2021-04-05 11:42:59 -07:00
2022-01-19 19:19:25 -08:00
2022-01-19 11:08:59 -08:00

jc

JC - JSON CLI output utility

This package serializes the output of many standard unix command line tools to dictionaries and lists of dictionaries.

For documentation on each parser, see the documentation site or use jc.get_help('parser_module_name')

Example:

>>> import subprocess
>>> import jc
>>>
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
                                         text=True)
>>> data = jc.parse('dig', cmd_output)
>>> data
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]

Alternatively, you can bypass the high-level API and call the parser modules directly:

>>> import subprocess
>>> import jc.parsers.dig
>>>
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
                                         text=True)
>>> data = jc.parsers.dig.parse(cmd_output)
>>> data
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]

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().