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

add stream_error function

This commit is contained in:
Kelly Brazil
2021-09-13 18:29:10 -07:00
parent 260f3685d9
commit 27eb427245

View File

@ -173,6 +173,22 @@ def convert_to_bool(value):
return False
def stream_error(e, quiet, line):
"""reraise the stream exception with annotation or print an error _meta field if quiet=True"""
if not quiet:
e.args = (str(e) + '... Use the quiet option (-q) to ignore errors.',)
raise e
else:
return {
'_meta':
{
'success': False,
'error': 'error parsing line',
'line': line.strip()
}
}
class timestamp:
"""
Input a date-time text string of several formats and convert to a naive or timezone-aware epoch timestamp in UTC