blob: 3f8995ba1d4f256c7c190a28a4bdd805bf4bd934 (
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 = '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):
return self.config.getint(section, key)
config = Config()
|