summaryrefslogtreecommitdiff
path: root/config.py
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2012-02-13 22:09:11 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2012-02-13 22:09:11 +0100
commit0d8e86265f74ee36503bbcec445dcefdea208df0 (patch)
treed129e83b5913124ca4542ae6b5e6c40fcafc6517 /config.py
Initial import.
Diffstat (limited to 'config.py')
-rw-r--r--config.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/config.py b/config.py
new file mode 100644
index 0000000..3f8995b
--- /dev/null
+++ b/config.py
@@ -0,0 +1,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()