summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/allnoconfig_walk.py2
-rw-r--r--examples/help_grep.py6
-rw-r--r--examples/menuconfig_example.py19
-rw-r--r--examples/merge_config.py2
-rw-r--r--examples/print_config_tree.py11
-rw-r--r--examples/print_sym_info.py6
-rw-r--r--examples/print_tree.py2
7 files changed, 32 insertions, 16 deletions
diff --git a/examples/allnoconfig_walk.py b/examples/allnoconfig_walk.py
index 5abc80c..24b2828 100644
--- a/examples/allnoconfig_walk.py
+++ b/examples/allnoconfig_walk.py
@@ -13,6 +13,7 @@ import sys
from kconfiglib import Kconfig, Symbol
+
def do_allnoconfig(node):
global changed
@@ -40,6 +41,7 @@ def do_allnoconfig(node):
node = node.next
+
# Parse the Kconfig files
kconf = Kconfig(sys.argv[1])
diff --git a/examples/help_grep.py b/examples/help_grep.py
index 39cbe39..157d8f2 100644
--- a/examples/help_grep.py
+++ b/examples/help_grep.py
@@ -10,7 +10,7 @@
#
# menu "General setup"
# location: init/Kconfig:39
-#
+#
# config SYSVIPC
# bool
# prompt "System V IPC"
@@ -18,9 +18,9 @@
# ...
# exchange information. It is generally considered to be a good thing,
# ...
-#
+#
# location: init/Kconfig:233
-#
+#
# config BSD_PROCESS_ACCT
# bool
# prompt "BSD Process Accounting" if MULTIUSER
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
diff --git a/examples/merge_config.py b/examples/merge_config.py
index 2bf318e..ec022d5 100644
--- a/examples/merge_config.py
+++ b/examples/merge_config.py
@@ -65,7 +65,7 @@
import sys
-from kconfiglib import Kconfig, Symbol, BOOL, TRISTATE, TRI_TO_STR
+from kconfiglib import Kconfig, BOOL, TRISTATE, TRI_TO_STR
if len(sys.argv) < 4:
diff --git a/examples/print_config_tree.py b/examples/print_config_tree.py
index 8356dcb..90e529f 100644
--- a/examples/print_config_tree.py
+++ b/examples/print_config_tree.py
@@ -54,18 +54,19 @@
import sys
from kconfiglib import Kconfig, \
- Symbol, Choice, MENU, COMMENT, \
+ Symbol, MENU, COMMENT, \
BOOL, TRISTATE, STRING, INT, HEX, UNKNOWN, \
- expr_value, \
- TRI_TO_STR
+ expr_value
# Add help description to output
WITH_HELP_DESC = False
+
def indent_print(s, indent):
print(" "*indent + s)
+
def value_str(sc):
"""
Returns the value part ("[*]", "<M>", "(foo)" etc.) of a menu entry.
@@ -99,6 +100,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
@@ -151,6 +153,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
@@ -166,6 +169,7 @@ def print_menuconfig_nodes(node, indent):
node = node.next
+
def print_menuconfig(kconf):
"""
Prints all menu entries for the configuration.
@@ -177,6 +181,7 @@ def print_menuconfig(kconf):
print_menuconfig_nodes(kconf.top_node.list, 0)
print("")
+
if __name__ == "__main__":
# Load Kconfig configuration files
diff --git a/examples/print_sym_info.py b/examples/print_sym_info.py
index d36e7b0..ea6fc72 100644
--- a/examples/print_sym_info.py
+++ b/examples/print_sym_info.py
@@ -20,14 +20,14 @@
# useful for infrequently used options which are not required
# for booting. For more information, see the man pages for
# modprobe, lsmod, modinfo, insmod and rmmod.
-#
+#
# If you say Y here, you will need to run "make
# modules_install" to put the modules under /lib/modules/
# where modprobe can find them (you may need to be root to do
# this).
-#
+#
# If unsure, say Y.
-#
+#
# value = n
# visibility = y
# currently assignable values: n, y
diff --git a/examples/print_tree.py b/examples/print_tree.py
index cd23f68..66b3a81 100644
--- a/examples/print_tree.py
+++ b/examples/print_tree.py
@@ -49,6 +49,7 @@ from kconfiglib import Kconfig, Symbol, Choice, MENU, COMMENT
def indent_print(s, indent):
print(" "*indent + s)
+
def print_items(node, indent):
while node:
if isinstance(node.item, Symbol):
@@ -69,5 +70,6 @@ def print_items(node, indent):
node = node.next
+
kconf = Kconfig(sys.argv[1])
print_items(kconf.top_node, 0)