- return int(self._get_parameter(section, param))
- except ValueError:
- raise ParseError("Not int: [%s.%s]" % (section, param))
-
- def _get_bool_parameter(self, section, param):
- result = self._get_parameter(section, param)
- if str(result).lower() == 'true':
- return True
- if str(result).lower() == 'false':
- return False
-
- raise ParseError(
- "Not boolean: [%s.%s : %s]" % (section, param, result))
-
- @staticmethod
- def parse(config_location=None):
- obj = APIConfig()
-
- if config_location is None:
- config_location = obj._default_config_location
-
- if not os.path.exists(config_location):
- raise ParseError("%s not found" % config_location)
-
- obj._parser = ConfigParser.SafeConfigParser()
- obj._parser.read(config_location)
-
- # Linking attributes to keys from file with their sections
- obj.mongo_url = obj._get_parameter("mongo", "url")
- obj.mongo_dbname = obj._get_parameter("mongo", "dbname")