aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/configfile.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-06-17 13:49:05 -0400
committerKevin O'Connor <kevin@koconnor.net>2024-06-17 13:49:05 -0400
commit11f04ba1bae774d32fd43bed4a0772c58d8df199 (patch)
tree7eec3a3fca5012f33602a9f0e434cd85ad1cb96b /klippy/configfile.py
parent863a463cb2d07fce2ae09e2b0f925bdf201051dc (diff)
downloadkutter-11f04ba1bae774d32fd43bed4a0772c58d8df199.tar.gz
kutter-11f04ba1bae774d32fd43bed4a0772c58d8df199.tar.xz
kutter-11f04ba1bae774d32fd43bed4a0772c58d8df199.zip
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 <kevin@koconnor.net>
Diffstat (limited to 'klippy/configfile.py')
-rw-r--r--klippy/configfile.py2
1 files changed, 2 insertions, 0 deletions
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: