summaryrefslogtreecommitdiff
path: root/config.py
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-08-14 21:59:35 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-08-14 21:59:35 +0200
commit74ad26edc2cf0d8aa8d5d485d708de1a34aa75c0 (patch)
tree9b3311046562d1e1267487568cbe5f425011c719 /config.py
parent78c0eae9a300b18060cc9f5b4114d843e87a2025 (diff)
Some recoding work, added ogg encoder.
Diffstat (limited to 'config.py')
-rw-r--r--config.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/config.py b/config.py
index 88826cb..7fd35ad 100644
--- a/config.py
+++ b/config.py
@@ -1,19 +1,25 @@
try:
- from configparser import ConfigParser
+ from configparser import ConfigParser, NoOptionError
except ImportError:
- from ConfigParser import ConfigParser
+ from ConfigParser import ConfigParser, NoOptionError
class Config(object):
- def __init__(self, filename = 'config'):
- self.config_section = 'foo'
+ config_section = 'foo'
+ def __init__(self, filename = 'config'):
self.config = ConfigParser()
self.config.read(filename)
- def get(self, key):
- return self.config.get(self.config_section, key)
+ 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):
- return self.config.getint(self.config_section, key)
+ def getint(self, key, section = config_section):
+ return self.config.getint(section, key)
config = Config()