diff options
author | tv <tv@nomic.retiolum> | 2013-12-18 16:32:41 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-12-18 16:32:41 +0100 |
commit | aa7cd8834b21a064e4fe0440b956f6c174949ed2 (patch) | |
tree | 4e9a17a838dc3c6cec28954ad69a9b84057da33c /IRC/getconf.py | |
parent | 8a9c41f399dd874b246818bb81f4c9edbf9a9549 (diff) |
Reaktor: s/(config).json/\1.py/
Diffstat (limited to 'IRC/getconf.py')
-rw-r--r-- | IRC/getconf.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/IRC/getconf.py b/IRC/getconf.py index 5fdd1cd..d6e9f42 100644 --- a/IRC/getconf.py +++ b/IRC/getconf.py @@ -2,19 +2,29 @@ #getconf(key) -> value #oder error -import json +import imp +import os + def make_getconf(filename): + + config = load_config(filename) + def getconf(prop): prop_split = prop.split('.') string = '' - file = open(filename) - for line in file.readlines(): - string+=line - parsed = json.loads(string) - tmp = parsed + imp.reload(config) + tmp = config.__dict__ for pr in prop_split: tmp = tmp[pr] - return tmp + return getconf + + +def load_config(filename): + dirname = os.path.dirname(filename) + modname, ext = os.path.splitext(os.path.basename(filename)) + file, pathname, description = imp.find_module(modname, [ dirname ]) + return imp.load_module(modname, file, pathname, description) + |