From fc0663054c4f76c1103291c334bb60c0dff1280b Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 7 Jan 2014 18:58:06 -0300 Subject: Refactor provider utilities. --- src/leap/bitmask/provider/__init__.py | 37 ++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'src/leap/bitmask/provider/__init__.py') diff --git a/src/leap/bitmask/provider/__init__.py b/src/leap/bitmask/provider/__init__.py index 68f3ded0..ca6426f4 100644 --- a/src/leap/bitmask/provider/__init__.py +++ b/src/leap/bitmask/provider/__init__.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ -Module initialization for leap.bitmask.provider +Provider utilities. """ import os @@ -25,6 +25,10 @@ from leap.bitmask import __version__ as BITMASK_VERSION from leap.common.check import leap_assert +# The currently supported API versions by the client. +SUPPORTED_APIS = ["1"] + + def get_provider_path(domain): """ Returns relative path for provider config. @@ -38,19 +42,24 @@ def get_provider_path(domain): return os.path.join("leap", "providers", domain, "provider.json") -class SupportedClient(object): +def supports_api(api_version): """ - Class responsible of checking for client compatibility. + :param api_version: the version number of the api that we need to check + :type api_version: str + + :returns: if that version is supported or not. + :return type: bool """ + return api_version in SUPPORTED_APIS + - @classmethod - def supports(self, minimum_version): - """ - :param minimum_version: the version number of the client that - we need to check. - :type minimum_version: str - - :returns: True if that version is supported or False otherwise. - :return type: bool - """ - return LooseVersion(minimum_version) <= LooseVersion(BITMASK_VERSION) +def supports_client(minimum_version): + """ + :param minimum_version: the version number of the client that + we need to check. + :type minimum_version: str + + :returns: True if that version is supported or False otherwise. + :return type: bool + """ + return LooseVersion(minimum_version) <= LooseVersion(BITMASK_VERSION) -- cgit v1.2.3