mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
add template parser
This commit is contained in:
52
jc/parsers/foo.py
Normal file
52
jc/parsers/foo.py
Normal file
@ -0,0 +1,52 @@
|
||||
"""jc - JSON CLI output utility foo Parser
|
||||
|
||||
Usage:
|
||||
specify --foo as the first argument if the piped input is coming from foo
|
||||
|
||||
Examples:
|
||||
|
||||
$ foo | jc --foo -p
|
||||
[]
|
||||
|
||||
$ foo | jc --foo -p -r
|
||||
[]
|
||||
"""
|
||||
import jc.utils
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
'''schema:
|
||||
[
|
||||
{
|
||||
"foo": string,
|
||||
"bar": boolean,
|
||||
"baz": integer
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
# rebuild output for added semantic information
|
||||
return proc_data
|
||||
|
||||
|
||||
def parse(data, raw=False, quiet=False):
|
||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||
|
||||
if not quiet:
|
||||
jc.utils.compatibility(__name__, compatible)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
||||
# Clear any blank lines
|
||||
cleandata = list(filter(None, cleandata))
|
||||
|
||||
if cleandata:
|
||||
# parse the content
|
||||
pass
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
Reference in New Issue
Block a user