From: Alexander Popov Date: Sat, 22 Jul 2023 21:44:17 +0000 (+0300) Subject: Refactor populate_opt_with_data() X-Git-Tag: v0.6.6~116 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=51a3a89b308be0b71059c294551651238da7230b;hp=e6963df5f15afcd4a74f4216a9e269ed2e1d396f;p=kconfig-hardened-check.git Refactor populate_opt_with_data() Much better code, no functional changes --- diff --git a/kconfig_hardened_check/engine.py b/kconfig_hardened_check/engine.py index 8f3191b..2e86ef3 100644 --- a/kconfig_hardened_check/engine.py +++ b/kconfig_hardened_check/engine.py @@ -269,17 +269,16 @@ def populate_simple_opt_with_data(opt, data, data_type): def populate_opt_with_data(opt, data, data_type): - if opt.type == 'complex': + assert(opt.type != 'version'), 'a single VersionCheck is useless' + if opt.type != 'complex': + populate_simple_opt_with_data(opt, data, data_type) + else: for o in opt.opts: - if o.type == 'complex': + if o.type != 'complex': + populate_simple_opt_with_data(o, data, data_type) + else: # Recursion for nested ComplexOptCheck objects populate_opt_with_data(o, data, data_type) - else: - populate_simple_opt_with_data(o, data, data_type) - else: - assert(opt.type != 'version'), \ - 'a simple check with a single VersionCheck is useless' - populate_simple_opt_with_data(opt, data, data_type) def populate_with_data(checklist, data, data_type):