diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-09-15 02:19:34 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-09-15 03:07:11 +0200 |
| commit | 35a60b786c646c846d9bad6a5f15711acc9a62c6 (patch) | |
| tree | e0848683c8b4f39d1f0959fb6b9a95c14ca2a3f0 /examples/help_grep.py | |
| parent | f861c271dcbb06e0101c01add3d07006c2d3a09c (diff) | |
Update some examples to use node_iter()
Simplifies the code. Should promote new APIs.
Also fix list_undefined.py for recent kernels. More environment
variables are referenced now.
Diffstat (limited to 'examples/help_grep.py')
| -rw-r--r-- | examples/help_grep.py | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/examples/help_grep.py b/examples/help_grep.py index 20a4911..f05c66f 100644 --- a/examples/help_grep.py +++ b/examples/help_grep.py @@ -42,30 +42,21 @@ if len(sys.argv) < 3: search = re.compile(sys.argv[2], re.IGNORECASE).search -def search_tree(node): - while node: - match = False +for node in Kconfig(sys.argv[1]).node_iter(): + match = False - if isinstance(node.item, (Symbol, Choice)) and \ - node.help is not None and search(node.help): - print(node.item) - match = True + if isinstance(node.item, (Symbol, Choice)) and \ + node.help is not None and search(node.help): + print(node.item) + match = True - elif node.item == MENU and search(node.prompt[0]): - print('menu "{}"'.format(node.prompt[0])) - match = True + elif node.item == MENU and search(node.prompt[0]): + print('menu "{}"'.format(node.prompt[0])) + match = True - elif node.item == COMMENT and search(node.prompt[0]): - print('comment "{}"'.format(node.prompt[0])) - match = True + elif node.item == COMMENT and search(node.prompt[0]): + print('comment "{}"'.format(node.prompt[0])) + match = True - if match: - print("location: {}:{}\n".format(node.filename, node.linenr)) - - if node.list: - search_tree(node.list) - - node = node.next - -kconf = Kconfig(sys.argv[1]) -search_tree(kconf.top_node) + if match: + print("location: {}:{}\n".format(node.filename, node.linenr)) |
