From a8bf3c93007503ec411d0d23fef021f386127fa5 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 28 Sep 2018 16:51:36 +0100 Subject: Remove cyclical references to IRCBot --- src/Config.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/Config.py') diff --git a/src/Config.py b/src/Config.py index bf597b78..b5d27ea9 100644 --- a/src/Config.py +++ b/src/Config.py @@ -3,10 +3,20 @@ import configparser, os class Config(object): def __init__(self, location): self.location = location + self._config = {} + self.load() - def load_config(self): + def load(self): if os.path.isfile(self.location): with open(self.location) as config_file: parser = configparser.ConfigParser() parser.read_string(config_file.read()) - return dict(parser["bot"].items()) + self._config = dict(parser["bot"].items()) + + def __getitem__(self, key): + return self._config[key] + def get(self, key, default=None): + return self._config.get(key, default) + def __contains__(self, key): + return key in self.config + -- cgit v1.3.1-10-gc9f91