mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
simplify yield statements
This commit is contained in:
@@ -63,7 +63,9 @@ def _process(proc_data):
|
|||||||
|
|
||||||
Dictionary. Structured data to conform to the schema.
|
Dictionary. Structured data to conform to the schema.
|
||||||
"""
|
"""
|
||||||
# process the data
|
#
|
||||||
|
# process the data here
|
||||||
|
#
|
||||||
|
|
||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
@@ -87,15 +89,14 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
for line in data:
|
for line in data:
|
||||||
try:
|
try:
|
||||||
|
#
|
||||||
# parse the input here
|
# parse the input here
|
||||||
|
#
|
||||||
|
|
||||||
if quiet:
|
if quiet:
|
||||||
output_line['_meta'] = {'success': True}
|
output_line.update(jc.utils.stream_success)
|
||||||
|
|
||||||
if raw:
|
yield output_line if raw else _process(output_line)
|
||||||
yield output_line
|
|
||||||
else:
|
|
||||||
yield _process(output_line)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
yield jc.utils.stream_error(e, quiet, line)
|
yield jc.utils.stream_error(e, quiet, line)
|
||||||
|
@@ -167,12 +167,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
output_line['date'] = ' '.join(parsed_line[5:8])
|
output_line['date'] = ' '.join(parsed_line[5:8])
|
||||||
|
|
||||||
if quiet:
|
if quiet:
|
||||||
output_line['_meta'] = {'success': True}
|
output_line.update(jc.utils.stream_success)
|
||||||
|
|
||||||
if raw:
|
yield output_line if raw else _process(output_line)
|
||||||
yield output_line
|
|
||||||
else:
|
|
||||||
yield _process(output_line)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
yield jc.utils.stream_error(e, quiet, line)
|
yield jc.utils.stream_error(e, quiet, line)
|
||||||
|
@@ -192,12 +192,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if quiet:
|
if quiet:
|
||||||
output_line['_meta'] = {'success': True}
|
output_line.update(jc.utils.stream_success)
|
||||||
|
|
||||||
if raw:
|
yield output_line if raw else _process(output_line)
|
||||||
yield output_line
|
|
||||||
else:
|
|
||||||
yield _process(output_line)
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -235,12 +232,9 @@ def parse(data, raw=False, quiet=False):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if quiet:
|
if quiet:
|
||||||
output_line['_meta'] = {'success': True}
|
output_line.update(jc.utils.stream_success)
|
||||||
|
|
||||||
if raw:
|
yield output_line if raw else _process(output_line)
|
||||||
yield output_line
|
|
||||||
else:
|
|
||||||
yield _process(output_line)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
yield jc.utils.stream_error(e, quiet, line)
|
yield jc.utils.stream_error(e, quiet, line)
|
||||||
|
Reference in New Issue
Block a user