mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-08-04 06:50:14 +00:00
Improvement of compat/LooseVersion
This commit is contained in:
parent
8a19966017
commit
899447fbae
3 changed files with 8 additions and 24 deletions
|
|
@ -286,34 +286,18 @@ def LooseVersion(version):
|
|||
True
|
||||
>>> LooseVersion("1.0.1") > LooseVersion("1.0")
|
||||
True
|
||||
>>> LooseVersion("1.0.1-") == LooseVersion("1.0.1")
|
||||
True
|
||||
>>> LooseVersion("1.0.11") < LooseVersion("1.0.111")
|
||||
True
|
||||
>>> LooseVersion("foobar") > LooseVersion("1.0")
|
||||
False
|
||||
>>> LooseVersion("1.0") > LooseVersion("foobar")
|
||||
False
|
||||
>>> LooseVersion("3.22-mysql") == LooseVersion("3.22-mysql-ubuntu0.3")
|
||||
>>> LooseVersion("8.0.22") > LooseVersion("8.0.2")
|
||||
True
|
||||
>>> LooseVersion("8.0.22-0ubuntu0.20.04.2")
|
||||
8.000022
|
||||
>>> LooseVersion("1.0alpha-beta-gama")
|
||||
(1, 0)
|
||||
"""
|
||||
|
||||
match = re.search(r"\A(\d[\d.]*)", version or "")
|
||||
|
||||
if match:
|
||||
result = 0
|
||||
value = match.group(1)
|
||||
weight = 1.0
|
||||
for part in value.strip('.').split('.'):
|
||||
if part.isdigit():
|
||||
result += int(part) * weight
|
||||
weight *= 1e-3
|
||||
return tuple(int(part) for part in match.group(1).strip('.').split('.') if part.isdigit())
|
||||
else:
|
||||
result = float("NaN")
|
||||
|
||||
return result
|
||||
return ()
|
||||
|
||||
# NOTE: codecs.open re-implementation (deprecated in Python 3.14)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue