diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-06-12 01:58:41 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-06-12 02:04:45 +0200 |
| commit | 0327db2e642800a1608b006cd6c569f7bca0ff5c (patch) | |
| tree | 99a04f410cd8e8a736d8c48b9c6039b51785ef5c | |
| parent | 506e3fb211d22f62115ce83e9247266c5d87ea24 (diff) | |
Simplify allnoconfig.py and allyesconfig.py
We can rely on set_value() being a no-op when setting non-bool/tristate
symbols to 0/1/2 (due to those values being invalid for other types).
Remove some long duplicated comments too.
| -rwxr-xr-x | allmodconfig.py | 3 | ||||
| -rwxr-xr-x | allnoconfig.py | 20 | ||||
| -rwxr-xr-x | allyesconfig.py | 24 |
3 files changed, 25 insertions, 22 deletions
diff --git a/allmodconfig.py b/allmodconfig.py index 35caa9c..b8f792a 100755 --- a/allmodconfig.py +++ b/allmodconfig.py @@ -18,8 +18,7 @@ import kconfiglib def main(): kconf = kconfiglib.standard_kconfig() - # Avoid warnings printed by Kconfiglib when assigning a value to a symbol that - # has no prompt. Such assignments never have an effect. + # See allnoconfig.py kconf.disable_warnings() # Small optimizations diff --git a/allnoconfig.py b/allnoconfig.py index f7b9b64..1d14e97 100755 --- a/allnoconfig.py +++ b/allnoconfig.py @@ -20,16 +20,22 @@ import kconfiglib def main(): kconf = kconfiglib.standard_kconfig() - # Avoid warnings printed by Kconfiglib when assigning a value to a symbol that - # has no prompt. Such assignments never have an effect. + # Avoid warnings printed by Kconfiglib when assigning a value to a symbol + # that has no prompt. Such assignments never have an effect. + + # Avoid warnings that would otherwise get printed by Kconfiglib for the + # following: + # + # 1. Assigning a value to a symbol without a prompt, which never has any + # effect + # + # 2. Assigning values invalid for the type (only bool/tristate symbols + # accept 0/1/2, for n/m/y). The assignments will be ignored for other + # symbol types, which is what we want. kconf.disable_warnings() - # Small optimization - BOOL_TRI = (kconfiglib.BOOL, kconfiglib.TRISTATE) - for sym in kconf.defined_syms: - if sym.orig_type in BOOL_TRI: - sym.set_value(2 if sym.is_allnoconfig_y else 0) + sym.set_value(2 if sym.is_allnoconfig_y else 0) kconf.write_config(kconfiglib.standard_config_filename()) diff --git a/allyesconfig.py b/allyesconfig.py index ecc74ba..bf7ca51 100755 --- a/allyesconfig.py +++ b/allyesconfig.py @@ -36,22 +36,20 @@ import kconfiglib def main(): kconf = kconfiglib.standard_kconfig() - # Avoid warnings printed by Kconfiglib when assigning a value to a symbol that - # has no prompt. Such assignments never have an effect. + # See allnoconfig.py kconf.disable_warnings() - # Small optimization - BOOL_TRI = (kconfiglib.BOOL, kconfiglib.TRISTATE) - - # Try to set all bool/tristate symbols to 'y'. Dependencies might truncate - # the value down later, but this will at least give the highest possible - # value. + # Try to set all symbols to 'y'. Dependencies might truncate the value down + # later, but this will at least give the highest possible value. + # + # Assigning 0/1/2 to non-bool/tristate symbols has no effect (int/hex + # symbols still take a string, because they preserve formatting). for sym in kconf.defined_syms: - if sym.orig_type in BOOL_TRI: - # Set all choice symbols to 'm'. This value will be ignored for - # choices in 'y' mode (the "normal" mode), but will set all symbols - # in m-mode choices to 'm', which is as high as they can go. - sym.set_value(1 if sym.choice else 2) + # Set choice symbols to 'm'. This value will be ignored for choices in + # 'y' mode (the "normal" mode), which will instead just get their + # default selection, but will set all symbols in m-mode choices to 'm', + # which is as high as they can go. + sym.set_value(1 if sym.choice else 2) # Set all choices to the highest possible mode for choice in kconf.choices: |
