mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fix RuntimeWarning: You have iterated over the result of
pkg_resources.parse_version. This is a legacy behavior Fix #504
This commit is contained in:
12 files changed
+56
-11
No files matched your search
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import re
|
||||
import textwrap
|
||||
import posixpath
|
||||
|
||||
@@ -44,3 +45,32 @@ def int_to_macaddress(integer):
|
||||
Convert an integer to a macaddress
|
||||
"""
|
||||
return ":".join(textwrap.wrap("%012x" % (integer), width=2))
|
||||
|
||||
|
||||
def parse_version(version):
|
||||
"""
|
||||
Return a comparable tuple from a version string.
|
||||
|
||||
Replace pkg_resources.parse_version which now display a warning when use for comparing version with tuple
|
||||
|
||||
:returns: Version string as comparable tuple
|
||||
"""
|
||||
|
||||
release_type_found = False
|
||||
version_infos = re.split('(\.|[a-z]+)', version)
|
||||
version = []
|
||||
for info in version_infos:
|
||||
if info == '.' or len(info) == 0:
|
||||
continue
|
||||
try:
|
||||
info = int(info)
|
||||
version.append(info)
|
||||
except ValueError:
|
||||
# We want rc to be at lower level than dev version
|
||||
if info == 'rc':
|
||||
info = 'c'
|
||||
version.append(info)
|
||||
release_type_found = True
|
||||
if release_type_found is False:
|
||||
version.append("final")
|
||||
return tuple(version)
|
||||
Reference in new issue
Block a user