1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs
Kelly Brazil 5023e5be4c Dev v1.23.3 (#426)
* make certificate search more robust to different line endings

* use license_files instead of license_file which is deprecated

* version bump

* parsing extra options -e, -o, -p

* fix for extra opts and different field length at option -[aeop]

* test integration for extra opts -e -o -p

* formatting and use ast.literal_eval instead of eval

* doc update

* doc update

* Add a parser to parse mounted encrypted veracrypt volumes (fixes #403)

* update compatibility warning message

* netstat windows parser

* tests

* Windows route parser

* tests

* id should be a string

* add veracrypt parser and docs

* formatting

* doc update

* lsattr parser

* Update test_lsattr.py

* changed keys to lowercase

* changed info

* support missing data for stat

* doc update

* doc update

* doc update

* ensure compatibility warning prints even with no data

* improve compatibility message

* add support for dig +nsid option

* New parser: srt (#415)

* srt parser

* changed the parser to support more complex cases

* doc updates

* Adding certificate request parser (#416)

* Adding certificate request parser

* Adding the CSR type for Windows-style CSR

---------

Co-authored-by: Stg22 <stephane.for.test@gmail.com>

* doc update

* add csr tests

* Last -x (#422)

* Refactored the parser

* last -x support

* doc update

* fix for ping on linux with missing hostname

* allow less strict email decoding with a warning.

* doc update

* use explicit ascii decode with backslashreplace

* doc update

* use jc warning function instead of print for warning message

* last -x shutdown fix (#423)

* inject quiet setting into asn1crypto library

* Parse appearance and modalias lines for mouse devices (fixes #419) (#425)

The bluetoothctl device parser is implemented so that it aborts the parsing
process immediately returning what it has collected so far. This is because
the parser should work in hydrid way to support outputs comming from bluetoothctl
devices and bluetoothctl info calls.

* doc update

* doc update

---------

Co-authored-by: gerd <gerd.augstein@gmail.com>
Co-authored-by: Jake Ob <iakopap@gmail.com>
Co-authored-by: Mevaser <mevaser.rotner@gmail.com>
Co-authored-by: M.R <69431152+YeahItsMeAgain@users.noreply.github.com>
Co-authored-by: Stg22 <46686290+Stg22@users.noreply.github.com>
Co-authored-by: Stg22 <stephane.for.test@gmail.com>
2023-06-21 15:48:23 -07:00
..
2023-06-21 15:48:23 -07:00
2023-01-22 10:37:27 -08:00
2022-08-21 16:23:56 -07:00
2022-12-13 13:30:50 -08:00

jc

JC - JSON Convert

This package converts the output of many standard unix command line tools and file-types to dictionaries and lists of dictionaries.

Interactive Documentation

Using jc in your python programs:

>>> help('jc')
>>> help('jc.lib')
>>> jc.get_help('parser_module_name')

Developing jc parsers:

>>> help('jc.utils')
>>> help('jc.streaming')
>>> help('jc.parsers.universal')

Online Documentation

Latest

https://github.com/kellyjonbrazil/jc/tree/master/docs

Specific Version

https://github.com/kellyjonbrazil/jc/tree/v<full_version_number>/docs

Replace <full_version_number> - e.g. 1.18.0:

Specific versions can also be selected by tag in the Github branch dropdown menu.

Usage 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

parse(
    parser_module_name: str,
    data: str | bytes | Iterable
) -> dict | list[dict] | Iterable[dict]

High-level API to easily access the parser. This API will find both built-in parsers and local plugin parsers.

parser_info

parser_info(
    parser_module_name: str,
    documentation: bool = False
) -> dict

Get the metadata for a particular parser.

all_parser_info

all_parser_info(documentation: bool = False) -> list[dict]

Get the metadata for all parsers.

get_help

get_help(parser_module_name: str) -> None

Convenience function to display the help screen for a parser using its module name.

parser_mod_list

parser_mod_list() -> list[str]

Get a list of all available parser module names to be used in parse(), parser_info(), and get_help().

plugin_parser_mod_list

plugin_parser_mod_list() -> list[str]

Get a list of plugin parser module names to be used in parse(), parser_info(), and get_help(). This list is a subset of parser_mod_list().

standard_parser_mod_list

standard_parser_mod_list() -> list[str]

Get a list of standard parser module names to be used in parse(), parser_info(), and get_help(). This list is a subset of parser_mod_list() and does not contain any streaming parsers.

streaming_parser_mod_list

streaming_parser_mod_list() -> list[str]

Get a list of streaming parser module names to be used in parse(), parser_info(), and get_help(). This list is a subset of parser_mod_list().