mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-08 22:36:48 +02:00
fixup for first and last items
This commit is contained in:
@ -142,7 +142,6 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
|||||||
for line in data:
|
for line in data:
|
||||||
try:
|
try:
|
||||||
jc.utils.streaming_line_input_type_check(line)
|
jc.utils.streaming_line_input_type_check(line)
|
||||||
linecomplete = False
|
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
|
|
||||||
# ignore blank lines
|
# ignore blank lines
|
||||||
@ -158,10 +157,9 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
|||||||
# line #1
|
# line #1
|
||||||
if line.startswith(' File: '):
|
if line.startswith(' File: '):
|
||||||
if output_line:
|
if output_line:
|
||||||
linecomplete = True
|
yield stream_success(output_line, ignore_exceptions) if raw else stream_success(_process(output_line), ignore_exceptions)
|
||||||
else:
|
|
||||||
linecomplete = False
|
output_line = {}
|
||||||
output_line = {}
|
|
||||||
line_list = line.split(maxsplit=1)
|
line_list = line.split(maxsplit=1)
|
||||||
output_line['file'] = line_list[1]
|
output_line['file'] = line_list[1]
|
||||||
|
|
||||||
@ -262,12 +260,18 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
|
|||||||
'blocks': value[13],
|
'blocks': value[13],
|
||||||
'unix_flags': value[14]
|
'unix_flags': value[14]
|
||||||
}
|
}
|
||||||
linecomplete = True
|
|
||||||
|
|
||||||
if linecomplete and output_line:
|
if output_line:
|
||||||
yield stream_success(output_line, ignore_exceptions) if raw else stream_success(_process(output_line), ignore_exceptions)
|
yield stream_success(output_line, ignore_exceptions) if raw else stream_success(_process(output_line), ignore_exceptions)
|
||||||
elif linecomplete:
|
output_line = {}
|
||||||
raise ParseError('Not stat data')
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
yield stream_error(e, ignore_exceptions, line)
|
yield stream_error(e, ignore_exceptions, line)
|
||||||
|
output_line = {}
|
||||||
|
|
||||||
|
# gather final item
|
||||||
|
try:
|
||||||
|
if output_line:
|
||||||
|
yield stream_success(output_line, ignore_exceptions) if raw else stream_success(_process(output_line), ignore_exceptions)
|
||||||
|
except Exception as e:
|
||||||
|
yield stream_error(e, ignore_exceptions, line)
|
||||||
|
Reference in New Issue
Block a user