From 9f57bf933508901f07d22c75fca42e62145f5512 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 25 May 2019 17:04:09 +0200 Subject: Use the ' "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. --- kconfiglib.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'kconfiglib.py') 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 ' "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: -- cgit v1.2.3