diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-10-30 00:50:09 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-10-30 01:14:20 +0100 |
| commit | 989e9f77cfe8caabc7ac241572e9b52682901135 (patch) | |
| tree | 9c70f1d1c08efc19803b4fe741ab1dd2c69b42cd /examples/print_sym_info.py | |
| parent | 7bbaf7e7cf131d83931bfda2d2e8e5d6ef1b235f (diff) | |
Consistently use 0/1/2 for tristate values
Easier to work with, allowing e.g. direct comparisons with < and >. Make
set_value() take 0, 1, 2 for bool and tristate symbols, and fix other
APIs to match.
Also:
- Add introductions to various concepts in the module docstring.
Document some more attributes. Still TODOs.
- Rename the Config class to Kconfig.
- Escape " and \ in the name of constant symbols when printing them.
Also make the (un)escaping 100% consistent with how the C tools do
it (\ before non-magic character should be unescaped too).
- Clean up the escaping/unescaping code and provide two public
escape()/unescape() functions.
- Export the original MODULES-independent type in orig_type. It's
needed for printing symbols in the reparsable __str__() Kconfig
format with just public APIs.
- Lots of other minor reorganizing and nits all over.
Diffstat (limited to 'examples/print_sym_info.py')
| -rw-r--r-- | examples/print_sym_info.py | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/examples/print_sym_info.py b/examples/print_sym_info.py index 2c1b0f0..cc9f50a 100644 --- a/examples/print_sym_info.py +++ b/examples/print_sym_info.py @@ -5,48 +5,49 @@ # $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/print_sym_info.py SCRIPT_ARG=<name> # # Example output for SCRIPT_ARG=modules: -# -# config MODULES -# bool -# prompt "Enable loadable module support" -# option modules -# help -# Kernel modules are small pieces of compiled code which can -# be inserted in the running kernel, rather than being -# permanently built into the kernel. You use the "modprobe" -# tool to add (and sometimes remove) them. If you say Y here, -# many parts of the kernel can be built as modules (by -# answering M instead of Y where indicated): this is most -# 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 -# defined at init/Kconfig:1678 +# menuconfig MODULES +# bool +# prompt "Enable loadable module support" +# option modules +# help +# Kernel modules are small pieces of compiled code which can +# be inserted in the running kernel, rather than being +# permanently built into the kernel. You use the "modprobe" +# tool to add (and sometimes remove) them. If you say Y here, +# many parts of the kernel can be built as modules (by +# answering M instead of Y where indicated): this is most +# 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 +# defined at init/Kconfig:1674 -import kconfiglib +from kconfiglib import Kconfig, TRI_TO_STR import sys if len(sys.argv) < 3: print('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=<name>') sys.exit(1) -conf = kconfiglib.Config(sys.argv[1]) +conf = Kconfig(sys.argv[1]) sym = conf.syms[sys.argv[2]] print(sym) -print("value = " + sym.value) -print("visibility = " + sym.visibility) -print("currently assignable values: " + ", ".join(sym.assignable)) +print("value = " + sym.str_value) +print("visibility = " + TRI_TO_STR[sym.visibility]) +print("currently assignable values: " + + ", ".join([TRI_TO_STR[v] for v in sym.assignable])) for node in sym.nodes: print("defined at {}:{}".format(node.filename, node.linenr)) |
