-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathifaceconfiglib.py
40 lines (30 loc) · 971 Bytes
/
ifaceconfiglib.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
# -*- coding: utf-8 -*-
__author__ = 'Mariusz "maryush" Witkowski'
import os
import sys
import ConfigParser
config_file = os.path.dirname(__file__)+os.sep+"iface.cfg"
class Config(object):
"""basic operations on config file"""
cfg = None
def __init__(self, config_file):
"""class initialization"""
if not config_file:
config_file = config_file
self.cfg = ConfigParser.RawConfigParser()
self.cfg.read(config_file)
def get(self, section, name):
"""read value from selected section"""
try:
value = self.cfg.get(section, name)
except:
value = None
finally:
return value
def getBoolean(self, section, name):
"""getting boolean value"""
return self.cfg.getboolean(section, name)
def getInt(self, section, name):
"""getting int value"""
return self.cfg.getint(section, name)
cfg = Config(config_file)