Skip to content

Commit

Permalink
Turn MenuNode/Symbol/Choice.referenced() into a @Property
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ulfalizer committed Jun 22, 2018
1 parent f6eb4f4 commit eb6c21a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
45 changes: 28 additions & 17 deletions kconfiglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3334,17 +3341,14 @@ def unset_value(self):
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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -3925,17 +3935,14 @@ def unset_value(self):
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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -4226,13 +4240,10 @@ def __init__(self):
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
Expand Down
4 changes: 2 additions & 2 deletions testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,12 +1009,12 @@ def verify_expr_items(expr, *sym_names):
)


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")
Expand Down

0 comments on commit eb6c21a

Please sign in to comment.