diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-06-13 01:33:15 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-06-13 01:39:36 +0200 |
| commit | 68043b21a2fdf09d91996977d5408e92a23fe3e8 (patch) | |
| tree | 8f12ea087149d1d1c538467a7fb06cac7ddfa106 /kconfiglib.py | |
| parent | 35ede24133d87a79e993de2c2e427f03e3de9303 (diff) | |
Add MenuNode function that returns referenced items
MenuNode.referenced() returns all symbols (and choices, for choice
symbols) referenced in the properties (prompt, defaults, selects,
ranges, etc.) and property conditions of the menu node.
Handy e.g. when generating cross-references.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 56f9efa..6abb4e6 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4150,6 +4150,45 @@ class MenuNode(object): "ranges" ) + def referenced(self): + """ + Returns a set() of all symbols and choices referenced in the properties + and property conditions of this menu node. + + Also includes dependencies inherited from surrounding menus and if's. + Choices appear in the dependencies of choice symbols. + """ + res = set() + + if self.prompt: + res |= expr_items(self.prompt[1]) + + if self.item == MENU: + res |= expr_items(self.visibility) + + for value, cond in self.defaults: + res |= expr_items(value) + res |= expr_items(cond) + + for value, cond in self.selects: + res.add(value) + res |= expr_items(cond) + + for value, cond in self.implies: + res.add(value) + res |= expr_items(cond) + + for low, high, cond in self.ranges: + res.add(low) + res.add(high) + res |= expr_items(cond) + + # Need this to catch dependencies from a lone 'depends on' when there + # are no properties to propagate it to + res |= expr_items(self.dep) + + return res + def __repr__(self): """ Returns a string with information about the menu node when it is |
