1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-15 01:24:29 +02:00

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

This commit is contained in:
Kelly Brazil
2021-09-12 17:30:56 -07:00
parent 787df51239
commit 1d8cfae89f

View File

@ -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,6 +195,8 @@ 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])
if quiet:
output_line['_meta'] = {'success': True}
if raw:
@ -202,9 +204,10 @@ def parse(data, raw=False, quiet=False):
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':