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:
16
jc/utils.py
16
jc/utils.py
@ -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
|
||||
|
Reference in New Issue
Block a user