From 1d8cfae89f24192b6fab087f59c9b8988ef363dc Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 12 Sep 2021 17:30:56 -0700 Subject: [PATCH] only print _meta object if -q or quiet flag is used. Also, add message to the end of exceptions informing of the -q option to ignore errors --- jc/parsers/ls_s.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jc/parsers/ls_s.py b/jc/parsers/ls_s.py index 839a00e3..a2d009b8 100644 --- a/jc/parsers/ls_s.py +++ b/jc/parsers/ls_s.py @@ -34,7 +34,7 @@ Schema: "date": string, "epoch": integer, # naive timestamp if date field exists and can be converted "epoch_utc": integer, # timezone aware timestamp if date field is in UTC and can be converted - "_meta": + "_meta": # This object only exists if using -q or quiet=True { "success": booean, # true if successfully parsed, false if error "error_msg": string, # exists if "success" is false @@ -195,16 +195,19 @@ def parse(data, raw=False, quiet=False): output_line['group'] = parsed_line[3] output_line['size'] = parsed_line[4] output_line['date'] = ' '.join(parsed_line[5:8]) - output_line['_meta'] = {'success': True} + + if quiet: + output_line['_meta'] = {'success': True} if raw: yield output_line else: yield _process(output_line) - except Exception: + except Exception as e: if not quiet: - raise + e.args = (str(e) + '... Try the quiet option (-q) to ignore errors.',) + raise e else: yield { '_meta':