summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2012-12-06 22:40:46 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2012-12-06 22:40:46 +0100
commit619f0473d0d0f2ed0890f2a99ec42846d1f0211d (patch)
tree78e49fda4248b6df412814e51a76d8bd0e5fe038
parent4b4f2da02cc2d1b76dfaf6cf01ac4eac665b8f6c (diff)
Clarify eval() and always use transform_m = True.
The old version was a bit confusing, and it's probably best to always handle expressions like for conditionals.
-rw-r--r--kconfiglib.py33
1 files changed, 15 insertions, 18 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 3e315d1..25a5a31 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -486,28 +486,25 @@ class Config():
order they appear in the Kconfig files."""
return self.comments
- def eval(self, s, transform_m = False):
+ def eval(self, s):
"""Returns the value of the expression 's' -- where 's' is represented
as a string -- in the context of the configuration. Raises
Kconfig_Syntax_Error if syntax errors are detected in 's'.
- For example, if FOO and BAR are tristate symbols at least
- one of which has the value "y", then
- config.eval("y && (FOO || BAR)") => "y"
-
- Note that this functions always yields a tristate value. To get the
- value of non-bool, non-tristate symbols, use calc_value().
-
- transform_m (default: False) --
- Within conditional expressions (those following e.g. 'if' and
- 'depends on') "m" is rewritten as "m" && MODULES internally by the C
- implementation and by kconfiglib, so that MODULES needs to be enabled
- for the expression to be true. Pass True here if you want that to
- happen; otherwise, pass False."""
- return self._eval_expr(self._parse_expr(self._tokenize(s, True),
- None,
- s,
- transform_m = transform_m))
+ For example, if FOO and BAR are tristate symbols at least one of which
+ has the value "y", then config.eval("y && (FOO || BAR)") => "y"
+
+ This functions always yields a tristate value. To get the value of
+ non-bool, non-tristate symbols, use calc_value().
+
+ The result of this function is consistent with how evaluation works for
+ conditional expressions in the configuration as well as in the C
+ implementation. "m" and m are rewritten as '"m" && MODULES' and 'm &&
+ MODULES', respectively, and a result of "m" will get promoted to "y" if
+ we're running without modules."""
+ return self._eval_expr(self._parse_expr(self._tokenize(s, True), # Feed
+ None, # Current symbol or choice
+ s)) # line
def get_config_header(self):
"""Returns the (uncommented) textual header of the .config file most