From: Alexander Popov Date: Mon, 28 Mar 2022 09:17:31 +0000 (+0300) Subject: Add cmdline file parsing X-Git-Tag: v0.6.1~158^2~6 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=e0ba390411f01ee16adb2e5679e62bda1b3083ad;p=kconfig-hardened-check.git Add cmdline file parsing --- diff --git a/kconfig_hardened_check/__init__.py b/kconfig_hardened_check/__init__.py index 565503e..bf7977d 100644 --- a/kconfig_hardened_check/__init__.py +++ b/kconfig_hardened_check/__init__.py @@ -804,9 +804,20 @@ def parse_kconfig_file(parsed_options, fname): def parse_cmdline_file(parsed_options, fname): with open(fname, 'r') as f: - print('FIXME! cmdline file:') - for line in f.readlines(): - print(line) + line = f.readline() + opts = line.split() + + line = f.readline() + if line: + sys.exit('[!] ERROR: more than one line in "{}"'.format(fname)) + + for opt in opts: + if '=' in opt: + name, value = opt.split('=', 1) + else: + name = opt + value = '' # '' is not None + parsed_options[name] = value def main():