mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
update docstrings
This commit is contained in:
@ -18,7 +18,7 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc.parsers.ls_s
|
import jc.parsers.ls_s
|
||||||
result = jc.parsers.ls_s.parse(ls_command_output) # result is an iterable object
|
result = jc.parsers.ls_s.parse(ls_command_output.splitlines()) # result is an iterable object
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -73,9 +73,9 @@ Main text parsing generator function. Produces an iterable object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (string) line-based text data to parse
|
data: (iterable) line-based text data to parse (e.g. str.splitlines())
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages and ignore parsing errors if True
|
quiet: (boolean) suppress warning messages and ignore parsing exceptions if True
|
||||||
|
|
||||||
Yields:
|
Yields:
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ Usage (cli):
|
|||||||
|
|
||||||
$ ping | jc --ping-s
|
$ ping | jc --ping-s
|
||||||
|
|
||||||
> Note: When piping `jc` output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `ping` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/streaming#streaming-parsers) for more information.
|
> Note: When piping `jc` converted ping output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `ping` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/streaming#streaming-parsers) for more information.
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc.parsers.ping_s
|
import jc.parsers.ping_s
|
||||||
result = jc.parsers.ping_s.parse(ping_command_output) # result is an iterable object
|
result = jc.parsers.ping_s.parse(ping_command_output.splitlines()) # result is an iterable object
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -80,15 +80,15 @@ Main text parsing generator function. Produces an iterable object.
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (string) line-based text data to parse
|
data: (iterable) line-based text data to parse (e.g. str.splitlines())
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages and ignore parsing errors if True
|
quiet: (boolean) suppress warning messages and ignore parsing exceptions if True
|
||||||
|
|
||||||
Yields:
|
Yields:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
|
|
||||||
## Parser Information
|
## Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, aix, freebsd
|
Compatibility: linux, darwin, freebsd
|
||||||
|
|
||||||
Version 0.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 0.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -7,7 +7,7 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc.parsers.foo_s
|
import jc.parsers.foo_s
|
||||||
result = jc.parsers.foo_s.parse(foo_command_output) # result is an iterable object
|
result = jc.parsers.foo_s.parse(foo_command_output.splitlines()) # result is an iterable object
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -79,9 +79,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (string) line-based text data to parse
|
data: (iterable) line-based text data to parse (e.g. str.splitlines())
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages and ignore parsing errors if True
|
quiet: (boolean) suppress warning messages and ignore parsing exceptions if True
|
||||||
|
|
||||||
Yields:
|
Yields:
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc.parsers.ls_s
|
import jc.parsers.ls_s
|
||||||
result = jc.parsers.ls_s.parse(ls_command_output) # result is an iterable object
|
result = jc.parsers.ls_s.parse(ls_command_output.splitlines()) # result is an iterable object
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -108,9 +108,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (string) line-based text data to parse
|
data: (iterable) line-based text data to parse (e.g. str.splitlines())
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages and ignore parsing errors if True
|
quiet: (boolean) suppress warning messages and ignore parsing exceptions if True
|
||||||
|
|
||||||
Yields:
|
Yields:
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', line):
|
if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', line):
|
||||||
raise ParseError(f'Not ls -l data')
|
raise ParseError('Not ls -l data')
|
||||||
|
|
||||||
parsed_line = line.strip().split(maxsplit=8)
|
parsed_line = line.strip().split(maxsplit=8)
|
||||||
output_line = {}
|
output_line = {}
|
||||||
|
@ -6,12 +6,12 @@ Usage (cli):
|
|||||||
|
|
||||||
$ ping | jc --ping-s
|
$ ping | jc --ping-s
|
||||||
|
|
||||||
> Note: When piping `jc` output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `ping` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/streaming#streaming-parsers) for more information.
|
> Note: When piping `jc` converted ping output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because `ping` output is too small to quickly fill up the buffer. Use the `-u` option to unbuffer the `jc` output if you would like immediate output. See the [readme](https://github.com/kellyjonbrazil/jc/tree/streaming#streaming-parsers) for more information.
|
||||||
|
|
||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc.parsers.ping_s
|
import jc.parsers.ping_s
|
||||||
result = jc.parsers.ping_s.parse(ping_command_output) # result is an iterable object
|
result = jc.parsers.ping_s.parse(ping_command_output.splitlines()) # result is an iterable object
|
||||||
for item in result:
|
for item in result:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class info():
|
|||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
|
|
||||||
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
# compatible options: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'freebsd']
|
||||||
streaming = True
|
streaming = True
|
||||||
|
|
||||||
|
|
||||||
@ -455,9 +455,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (string) line-based text data to parse
|
data: (iterable) line-based text data to parse (e.g. str.splitlines())
|
||||||
raw: (boolean) output preprocessed JSON if True
|
raw: (boolean) output preprocessed JSON if True
|
||||||
quiet: (boolean) suppress warning messages and ignore parsing errors if True
|
quiet: (boolean) suppress warning messages and ignore parsing exceptions if True
|
||||||
|
|
||||||
Yields:
|
Yields:
|
||||||
|
|
||||||
|
2
man/jc.1
2
man/jc.1
@ -1,4 +1,4 @@
|
|||||||
.TH jc 1 2021-09-20 1.17.0 "JSON CLI output utility"
|
.TH jc 1 2021-09-21 1.17.0 "JSON CLI output utility"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
jc \- JSONifies the output of many CLI tools and file-types
|
jc \- JSONifies the output of many CLI tools and file-types
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
Reference in New Issue
Block a user