summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-06-03 01:55:50 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2019-06-03 06:50:06 +0200
commitbf36f5de0f49d56975b1a844e25484ec385dc971 (patch)
tree258589b5bbf8a64ced24c27bded8f4e08805106c /examples
parent55bc8c380869ea663092212e8fe388ad7abae596 (diff)
Improve warning control API (with backwards compatibility)
A wart of the warning control API (enable/disable_*_warnings()) is that the current warning settings can't be queried. Querying warning settings is useful in functions that want to temporarily enable/disable some warning and then put things back to how they were. kconfiglib.load_allconfig() ran into this, for example. Make the internal warning control variables public (improve the naming at the same time), and encourage just setting them directly. Keep the old API for backwards compatibility. Also remove _warn_redun_assign() and _warn_override(). They're trivial and were called in a single place.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/menuconfig_example.py5
-rwxr-xr-xexamples/merge_config.py6
2 files changed, 5 insertions, 6 deletions
diff --git a/examples/menuconfig_example.py b/examples/menuconfig_example.py
index b265e69..2c98fff 100755
--- a/examples/menuconfig_example.py
+++ b/examples/menuconfig_example.py
@@ -277,9 +277,8 @@ def get_value_from_user(sc):
val = "0x" + val
# Let Kconfiglib itself print a warning here if the value is invalid. We
- # could also disable warnings temporarily with
- # kconf.disable_warnings() / kconf.enable_warnings() and print our own
- # warning.
+ # could also disable warnings temporarily with 'kconf.warn = False' and
+ # print our own warning.
return sc.set_value(val)
diff --git a/examples/merge_config.py b/examples/merge_config.py
index 6f60375..ef11d79 100755
--- a/examples/merge_config.py
+++ b/examples/merge_config.py
@@ -82,7 +82,7 @@ if len(sys.argv) < 4:
kconf = Kconfig(sys.argv[1])
# Enable warnings for assignments to undefined symbols
-kconf.enable_undef_warnings()
+kconf.warn_assign_undef = True
# (This script uses alldefconfig as the base. Other starting states could be
# set up here as well. The approach in examples/allnoconfig_simpler.py could
@@ -91,8 +91,8 @@ kconf.enable_undef_warnings()
# Disable warnings generated for multiple assignments to the same symbol within
# a (set of) configuration files. Assigning a symbol multiple times might be
# done intentionally when merging configuration files.
-kconf.disable_override_warnings()
-kconf.disable_redun_warnings()
+kconf.warn_assign_override = False
+kconf.warn_assign_redun = False
# Create a merged configuration by loading the fragments with replace=False.
# load_config() and write_config() returns a message to print.