From 11f04ba1bae774d32fd43bed4a0772c58d8df199 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 17 Jun 2024 13:49:05 -0400 Subject: configfile: Allow getchoice() to take a list If a list is passed to getchoice(), seamlessly convert it to a dict. Signed-off-by: Kevin O'Connor --- klippy/configfile.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'klippy/configfile.py') diff --git a/klippy/configfile.py b/klippy/configfile.py index 91b555cd..a8a4a4ff 100644 --- a/klippy/configfile.py +++ b/klippy/configfile.py @@ -69,6 +69,8 @@ class ConfigWrapper: return self._get_wrapper(self.fileconfig.getboolean, option, default, note_valid=note_valid) def getchoice(self, option, choices, default=sentinel, note_valid=True): + if type(choices) == type([]): + choices = {i: i for i in choices} if choices and type(list(choices.keys())[0]) == int: c = self.getint(option, default, note_valid=note_valid) else: -- cgit v1.2.3-70-g09d2