summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2017-11-06 03:46:41 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2017-11-06 03:58:04 +0100
commitdccbad534a1ffe688d45810faf986ff79a0f3a41 (patch)
tree271ee08edfa561cd0d767387f2c1d3e059bffd0e /examples
parentde6e57ff6dd4bab3d2a78f8d01b2bfecbd663fc4 (diff)
Clean up examples a bit
conf -> kconf, for consistency, plus various nits.
Diffstat (limited to 'examples')
-rw-r--r--examples/allyesconfig.py8
-rw-r--r--examples/eval_expr.py8
-rw-r--r--examples/help_grep.py4
-rw-r--r--examples/print_sym_info.py4
-rw-r--r--examples/print_tree.py4
5 files changed, 16 insertions, 12 deletions
diff --git a/examples/allyesconfig.py b/examples/allyesconfig.py
index b9210d3..a515196 100644
--- a/examples/allyesconfig.py
+++ b/examples/allyesconfig.py
@@ -2,7 +2,8 @@
# identical to 'make allyesconfig', for all ARCHES.
#
# This example is implemented a bit differently from allnoconfig.py to
-# demonstrate some other possibilities.
+# demonstrate some other possibilities. A variant similar to
+# allnoconfig_simpler.py could be constructed too.
#
# In theory, we need to handle choices in two different modes:
#
@@ -39,7 +40,7 @@ def all_choices(node):
(I was thinking of making a list of choices available directly in the API,
but I'm not sure it will always be needed internally, and I'm trying to
- spam the API with less seldom-used stuff compared to Kconfiglib 1.)
+ spam the API with less seldomly-used stuff compared to Kconfiglib 1.)
"""
res = []
@@ -75,8 +76,9 @@ while True:
choice.set_value(choice.assignable[-1])
changed = True
+ # For y-mode choices, we just let the choice get its default
+ # selection. For m-mode choices, we set all choice symbols to m.
if choice.tri_value == 1:
- # For m-mode choices, set all choice symbols to m
for sym in choice.syms:
sym.set_value(1)
diff --git a/examples/eval_expr.py b/examples/eval_expr.py
index 260edbe..36a7e6a 100644
--- a/examples/eval_expr.py
+++ b/examples/eval_expr.py
@@ -13,10 +13,12 @@ if len(sys.argv) < 3:
print('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=NAME')
sys.exit(1)
-conf = kconfiglib.Kconfig(sys.argv[1])
+expr = sys.argv[2]
+
+kconf = kconfiglib.Kconfig(sys.argv[1])
# Enable modules so that m doesn't get demoted to n
-conf.syms["MODULES"].set_value(2)
+kconf.syms["MODULES"].set_value(2)
print("the expression '{}' evaluates to {}"
- .format(sys.argv[2], conf.eval_string(sys.argv[2])))
+ .format(expr, kconf.eval_string(expr)))
diff --git a/examples/help_grep.py b/examples/help_grep.py
index b9e1440..01ea5e7 100644
--- a/examples/help_grep.py
+++ b/examples/help_grep.py
@@ -68,5 +68,5 @@ def search_tree(node):
node = node.next
-conf = Kconfig(sys.argv[1])
-search_tree(conf.top_node)
+kconf = Kconfig(sys.argv[1])
+search_tree(kconf.top_node)
diff --git a/examples/print_sym_info.py b/examples/print_sym_info.py
index cc9f50a..120bc07 100644
--- a/examples/print_sym_info.py
+++ b/examples/print_sym_info.py
@@ -40,8 +40,8 @@ if len(sys.argv) < 3:
print('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=<name>')
sys.exit(1)
-conf = Kconfig(sys.argv[1])
-sym = conf.syms[sys.argv[2]]
+kconf = Kconfig(sys.argv[1])
+sym = kconf.syms[sys.argv[2]]
print(sym)
print("value = " + sym.str_value)
diff --git a/examples/print_tree.py b/examples/print_tree.py
index cda9ce2..1a53a3a 100644
--- a/examples/print_tree.py
+++ b/examples/print_tree.py
@@ -63,5 +63,5 @@ def print_items(node, indent):
node = node.next
-conf = Kconfig(sys.argv[1])
-print_items(conf.top_node, 0)
+kconf = Kconfig(sys.argv[1])
+print_items(kconf.top_node, 0)