summaryrefslogtreecommitdiff
path: root/examples/menuconfig_example.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-03-06 02:10:20 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2019-03-06 02:15:29 +0100
commit66557edc120faac569004ba2bc426c5ac6a1100b (patch)
tree58b44e89288715d2907671e18a341cf4df0cd40e /examples/menuconfig_example.py
parent553cca8e7417ad863b923758e6d402296d05de9c (diff)
Use a consistent style in examples
Also remove some unused imports.
Diffstat (limited to 'examples/menuconfig_example.py')
-rw-r--r--examples/menuconfig_example.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/examples/menuconfig_example.py b/examples/menuconfig_example.py
index 6a5e570..402fabd 100644
--- a/examples/menuconfig_example.py
+++ b/examples/menuconfig_example.py
@@ -91,9 +91,9 @@
#
# Enter a symbol/choice name, "load_config", or "write_config" (or press CTRL+D to exit): MODULES
# Value for MODULES (available: n, y): n
-#
+#
# ======== Example Kconfig configuration ========
-#
+#
# [ ] Enable loadable module support (MODULES)
# Bool and tristate symbols
# [ ] Bool symbol (BOOL)
@@ -114,14 +114,14 @@
# --> Tristate choice sym 1 (TRI_CHOICE_SYM_1)
# Tristate choice sym 2 (TRI_CHOICE_SYM_2)
# [ ] Optional bool choice (OPT_BOOL_CHOICE)
-#
+#
# Enter a symbol/choice name, "load_config", or "write_config" (or press CTRL+D to exit): ^D
import readline
import sys
from kconfiglib import Kconfig, \
- Symbol, Choice, MENU, COMMENT, \
+ Symbol, MENU, COMMENT, \
BOOL, TRISTATE, STRING, INT, HEX, UNKNOWN, \
expr_value, \
TRI_TO_STR
@@ -131,9 +131,11 @@ from kconfiglib import Kconfig, \
if sys.version_info[0] < 3:
input = raw_input
+
def indent_print(s, indent):
print(" "*indent + s)
+
def value_str(sc):
"""
Returns the value part ("[*]", "<M>", "(foo)" etc.) of a menu entry.
@@ -167,6 +169,7 @@ def value_str(sc):
return "{" + tri_val_str + "}" # Gets a bit confusing with .format()
return "<{}>".format(tri_val_str)
+
def node_str(node):
"""
Returns the complete menu entry text for a menu node, or "" for invisible
@@ -217,6 +220,7 @@ def node_str(node):
return res
+
def print_menuconfig_nodes(node, indent):
"""
Prints a tree with all the menu entries rooted at 'node'. Child menu
@@ -232,6 +236,7 @@ def print_menuconfig_nodes(node, indent):
node = node.next
+
def print_menuconfig(kconf):
"""
Prints all menu entries for the configuration.
@@ -243,6 +248,7 @@ def print_menuconfig(kconf):
print_menuconfig_nodes(kconf.top_node.list, 0)
print("")
+
def get_value_from_user(sc):
"""
Prompts the user for a value for the symbol or choice 'sc'. For
@@ -273,6 +279,7 @@ def get_value_from_user(sc):
# warning.
return sc.set_value(val)
+
if __name__ == "__main__":
if len(sys.argv) != 2:
sys.exit("usage: menuconfig.py <Kconfig file>")
@@ -285,8 +292,8 @@ if __name__ == "__main__":
while True:
try:
- cmd = input('Enter a symbol/choice name, "load_config", or "write_config" (or press CTRL+D to exit): ') \
- .strip()
+ cmd = input('Enter a symbol/choice name, "load_config", or '
+ '"write_config" (or press CTRL+D to exit): ').strip()
except EOFError:
print("")
break