diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index b5cdc3d..d163c6f 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -132,7 +132,7 @@ class BotCommands(): logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e)) # Extra directories - for directory in botconfig.config.core.extra: + for directory in botconfig.extra: filepathlisting.append(directory) return filepathlisting diff --git a/sopel_modules/SpiceBot/Config.py b/sopel_modules/SpiceBot/Config.py index 954083e..450ba59 100644 --- a/sopel_modules/SpiceBot/Config.py +++ b/sopel_modules/SpiceBot/Config.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi from sopel.cli.run import build_parser, get_configuration import sys -import configparser class BotConfig(): @@ -22,29 +21,14 @@ class BotConfig(): opts = parser.parse_args(argv) self.config = get_configuration(opts) - # Filename - self.filename = self.config.filename - - # load as dict - config = configparser.ConfigParser() - config.read(self.filename) - for each_section in config.sections(): - 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.lower() not in self.dict[each_section.lower()].keys(): - self.dict[each_section.lower()][each_key.lower()] = each_val - def define_section(self, name, cls_, validate=True): return self.config.define_section(name, cls_, validate) def __getattr__(self, name): ''' will only get called for undefined attributes ''' """We will try to find a core value, or return None""" - if hasattr(self.config.core, name): + if hasattr(self.config, name): return eval("self.config.core." + name) - elif name.lower() in self.dict["core"].keys(): - return self.dict["core"][str(name).lower()] else: return None diff --git a/sopel_modules/SpiceBot/Logs.py b/sopel_modules/SpiceBot/Logs.py index 9e201d5..b1a0853 100644 --- a/sopel_modules/SpiceBot/Logs.py +++ b/sopel_modules/SpiceBot/Logs.py @@ -30,7 +30,7 @@ class BotLogs(): logtitle = "[" + logtype + "]" logmessage = logtitle + " " + logentry - if botconfig.config.core.logging_channel: + if botconfig.logging_channel: self.dict["queue"].append(logmessage) if stdio: @@ -57,7 +57,7 @@ class BotLogs(): for logtype in self.dict["list"].keys(): stdio_ignore.append("[" + logtype + "]") - logfile = os.path.os.path.join(botconfig.config.core.logdir, 'stdio.log') + logfile = os.path.os.path.join(botconfig.logdir, 'stdio.log') try: log_file_lines = [] @@ -105,12 +105,12 @@ class BotLogs(): def get_running_pid(self): try: - filename = "/run/sopel/sopel-" + str(botconfig.config.core.nick) + ".pid" + filename = "/run/sopel/sopel-" + str(botconfig.nick) + ".pid" with open(filename, 'r') as pid_file: pidnum = int(pid_file.read()) except Exception as e: pidnum = e - pidnum = str(os.popen("systemctl show " + str(botconfig.config.core.nick) + " --property=MainPID").read()).split("=")[-1] + pidnum = str(os.popen("systemctl show " + str(botconfig.nick) + " --property=MainPID").read()).split("=")[-1] return pidnum diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index e290cf2..8519ef7 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -42,7 +42,7 @@ github_dict = { def bot_privs(privtype): if privtype == 'owners': privtype = 'owner' - botpriveval = eval("botconfig.config.config.core." + privtype) + botpriveval = eval("botconfig." + privtype) if not isinstance(botpriveval, list): botpriveval = [botpriveval] return botpriveval diff --git a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py index b7ea84d..5a2e8ff 100644 --- a/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py +++ b/sopel_modules/SpiceBot_Database_Command/DatabaseCommand.py @@ -10,4 +10,4 @@ import sopel_modules.SpiceBot as SpiceBot @sopel.module.nickname_commands('database') def bot_command_gender(bot, trigger): - bot.osd("Database is " + SpiceBot.config.dict["core"]["db_type"]) + bot.osd("Database is " + SpiceBot.config.db_type) diff --git a/sopel_modules/SpiceBot_GifSearch/gifsearch.py b/sopel_modules/SpiceBot_GifSearch/gifsearch.py index b7eda44..8681674 100644 --- a/sopel_modules/SpiceBot_GifSearch/gifsearch.py +++ b/sopel_modules/SpiceBot_GifSearch/gifsearch.py @@ -55,7 +55,7 @@ def setup(bot): dir_to_scan.append(api_dir) bot.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) - SpiceBot.config.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) + SpiceBot.config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) if bot.config.SopelGifSearch.extra: dir_to_scan.append(bot.config.SopelGifSearch.extra) @@ -63,7 +63,7 @@ def setup(bot): for gif_api in valid_gif_api_dict.keys(): bot.config.define_section(gif_api, GifAPISection, validate=False) - SpiceBot.config.config.define_section(gif_api, GifAPISection, validate=False) + SpiceBot.config.define_section(gif_api, GifAPISection, validate=False) apikey = eval("bot.config." + gif_api + ".apikey") if apikey: valid_gif_api_dict[gif_api]["apikey"] = apikey diff --git a/sopel_modules/SpiceBot_Kick/__init__.py b/sopel_modules/SpiceBot_Kick/__init__.py index b628b5c..54fe4f8 100644 --- a/sopel_modules/SpiceBot_Kick/__init__.py +++ b/sopel_modules/SpiceBot_Kick/__init__.py @@ -42,7 +42,7 @@ def setup(bot): # verify config settings for server SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings") bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) - SpiceBot.config.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) + SpiceBot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) @module.event('005') diff --git a/sopel_modules/SpiceBot_Logs/Queue.py b/sopel_modules/SpiceBot_Logs/Queue.py index 274bdeb..8daedbb 100644 --- a/sopel_modules/SpiceBot_Logs/Queue.py +++ b/sopel_modules/SpiceBot_Logs/Queue.py @@ -18,7 +18,7 @@ def setup(bot): @sopel.module.rule('.*') def join_log_channel(bot, trigger): - if SpiceBot.config.config.core.logging_channel: + if SpiceBot.config.logging_channel: channel = bot.config.core.logging_channel if channel not in bot.channels.keys(): bot.write(('JOIN', bot.nick, channel)) diff --git a/sopel_modules/SpiceBot_Update/Update.py b/sopel_modules/SpiceBot_Update/Update.py index 43450d3..cd8424d 100644 --- a/sopel_modules/SpiceBot_Update/Update.py +++ b/sopel_modules/SpiceBot_Update/Update.py @@ -25,7 +25,7 @@ def configure(config): def setup(bot): SpiceBot.logs.log('SpiceBot_Update', "Initial Setup processing") bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) - SpiceBot.config.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) + SpiceBot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) @SpiceBot.prerun.prerun('nickname') diff --git a/sopel_modules/SpiceBot_osd/__init__.py b/sopel_modules/SpiceBot_osd/__init__.py index 96b857a..b8529b9 100644 --- a/sopel_modules/SpiceBot_osd/__init__.py +++ b/sopel_modules/SpiceBot_osd/__init__.py @@ -50,7 +50,7 @@ def setup(bot): # verify config settings for server SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings") bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) - SpiceBot.config.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) + SpiceBot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) @module.event('005')