From 8a8abdde5b9b834fb4f51fcfb44df239e572b8af Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 28 Aug 2015 11:05:44 +0200 Subject: Reaktor: IRC -> reaktor Remove Obsolete README, remove obsolete index --- reaktor/getconf.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 reaktor/getconf.py (limited to 'reaktor/getconf.py') diff --git a/reaktor/getconf.py b/reaktor/getconf.py new file mode 100644 index 0000000..168c908 --- /dev/null +++ b/reaktor/getconf.py @@ -0,0 +1,33 @@ +#getconf = make_getconf("dateiname.json") +#getconf(key) -> value +#oder error + +import imp +import os + + +def make_getconf(filename): + + + def getconf(prop, default_value=None): + prop_split = prop.split('.') + string = '' + config = load_config(filename) + #imp.reload(config) + tmp = config.__dict__ + for pr in prop_split: + if pr in tmp: + tmp = tmp[pr] + else: + return default_value + 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) + -- cgit v1.2.3