mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-25 00:37:31 +02:00
add support for legacy output
This commit is contained in:
@ -89,15 +89,23 @@ def parse(data, raw=False, quiet=False):
|
|||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
cleandata = list(filter(None, linedata))
|
cleandata = list(filter(None, linedata))
|
||||||
|
|
||||||
# clear separator line
|
# detect legacy output type
|
||||||
for i, line in reversed(list(enumerate(cleandata))):
|
if cleandata[0].find(' (') != -1:
|
||||||
if line.find('---') != -1:
|
for row in cleandata:
|
||||||
cleandata.pop(i)
|
raw_output.append({'package': row.split(' (')[0],
|
||||||
|
'version': row.split(' (')[1].rstrip(')')})
|
||||||
|
|
||||||
cleandata[0] = cleandata[0].lower()
|
# otherwise normal table output
|
||||||
|
else:
|
||||||
|
# clear separator line
|
||||||
|
for i, line in reversed(list(enumerate(cleandata))):
|
||||||
|
if line.find('---') != -1:
|
||||||
|
cleandata.pop(i)
|
||||||
|
|
||||||
if cleandata:
|
cleandata[0] = cleandata[0].lower()
|
||||||
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
|
||||||
|
if cleandata:
|
||||||
|
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
|
Reference in New Issue
Block a user