summaryrefslogtreecommitdiff
path: root/src/leap/common/config
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2013-08-06 18:20:59 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2013-08-07 14:53:37 -0300
commit011e8802b248ffa39fa40d4931d2577256d01bd7 (patch)
tree0ebb2c729197d0923b00404a51273a0f8a6f9a9c /src/leap/common/config
parent6b3c65f158fcb63695568b3215f3f86503af8cb8 (diff)
Handle schemas and api versions in base class.
Diffstat (limited to 'src/leap/common/config')
-rw-r--r--src/leap/common/config/baseconfig.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/leap/common/config/baseconfig.py b/src/leap/common/config/baseconfig.py
index 7bf08dd..ba87df9 100644
--- a/src/leap/common/config/baseconfig.py
+++ b/src/leap/common/config/baseconfig.py
@@ -61,13 +61,25 @@ class BaseConfig:
def __init__(self):
self._data = {}
self._config_checker = None
+ self._api_version = None
@abstractmethod
+ def _get_schema(self):
+ """
+ Returns the schema corresponding to the version given.
+
+ :rtype: dict or None if the version is not supported.
+ """
+ pass
+
def _get_spec(self):
"""
Returns the spec object for the specific configuration.
"""
- return None
+ leap_assert(self._api_version is not None,
+ "You should set the API version.")
+
+ return self._get_schema()
def _safe_get_value(self, key):
"""
@@ -79,6 +91,17 @@ class BaseConfig:
leap_assert(self._config_checker, "Load the config first")
return self._config_checker.config.get(key, None)
+ def set_api_version(self, version):
+ """
+ Sets the supported api version.
+
+ :param api_version: the version of the api supported by the provider.
+ :type api_version: str
+ """
+ self._api_version = version
+ leap_assert(self._get_schema(self._api_version) is not None,
+ "Version %s is not supported." % (version, ))
+
def get_path_prefix(self):
"""
Returns the platform dependant path prefixer