1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

doc updates

This commit is contained in:
Kelly Brazil
2021-09-13 15:05:49 -07:00
parent 1ac944fa02
commit 76e78fc0c3

View File

@ -1,8 +1,8 @@
"""jc - JSON CLI output utility `ls` and `vdir` command output streaming parser """jc - JSON CLI output utility `ls` and `vdir` command output streaming parser
This streaming parser requires the `-l` option to be used on `ls`. If there are newline characters in the filename, then make sure to use the `-b` or `-B` option on `ls`. This streaming parser requires the `-l` option to be used on `ls`. If there are newline characters in the filename, then make sure to use the `-b` option on `ls`.
The `jc` `-q` option can be used to ignore parsing errors. (e.g. filenames with newline characters, but `-b` or `-B` was not used) The `jc` `-q` option can be used to ignore parsing errors. (e.g. filenames with newline characters, but `-b` was not used)
The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on) The `epoch` calculated timestamp field is naive (i.e. based on the local time of the system the parser is run on)
@ -79,11 +79,11 @@ def _process(proc_data):
Parameters: Parameters:
proc_data: (List of Dictionaries) raw structured data to process proc_data: (Dictionary) raw structured data to process
Returns: Returns:
List of Dictionaries. Structured data to conform to the schema. Dictionary. Structured data to conform to the schema.
""" """
int_list = ['links', 'size'] int_list = ['links', 'size']
for key in proc_data: for key in proc_data:
@ -102,17 +102,17 @@ def _process(proc_data):
def parse(data, raw=False, quiet=False): def parse(data, raw=False, quiet=False):
""" """
Main text parsing function Main text parsing generator function. Produces an iterable object.
Parameters: Parameters:
data: (string) line-based text data to parse data: (string) line-based text data to parse
raw: (boolean) output preprocessed JSON if True raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True quiet: (boolean) suppress warning messages and ignore parsing errors if True
Returns: Yields:
List of Dictionaries. Raw or processed structured data. Dictionary. Raw or processed structured data.
""" """
if not quiet: if not quiet:
jc.utils.compatibility(__name__, info.compatible) jc.utils.compatibility(__name__, info.compatible)
@ -164,8 +164,6 @@ def parse(data, raw=False, quiet=False):
if quiet: if quiet:
output_line['_meta'] = {'success': True} output_line['_meta'] = {'success': True}
last_object = output_line
if raw: if raw:
yield output_line yield output_line
@ -174,7 +172,7 @@ def parse(data, raw=False, quiet=False):
except Exception as e: except Exception as e:
if not quiet: if not quiet:
e.args = (str(e) + '... Try the quiet option (-q) to ignore errors.',) e.args = (str(e) + '... Use the quiet option (-q) to ignore errors.',)
raise e raise e
else: else:
yield { yield {