summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-05-25 17:04:09 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2019-05-25 18:04:15 +0200
commit9f57bf933508901f07d22c75fca42e62145f5512 (patch)
tree5b80c60bd542d7167ec8c6f04d8b3ea50985f455 /kconfiglib.py
parente1da7aa4d041d25e4fd5fd1f603f4c28d32b1392 (diff)
Use the '<type> "prompt"' shorthand in __str__()
Pro: Looks cleaner and matches how definitions are usually written. Con: Makes it harder to discover that 'bool "foo"' is just shorthand for 'bool' + 'prompt "foo"' (though it's documented). The pros probably win.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 55d08f6..8ff95bc 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -5429,13 +5429,21 @@ class MenuNode(object):
else:
lines = ["choice " + sc.name if sc.name else "choice"]
- if sc.orig_type: # != UNKNOWN
+ if sc.orig_type and not self.prompt: # sc.orig_type != UNKNOWN
+ # If there's a prompt, we'll use the '<type> "prompt"' shorthand
+ # instead
indent_add(TYPE_TO_STR[sc.orig_type])
if self.prompt:
- indent_add_cond(
- 'prompt "{}"'.format(escape(self.prompt[0])),
- self.orig_prompt[1])
+ if sc.orig_type:
+ prompt = TYPE_TO_STR[sc.orig_type]
+ else:
+ # Symbol defined without a type (which generates a warning)
+ prompt = "prompt"
+
+ prompt += ' "{}"'.format(escape(self.prompt[0]))
+
+ indent_add_cond(prompt, self.orig_prompt[1])
if sc.__class__ is Symbol:
if sc.is_allnoconfig_y: