-
Notifications
You must be signed in to change notification settings - Fork 0
/
inifiles.py
43 lines (38 loc) · 1017 Bytes
/
inifiles.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
35
36
37
38
39
40
41
42
43
"""
Version 1.0
"""
from configparser import ConfigParser
class IniFiles:
"""
Simple class for work with INI files
"""
def __init__(self, config_file):
self.config_file = config_file
self.config = None
self.open_config()
def open_config(self):
"""
Open configuration file
:return:
"""
self.config = ConfigParser()
self.config.read(self.config_file)
def read_option(self, section, option):
"""
Read value from configuration file
:param section:
:param option:
:return:
"""
return self.config[section][option]
def write_option(self, section, option, value):
"""
Save value to configuration file
:param section:
:param option:
:param value:
:return:
"""
self.config[section][option] = value
with open(self.config_file, "w") as conf_file:
self.config.write(conf_file)