summaryrefslogtreecommitdiff
path: root/config.py
blob: 7fd35adb16b8d753c3839588b84564185a96ab91 (plain)
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
try:
	from configparser import ConfigParser, NoOptionError
except ImportError:
	from ConfigParser import ConfigParser, NoOptionError

class Config(object):
	config_section = 'foo'

	def __init__(self, filename = 'config'):
		self.config = ConfigParser()
		self.config.read(filename)

	def get(self, key, section = config_section, default = None):
		try:
			return self.config.get(section, key)
		except NoOptionError:
			if default != None:
				return default
			else:
				raise

	def getint(self, key, section = config_section):
		return self.config.getint(section, key)

config = Config()