from os import path, environ from ConfigParser import SafeConfigParser, ParsingError class Config: def __init__(self): try: self.home = environ['LCSH_HOME'] self.config_file = "%s/lcsh.conf" % self.home parser = SafeConfigParser() parser.read(self.config_file) self.config = parser self.solr = self.config.get('lcsh', 'solr') self.store = self.config.get('lcsh', 'store') except KeyError: raise RuntimeError("LCSH_HOME not defined") except ParsingError, e: raise RuntimeError("unable to read configuration file : %s" % self.config_file) def get(self, section, option): return self.config.get(section, option)