diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-08 07:36:57 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-08 07:37:27 +0100 |
| commit | 88fc64fbebd2d8344cb8af486e4dc732ed2542df (patch) | |
| tree | ac4a84445170ed786a145a1445d5fd1253ec699a /examples | |
| parent | a21d4585f2299df64cdb60af86c254aa4aa8da72 (diff) | |
Clarify allno/yesconfig.py.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/allnoconfig.py | 24 | ||||
| -rw-r--r-- | examples/allyesconfig.py | 13 |
2 files changed, 16 insertions, 21 deletions
diff --git a/examples/allnoconfig.py b/examples/allnoconfig.py index 2fe151d..7c22036 100644 --- a/examples/allnoconfig.py +++ b/examples/allnoconfig.py @@ -1,36 +1,32 @@ -# Works like allnoconfig. Verified to produce identical output to 'make -# allnoconfig' for all ARCHes. The looping is done in case setting one symbol -# to "n" allows other symbols to be set to "n" (due to dependencies). +# Works like allnoconfig. Automatically verified by the testsuite to generate +# identical output to 'make allnoconfig' for all ARCHes. The looping is done in +# case setting one symbol to "n" allows other symbols to be set to "n" (due to +# dependencies). import kconfiglib import sys conf = kconfiglib.Config(sys.argv[1]) -while True: +done = False +while not done: done = True for sym in conf: # Choices take care of themselves for allnoconfig, so we only need to # worry about non-choice symbols if not sym.is_choice_item(): + # If we can assign a value to the symbol (where "n", "m" and "y" + # are ordered from lowest to highest), then assign the lowest + # value. lower_bound() returns None for symbols whose values cannot + # (currently) be changed, as well as for non-bool/tristate symbols. lower_bound = sym.get_lower_bound() - - # If we can assign a lower value to the symbol (where "n", "m" and - # "y" are ordered from lowest to highest), then do so. - # lower_bound() returns None for symbols whose values cannot - # (currently) be changed, as well as for non-bool, non-tristate - # symbols. if lower_bound is not None and \ kconfiglib.tri_less(lower_bound, sym.calc_value()): sym.set_value(lower_bound) - # We just changed the value of some symbol. As this may affect # other symbols, keep going. done = False - if done: - break - conf.write_config(".config") diff --git a/examples/allyesconfig.py b/examples/allyesconfig.py index 12dc19e..aa1d58b 100644 --- a/examples/allyesconfig.py +++ b/examples/allyesconfig.py @@ -23,7 +23,8 @@ conf = kconfiglib.Config(sys.argv[1]) non_choice_syms = [sym for sym in conf.get_symbols() if not sym.is_choice_item()] -while True: +done = False +while not done: done = True # Handle symbols outside of choices @@ -50,17 +51,15 @@ while True: selection.set_value("y") done = False - # Handle choices whose visibility only allow them to be in "m" mode + # Handle choices whose visibility only allow them to be in "m" mode. + # This might happen if a choice depends on a symbol that can only be + # "m" for example. elif choice.get_visibility() == "m": - for sym in choice.get_items(): + for sym in choice.get_actual_items(): if sym.calc_value() != "m" and \ sym.get_upper_bound() != "n": sym.set_value("m") done = False - - if done: - break - conf.write_config(".config") |
