forked from erichnau/ApInsight
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_manager.py
More file actions
26 lines (19 loc) · 796 Bytes
/
config_manager.py
File metadata and controls
26 lines (19 loc) · 796 Bytes
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
import configparser
class ConfigurationManager:
def __init__(self, config_file):
self.config = configparser.ConfigParser()
self.config_file = config_file
self.load_config()
def load_config(self):
self.config.read(self.config_file)
def get_option(self, section, option):
return self.config.get(section, option)
def get_boolean_option(self, section, option):
return self.config.getboolean(section, option)
def set_option(self, section, option, value):
if not self.config.has_section(section):
self.config.add_section(section)
self.config.set(section, option, str(value))
def save_config(self):
with open(self.config_file, 'w') as configfile:
self.config.write(configfile)