mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
* version bump * fix regex for crlf line endings * Completed Ip_route parser (#429) * tests * Merge pull request #398 from kellyjonbrazil/dev Dev v1.23.2 * Merge pull request #398 from kellyjonbrazil/dev Dev v1.23.2 --------- Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com> Co-authored-by: Jjack3032 <julian.jackson@parsons.us> * formatting * doc update * use splitlines * formatting * formatting * Parser for `find` linux command (#434) * Added find parser and tests for Centos 7.7 and Ubuntu 18.04 * Added a test file, changed logic, and included a case for permission denied returned by find. * Added a few more lines to the tests * Changed logic for setting values to null and updated test cases. * doc update * doc update * Added proc_net_tcp parser (#421) Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com> * clean up net_tcp parser * add resolve.conf test files * doc update * add resolve.conf parser * doc update * add sortlist functionality * add resolve.conf parser tests * doc update --------- Co-authored-by: Julian5555 <58196809+Julian5555@users.noreply.github.com> Co-authored-by: Jjack3032 <julian.jackson@parsons.us> Co-authored-by: solomonleang <124934439+solomonleang@users.noreply.github.com> Co-authored-by: AlvinSolomon <41175627+AlvinSolomon@users.noreply.github.com>
1.5 KiB
1.5 KiB
jc.parsers.find
jc - JSON Convert find
command output parser
This parser returns a list of objects by default and a list of strings if
the --raw
option is used.
Usage (cli):
$ find | jc --find
Usage (module):
import jc
result = jc.parse('find', find_command_output)
Schema:
[
{
"path": string,
"node": string,
"error": string
}
]
Examples:
$ find | jc --find -p
[
{
"path": "./directory"
"node": "filename"
},
{
"path": "./anotherdirectory"
"node": "anotherfile"
},
{
"path": null
"node": null
"error": "find: './inaccessible': Permission denied"
}
...
]
$ find | jc --find -p -r
[
"./templates/readme_template",
"./templates/manpage_template",
"./.github/workflows/pythonapp.yml",
...
]
parse
def parse(data, raw=False, quiet=False)
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
List of raw strings or
List of Dictionaries of processed structured data
Parser Information
Compatibility: linux
Version 1.0 by Solomon Leang (solomonleang@gmail.com)