summaryrefslogtreecommitdiff
path: root/config.py
diff options
context:
space:
mode:
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()