diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-06-22 05:29:59 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-06-22 06:02:47 +0200 |
| commit | eb6c21a9b33a2d6e2bed9882d4f930d0cab2f03b (patch) | |
| tree | 2e03f85c7d25ed51d4db11a36f8d88362079bd5a | |
| parent | f6eb4f435bc594aa58b8f8c066a9e2243c5c8330 (diff) | |
Turn MenuNode/Symbol/Choice.referenced() into a @property
Having it as a function is inconsistent, since all other read-only
fields use properties. Oversight.
Major version will be bumped to 7, though the function version wasn't in
for long.
| -rw-r--r-- | kconfiglib.py | 45 | ||||
| -rw-r--r-- | testsuite.py | 4 |
2 files changed, 30 insertions, 19 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 2741e10..dd99f14 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2913,6 +2913,13 @@ class Symbol(object): parent dependencies are automatically propagated to the conditions of properties, so normally it's redundant to check the direct dependencies. + referenced: + A set() with all symbols and choices referenced in the properties and + property conditions of the symbol. + + Also includes dependencies inherited from surrounding menus and if's. + Choices appear in the dependencies of choice symbols. + env_var: If the Symbol has an 'option env="FOO"' option, this contains the name ("FOO") of the environment variable. None for symbols without no @@ -3334,17 +3341,14 @@ class Symbol(object): self.user_value = None self._rec_invalidate_if_has_prompt() + @property def referenced(self): """ - Returns a set() of all symbols and choices referenced in the properties - and property conditions of the symbol. - - Also includes dependencies inherited from surrounding menus and if's. - Choices appear in the dependencies of choice symbols. + See the class documentation. """ res = set() for node in self.nodes: - res |= node.referenced() + res |= node.referenced return res @@ -3776,6 +3780,12 @@ class Choice(object): direct_dep: See Symbol.direct_dep. + referenced: + A set() with all symbols referenced in the properties and property + conditions of the choice. + + Also includes dependencies inherited from surrounding menus and if's. + is_optional: True if the choice has the 'optional' flag set on it and can be in n mode. @@ -3925,17 +3935,14 @@ class Choice(object): self.user_value = self.user_selection = None self._rec_invalidate() + @property def referenced(self): """ - Returns a set() of all symbols and choices referenced in the properties - and property conditions of the choice. - - Also includes dependencies inherited from surrounding menus and if's. - Choices appear in the dependencies of choice symbols. + See the class documentation. """ res = set() for node in self.nodes: - res |= node.referenced() + res |= node.referenced return res @@ -4175,6 +4182,13 @@ class MenuNode(object): 'visible if' dependencies are recursively propagated to the prompts of symbols and choices within the menu. + referenced: + A set() with all symbols and choices referenced in the properties and + property conditions of the menu node. + + Also includes dependencies inherited from surrounding menus and if's. + Choices appear in the dependencies of choice symbols. + is_menuconfig: Set to True if the children of the menu node should be displayed in a separate menu. This is the case for the following items: @@ -4226,13 +4240,10 @@ class MenuNode(object): self.implies = [] self.ranges = [] + @property def referenced(self): """ - Returns a set() of all symbols and choices referenced in the properties - and property conditions of the menu node. - - Also includes dependencies inherited from surrounding menus and if's. - Choices appear in the dependencies of choice symbols. + See the class documentation. """ # self.dep is included to catch dependencies from a lone 'depends on' # when there are no properties to propagate it to diff --git a/testsuite.py b/testsuite.py index 8f93c81..64b5bd9 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1009,12 +1009,12 @@ g ) - print("Testing MenuNode/Symbol/Choice.referenced()") + print("Testing MenuNode/Symbol/Choice.referenced") c = Kconfig("Kconfiglib/tests/Kreferenced", warn=False) def verify_deps(item, *dep_names): - verify_equal(tuple(sorted(item.name for item in item.referenced())), + verify_equal(tuple(sorted(item.name for item in item.referenced)), dep_names) verify_deps(c.top_node, "y") |
