From f66cd7155158943987570937be37b09d9ca58028 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 7 Feb 2018 02:30:16 +0100 Subject: Allow "n"/"m"/"y" as aliases for 0/1/2 in set_value() More experience working with the API convinced me that it's worth it. Gets rid of ugly conversions in the menuconfig.py and oldconfig.py examples, and streamlines some things internally as well. Include two other small fixes as well: - Make warnings generated by Choice.set_value() match those generated by Symbol.set_value(). - Get rid of the input stripping in menuconfig.py. It's not like the interface is usable as-is anyway, and it just complicates the example. --- examples/menuconfig.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'examples/menuconfig.py') diff --git a/examples/menuconfig.py b/examples/menuconfig.py index b55af6d..753ac40 100644 --- a/examples/menuconfig.py +++ b/examples/menuconfig.py @@ -258,19 +258,7 @@ def get_value_from_user(sc): .format(", ".join([TRI_TO_STR[val] for val in sc.assignable])) prompt += ": " - val_str = input(prompt).strip() - if sc.type in (BOOL, TRISTATE): - if val_str not in STR_TO_TRI: - print("'{}' is not a valid tristate value".format(val_str)) - return False - - # I was thinking of having set_value() accept "n", "m", "y" as well as - # a convenience for BOOL / TRISTATE symbols. Consistently using 0, 1, 2 - # makes the format clearer though. That's the best format in all ways - # except for readability (where it isn't horrible either). - val = STR_TO_TRI[val_str] - else: - val = val_str + val = input(prompt) # Automatically add a "0x" prefix for hex symbols, like the menuconfig # interface does. This isn't done when loading .config files, hence why -- cgit v1.2.3