summaryrefslogtreecommitdiff
path: root/examples/help_grep.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/help_grep.py')
-rw-r--r--examples/help_grep.py37
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))