- 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")
-
- obj.api_port = obj._get_int_parameter("api", "port")
- obj.api_debug_on = obj._get_bool_parameter("api", "debug")
- obj.api_authenticate_on = obj._get_bool_parameter("api",
- "authenticate")
-
- obj.swagger_base_url = obj._get_parameter("swagger", "base_url")
-
- return obj
+ def _default_config():
+ is_venv = os.getenv('VIRTUAL_ENV')
+ return os.path.join('/' if not is_venv else is_venv,
+ 'etc/opnfv_testapi/config.ini')