forked from emreg00/toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.py
35 lines (27 loc) · 1.05 KB
/
configuration.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
27
28
29
30
31
32
33
34
import ConfigParser #, os
#CONFIG = configuration.Configuration(CONFIG_FILE, CONFIG_SECTION)
class Configuration():
CONFIG_FILE = "default.ini"
CONFIG_SECTION = "DEFAULT"
def __init__(self, config_file=None, config_section=None):
#print os.getcwd()
if config_file is None:
config_file = Configuration.CONFIG_FILE
if config_section is None:
config_section = Configuration.CONFIG_SECTION
self.config_section = config_section
self.config = ConfigParser.SafeConfigParser()
self.config.read(config_file)
return
def get(self, var_name):
return self.config.get(self.config_section, var_name)
def get_boolean(self, var_name):
return self.config.getboolean(self.config_section, var_name)
# CONFIG = configuration.get_configuration(CONFIG_FILE, CONFIG_SECTION)
#def get_configuration(config_file=CONFIG_FILE, config_section=CONFIG_SECTION, var_name=None):
# config = ConfigParser.SafeConfigParser()
# config.read(CONFIG_FILE)
# if var_name is None:
# return config
# else:
# return config.get(CONFIG_SECTION, var_name)