From 74ad26edc2cf0d8aa8d5d485d708de1a34aa75c0 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 14 Aug 2011 21:59:35 +0200 Subject: Some recoding work, added ogg encoder. --- config.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'config.py') 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() -- cgit v1.2.3