From 87e184131adb7a088f71a1366f0cd3425537e715 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 29 May 2019 10:59:15 -0400 Subject: [PATCH] test getattr --- sopel_modules/SpiceBot/Config.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 8cf5acf..0c66dc1 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -29,11 +29,19 @@ class BotConfig(): config = configparser.ConfigParser() config.read(self.filename) for each_section in config.sections(): - if each_section not in self.dict.keys(): - self.dict[each_section] = dict() + if each_section.lower() not in self.dict.keys(): + self.dict[each_section.lower()] = dict() for (each_key, each_val) in config.items(each_section): - if each_key not in self.dict[each_section].keys(): - self.dict[each_section][each_key] = each_val + if each_key.lower() not in self.dict[each_section.lower()].keys(): + self.dict[each_section.lower()][each_key.lower()] = each_val + + def __getattr__(self, name): + ''' will only get called for undefined attributes ''' + """We will try to find a core value, or return None""" + if name.lower() in self.dict["core"].keys(): + return self.dict["core"][str(name).lower()] + else: + return None botconfig = BotConfig()