mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
filename
This commit is contained in:
parent
64be7e4a6f
commit
20c03fcab2
@ -12,6 +12,7 @@ class BotConfig():
|
||||
|
||||
def __init__(self):
|
||||
self.dict = {}
|
||||
self.filename = None
|
||||
self.config = self.load_config()
|
||||
|
||||
def load_config(self):
|
||||
@ -25,17 +26,25 @@ class BotConfig():
|
||||
opts = parser.parse_args(argv)
|
||||
config_module = get_configuration(opts)
|
||||
|
||||
# load dict
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_module.filename)
|
||||
for each_section in config.sections():
|
||||
if each_section not in self.dict.keys():
|
||||
self.dict[each_section] = 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
|
||||
# Filename
|
||||
self.filename = config_module.filename
|
||||
|
||||
# load as dict
|
||||
self.dict = self.config_file_to_dict()
|
||||
|
||||
return config_module
|
||||
|
||||
def config_file_to_dict(self):
|
||||
configdict = dict()
|
||||
config = configparser.ConfigParser()
|
||||
config.read(self.filename)
|
||||
for each_section in config.sections():
|
||||
if each_section not in configdict.keys():
|
||||
configdict[each_section] = dict()
|
||||
for (each_key, each_val) in config.items(each_section):
|
||||
if each_key not in configdict[each_section].keys():
|
||||
configdict[each_section][each_key] = each_val
|
||||
return configdict
|
||||
|
||||
|
||||
botconfig = BotConfig()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user