diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-12 11:16:11 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2012-12-12 11:16:11 +0100 |
| commit | c6c21b2455a8ffc20c8fb5b4bedbd9a2d2eb7dab (patch) | |
| tree | 3a08b0207cbdc46483c0365df2402cd66d323390 | |
| parent | 2f26f5c2e68a804a5f7f24482a46bf254c1120a2 (diff) | |
Re-enable set_user_value() warning for symbols with no prompts.
Disable warnings in allnoconfig_simpler.py instead.
| -rw-r--r-- | examples/allnoconfig_simpler.py | 5 | ||||
| -rw-r--r-- | kconfiglib.py | 20 | ||||
| -rw-r--r-- | kconfigtest.py | 6 |
3 files changed, 20 insertions, 11 deletions
diff --git a/examples/allnoconfig_simpler.py b/examples/allnoconfig_simpler.py index affa004..f8f2a2c 100644 --- a/examples/allnoconfig_simpler.py +++ b/examples/allnoconfig_simpler.py @@ -16,6 +16,11 @@ import sys conf = kconfiglib.Config(sys.argv[1]) +# Avoid warnings printed by Kconfiglib when assigning a user value with +# set_user_value() to a symbol that has no prompt (such assignments never have +# an effect) +conf.set_print_warnings(False) + for sym in conf: if sym.get_type() in (kconfiglib.BOOL, kconfiglib.TRISTATE): sym.set_user_value("n") diff --git a/kconfiglib.py b/kconfiglib.py index 17afc7d..6d9f420 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2214,7 +2214,7 @@ class _HasVisibility(): """Base class for elements that have a "visibility" that acts as an upper limit on the values a user can set for them. Subclasses are Symbol and - Choice.""" + Choice (which supply some of the attributes).""" def __init__(self): self.cached_visibility = None @@ -2857,9 +2857,11 @@ class Symbol(Item, _HasVisibility): """Like set_user_value(), but does not invalidate any symbols. suppress_load_warnings -- - some warnings don't make sense when loading a .config that do make - sense when manually invoking set_user_value(). This flag is set to True to - suppress such warnings.""" + some warnings are annoying when loading a .config that can be helpful + when manually invoking set_user_value(). This flag is set to True to + suppress such warnings. + + Perhaps this could be made optional for load_config() instead.""" if self.is_special_: if self.is_from_env: @@ -2900,11 +2902,11 @@ class Symbol(Item, _HasVisibility): # This warning is annoying when running allnoconfig_simpler.py. Make it # optional? - #if self.prompts == [] and not suppress_load_warnings: - #self.config._warn('assigning "{0}" to the symbol {1} which lacks ' - #'prompts and thus has visibility "n". The assignment ' - #'will have no effect.' - #.format(v, self.name)) + if self.prompts == [] and not suppress_load_warnings: + self.config._warn('assigning "{0}" to the symbol {1} which lacks ' + 'prompts and thus has visibility "n". The assignment ' + 'will have no effect.' + .format(v, self.name)) self.user_val = v diff --git a/kconfigtest.py b/kconfigtest.py index 7927484..e0fae52 100644 --- a/kconfigtest.py +++ b/kconfigtest.py @@ -541,6 +541,10 @@ def run_selftests(): print "Testing get_user_value()..." + # Avoid warnings from assigning invalid user values and assigning user + # values to symbols without prompts + c.set_print_warnings(False) + syms = [c[name] for name in \ ("BOOL", "TRISTATE", "STRING", "INT", "HEX")] b, t, s, i, h = syms @@ -571,8 +575,6 @@ def run_selftests(): # Assign invalid values for the types. They should retain their old user # value. - c.set_print_warnings(False) - assign_and_verify_new_user_value(b, "m", "y") assign_and_verify_new_user_value(b, "foo", "y") assign_and_verify_new_user_value(b, "1", "y") |
