From: Alexander Popov Date: Sun, 27 Mar 2022 18:25:04 +0000 (+0300) Subject: Add the CmdlineCheck class X-Git-Tag: v0.6.1~158^2~10 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=b9e670c37666fe04c1bd1dc102abe67589cdbcde;p=kconfig-hardened-check.git Add the CmdlineCheck class --- diff --git a/kconfig_hardened_check/__init__.py b/kconfig_hardened_check/__init__.py index 9b3c94c..17bf7be 100644 --- a/kconfig_hardened_check/__init__.py +++ b/kconfig_hardened_check/__init__.py @@ -132,6 +132,12 @@ class OptCheck: if with_results: print('| {}'.format(self.result), end='') + 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 KconfigCheck(OptCheck): def __init__(self, *args, **kwargs): @@ -142,11 +148,11 @@ class KconfigCheck(OptCheck): def type(self): 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 CmdlineCheck(OptCheck): + @property + def type(self): + return 'cmdline' class VersionCheck: @@ -185,7 +191,7 @@ class ComplexOptCheck: sys.exit('[!] ERROR: empty {} check'.format(self.__class__.__name__)) if len(self.opts) == 1: sys.exit('[!] ERROR: useless {} check'.format(self.__class__.__name__)) - if not isinstance(opts[0], KconfigCheck): + if not isinstance(opts[0], KconfigCheck) and not isinstance(opts[0], CmdlineCheck): sys.exit('[!] ERROR: invalid {} check: {}'.format(self.__class__.__name__, opts)) self.result = None