diff options
| author | Christian Heimes <cheimes@redhat.com> | 2016-11-21 10:24:17 +0100 |
|---|---|---|
| committer | Martin Babinsky <mbabinsk@redhat.com> | 2016-11-24 15:46:40 +0100 |
| commit | 2cbaf156045769b54150e4d4c3c1071f164a16fb (patch) | |
| tree | e56ed216116635fb02adae9a58fc8b6e2e6ce1d5 /ipaclient/remote_plugins | |
| parent | 526bcea705d04895aa6b09bce996ac340783d1d0 (diff) | |
| download | freeipa-2cbaf156045769b54150e4d4c3c1071f164a16fb.tar.gz freeipa-2cbaf156045769b54150e4d4c3c1071f164a16fb.tar.xz freeipa-2cbaf156045769b54150e4d4c3c1071f164a16fb.zip | |
Replace LooseVersion
pylint is having a hard time with distutils.version in tox's virtual
envs. virtualenv uses some tricks to provide a virtual distutils
package, pylint can't cope with.
https://github.com/PyCQA/pylint/issues/73 suggests to use pkg_resources
instead. pkg_resources' version parser has some more benefits, e.g. PEP
440 conformity. But pkg_resources.parse_version() is a heavy weight solution
with reduced functionality, e.g. no access to major version.
For API_VERSION and plugin version we can use a much simpler and faster
approach.
https://fedorahosted.org/freeipa/ticket/6468
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipaclient/remote_plugins')
| -rw-r--r-- | ipaclient/remote_plugins/compat.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/ipaclient/remote_plugins/compat.py b/ipaclient/remote_plugins/compat.py index 984eecd3f..c1ae63539 100644 --- a/ipaclient/remote_plugins/compat.py +++ b/ipaclient/remote_plugins/compat.py @@ -2,7 +2,6 @@ # Copyright (C) 2016 FreeIPA Contributors see COPYING for license # -from distutils.version import LooseVersion import importlib import os import re @@ -12,6 +11,7 @@ import six from ipaclient.frontend import ClientCommand, ClientMethod from ipalib.frontend import Object +from ipapython.ipautil import APIVersion if six.PY3: unicode = str @@ -58,7 +58,7 @@ def get_package(server_info, client): server_info['version'] = server_version server_info.update_validity() - server_version = LooseVersion(server_version) + server_version = APIVersion(server_version) package_names = {} base_name = __name__.rpartition('.')[0] @@ -66,15 +66,14 @@ def get_package(server_info, client): for name in os.listdir(base_dir): package_dir = os.path.join(base_dir, name) if name.startswith('2_') and os.path.isdir(package_dir): - package_version = name.replace('_', '.') + package_version = APIVersion(name.replace('_', '.')) package_names[package_version] = '{}.{}'.format(base_name, name) package_version = None - for version in sorted(package_names, key=LooseVersion): - if (package_version is None or - LooseVersion(package_version) < LooseVersion(version)): + for version in sorted(package_names): + if package_version is None or package_version < version: package_version = version - if LooseVersion(version) >= server_version: + if version >= server_version: break package_name = package_names[package_version] |
