-
Notifications
You must be signed in to change notification settings - Fork 0
/
Conf.py
26 lines (20 loc) · 845 Bytes
/
Conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
import json
class conf_parser(object):
def __init__(self):
self.read_config()
def read_config(self):
c_f = open('config.json', 'r')
self.config = json.loads(c_f.read())
c_f.close()
if 'debug' in self.config['global'] and self.config['global']['debug']:
print json.dumps(self.config, sort_keys=True, indent=4, separators=(',', ': '))
def get_config(self, module):
res={}
for key in self.config['global'].keys():
res[key]=self.config['global'][key]
for key in self.config[module].keys():
res[key]=self.config[module][key]
if 'debug' in self.config['global'] and self.config['global']['debug']>1:
print json.dumps(res, sort_keys=True, indent=4, separators=(',', ': '))
return res