Commit 38b6bbb2 by Alexander Popov

Introduce the json_dump() class method

parent b68df4d3
...@@ -122,6 +122,12 @@ class KconfigCheck(OptCheck): ...@@ -122,6 +122,12 @@ class KconfigCheck(OptCheck):
def type(self): def type(self):
return 'kconfig' return 'kconfig'
def json_dump(self, with_results):
dump = [self.name, self.type, self.expected, self.decision, self.reason]
if with_results:
dump.append(self.result)
return dump
class VersionCheck: class VersionCheck:
def __init__(self, ver_expected): def __init__(self, ver_expected):
...@@ -221,6 +227,12 @@ class ComplexOptCheck: ...@@ -221,6 +227,12 @@ class ComplexOptCheck:
if with_results: if with_results:
print('| {}'.format(self.result), end='') print('| {}'.format(self.result), end='')
def json_dump(self, with_results):
dump = self.opts[0].json_dump(False)
if with_results:
dump.append(self.result)
return dump
class OR(ComplexOptCheck): class OR(ComplexOptCheck):
# self.opts[0] is the option that this OR-check is about. # self.opts[0] is the option that this OR-check is about.
...@@ -645,13 +657,10 @@ def print_unknown_options(checklist, parsed_options): ...@@ -645,13 +657,10 @@ def print_unknown_options(checklist, parsed_options):
def print_checklist(mode, checklist, with_results): def print_checklist(mode, checklist, with_results):
if mode == 'json': if mode == 'json':
opts = [] output = []
for o in checklist: for o in checklist:
opt = [o.name, o.type, o.expected, o.decision, o.reason] output.append(o.json_dump(with_results))
if with_results: print(json.dumps(output))
opt.append(o.result)
opts.append(opt)
print(json.dumps(opts))
return return
# table header # table header
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment