summaryrefslogtreecommitdiff
path: root/config.py
blob: cadeb14cc8ee4a18a52f405b1261cb8cea453e4b (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
26
27
28
29
30
31
try:
	from configparser import ConfigParser, NoOptionError
except ImportError:
	from ConfigParser import ConfigParser, NoOptionError

class Config(object):
	config_section = 'ongaku'

	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, default = None):
		try:
			return self.config.getint(section, key)
		except NoOptionError:
			if default != None:
				return default
			else:
				raise

config = Config()