Coverage for src/robotide/utils/versioncomparator.py: 80%
20 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
1# Copyright 2008-2015 Nokia Networks
2# Copyright 2016- Robot Framework Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
16try: 1st
17 from pkg_resources import parse_version 1st
18except ImportError:
19 try:
20 from packaging.version import parse as parse_version
21 except ImportError as e:
22 print("RIDE cannot verify versions upgrade because of missing packages."
23 "You can install missing package with:\npip install packaging\nor\npip install setuptools")
24 raise e
27def cmp_versions(version1, version2): 1st
28 if version1 is None: 1noghbipqcjukldefmar
29 if version2 is None: 1e
30 return 0 1e
31 else:
32 return -1 1e
33 if version2 is None: 1noghbipqcjukldefmar
34 return 1 1ue
35 if parse_version(version1) == parse_version(version2): 1noghbipqcjkldfmar
36 return 0 1nobpqcar
37 elif parse_version(version1) > parse_version(version2): 1ghbicjkldfma
38 return 1 1kdfma
39 return -1 1ghbicjldfa