From 49f14caf42e44b362f815273a5b5e4699f5678df Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 30 Jan 2020 11:50:40 +0000 Subject: support different Config names --- bitbotd | 2 +- src/Config.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bitbotd b/bitbotd index 77810c7e..e3962dde 100755 --- a/bitbotd +++ b/bitbotd @@ -46,7 +46,7 @@ if args.version: print("BitBot %s" % IRCBot.VERSION) sys.exit(0) -config = Config.Config(args.config) +config = Config.Config("bot", args.config) config.load() DATA_DIR = os.path.expanduser(config.get("data-directory", "~/.bitbot")) diff --git a/src/Config.py b/src/Config.py index 579b2dec..06926dbb 100644 --- a/src/Config.py +++ b/src/Config.py @@ -1,8 +1,8 @@ import collections, configparser, os, typing class Config(object): - - def __init__(self, location: str): + def __init__(self, name: str, location: str): + self._name = name self.location = location self._config: typing.Dict[str, str] = collections.OrderedDict() @@ -15,14 +15,14 @@ class Config(object): parser = self._parser() parser.read_string(config_file.read()) self._config.clear() - for k, v in parser["bot"].items(): + for k, v in parser[self._name].items(): if v: self._config[k] = v def save(self): with open(self.location, "w") as config_file: parser = self._parser() - parser["bot"] = self._config.copy() + parser[self._name] = self._config.copy() parser.write(config_file) def __getitem__(self, key: str) -> typing.Any: -- cgit v1.3.1-10-gc9f91