From 66557edc120faac569004ba2bc426c5ac6a1100b Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 6 Mar 2019 02:10:20 +0100 Subject: Use a consistent style in examples Also remove some unused imports. --- examples/menuconfig_example.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'examples/menuconfig_example.py') 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 ("[*]", "", "(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 ") @@ -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 -- cgit v1.2.3