mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
simpler
This commit is contained in:
parent
8c322c2183
commit
105718b056
@ -12,11 +12,6 @@ class BotConfig():
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.dict = {}
|
self.dict = {}
|
||||||
self.config = None
|
|
||||||
self.filename = None
|
|
||||||
self.load_config()
|
|
||||||
|
|
||||||
def load_config(self):
|
|
||||||
|
|
||||||
# Load config
|
# Load config
|
||||||
parser = build_parser()
|
parser = build_parser()
|
||||||
@ -31,19 +26,14 @@ class BotConfig():
|
|||||||
self.filename = self.config.filename
|
self.filename = self.config.filename
|
||||||
|
|
||||||
# load as dict
|
# load as dict
|
||||||
self.dict = self.config_file_to_dict()
|
|
||||||
|
|
||||||
def config_file_to_dict(self):
|
|
||||||
configdict = dict()
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(self.filename)
|
config.read(self.filename)
|
||||||
for each_section in config.sections():
|
for each_section in config.sections():
|
||||||
if each_section not in configdict.keys():
|
if each_section not in self.dict.keys():
|
||||||
configdict[each_section] = dict()
|
self.dict[each_section] = dict()
|
||||||
for (each_key, each_val) in config.items(each_section):
|
for (each_key, each_val) in config.items(each_section):
|
||||||
if each_key not in configdict[each_section].keys():
|
if each_key not in self.dict[each_section].keys():
|
||||||
configdict[each_section][each_key] = each_val
|
self.dict[each_section][each_key] = each_val
|
||||||
return configdict
|
|
||||||
|
|
||||||
|
|
||||||
botconfig = BotConfig()
|
botconfig = BotConfig()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user