summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-03-20 15:13:46 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2018-03-20 15:16:29 +0100
commiteb9619bf1c40a0d3bb791ae984e992b66d6d25b2 (patch)
tree2ad25ffe8ed4d2a4356b8bdef09609bd7bcb63c0
parentc7ac6f86913a65c27d939964ae826c4a897883b0 (diff)
Get rid of local 'prompt' variable
There's no need to handle prompts like defaults, selects, etc. in _parse_properties(), because prompts belong to menu nodes, which means only local dependencies will be propagated anyway. Makes the code a bit less twisty.
-rw-r--r--kconfiglib.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 53f89d6..b0e146d 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1827,7 +1827,7 @@ class Kconfig(object):
node = MenuNode()
node.kconfig = self
node.item = sym
- node.help = node.list = None
+ node.prompt = node.help = node.list = None
node.parent = parent
node.filename = self._filename
node.linenr = self._linenr
@@ -1964,7 +1964,7 @@ class Kconfig(object):
node = MenuNode()
node.kconfig = self
node.item = choice
- node.help = None
+ node.prompt = node.help = None
node.parent = parent
node.filename = self._filename
node.linenr = self._linenr
@@ -2021,7 +2021,6 @@ class Kconfig(object):
# New properties encountered at this location. A local 'depends on'
# only applies to these, in case a symbol is defined in multiple
# locations.
- prompt = None
defaults = []
selects = []
implies = []
@@ -2048,11 +2047,11 @@ class Kconfig(object):
node.item.orig_type = new_type
if self._peek_token() is not None:
- if prompt:
+ if node.prompt:
self._warn("{} defined with multiple prompts in single location"
.format(_name_and_loc_str(node.item)))
- prompt = (self._expect_str(), self._parse_cond())
+ node.prompt = (self._expect_str(), self._parse_cond())
elif t0 == _T_DEPENDS:
if not self._check_token(_T_ON):
@@ -2149,11 +2148,11 @@ class Kconfig(object):
# 'prompt' properties override each other within a single
# definition of a symbol, but additional prompts can be added
# by defining the symbol multiple times
- if prompt:
+ if node.prompt:
self._warn("{} defined with multiple prompts in single location"
.format(_name_and_loc_str(node.item)))
- prompt = (self._expect_str(), self._parse_cond())
+ node.prompt = (self._expect_str(), self._parse_cond())
elif t0 == _T_RANGE:
ranges.append((self._expect_sym(),
@@ -2258,13 +2257,11 @@ class Kconfig(object):
self._make_or(node.item.direct_dep, node.dep)
# Set the prompt, with dependencies propagated
- if prompt:
- node.prompt = (prompt[0],
- self._make_and(self._make_and(prompt[1],
- node.dep),
- visible_if_deps))
- else:
- node.prompt = None
+ if node.prompt:
+ node.prompt = \
+ (node.prompt[0],
+ self._make_and(node.prompt[1],
+ self._make_and(node.dep, visible_if_deps)))
# Add the new defaults, with dependencies propagated
for val_expr, cond in defaults: