Software Update: Default to pkg_resources for version comparison
That's also able to cope with 0.3a and similar "non-semantic" version schemes. Semantic version comparison can still be forced by setting the compare_type in the check to "semantic". Strict equality check can be set similarly by using the value "unequal".
This commit is contained in:
parent
326fc943b7
commit
0f818a313d
1 changed files with 12 additions and 4 deletions
|
|
@ -48,11 +48,19 @@ def _is_current(release_information, compare_type, custom=None):
|
||||||
if release_information["remote"]["value"] is None:
|
if release_information["remote"]["value"] is None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not compare_type in ("semantic", "unequal", "custom") or compare_type == "custom" and custom is None:
|
if not compare_type in ("python", "semantic", "unequal", "custom") or compare_type == "custom" and custom is None:
|
||||||
compare_type = "semantic"
|
compare_type = "python"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if compare_type == "semantic":
|
if compare_type == "python":
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
local_version = pkg_resources.parse_version(release_information["local"]["value"])
|
||||||
|
remote_version = pkg_resources.parse_version(release_information["remote"]["value"])
|
||||||
|
|
||||||
|
return local_version >= remote_version
|
||||||
|
|
||||||
|
elif compare_type == "semantic":
|
||||||
import semantic_version
|
import semantic_version
|
||||||
|
|
||||||
local_version = semantic_version.Version(release_information["local"]["value"])
|
local_version = semantic_version.Version(release_information["local"]["value"])
|
||||||
|
|
@ -79,7 +87,7 @@ def get_latest(target, check, custom_compare=None):
|
||||||
current = check["current"]
|
current = check["current"]
|
||||||
|
|
||||||
remote_name, remote_tag = _get_latest_release(check["user"], check["repo"], include_prerelease=check["prerelease"] == True if "prerelease" in check else False)
|
remote_name, remote_tag = _get_latest_release(check["user"], check["repo"], include_prerelease=check["prerelease"] == True if "prerelease" in check else False)
|
||||||
compare_type = check["release_compare"] if "release_compare" in check else "semantic"
|
compare_type = check["release_compare"] if "release_compare" in check else "python"
|
||||||
|
|
||||||
information =dict(
|
information =dict(
|
||||||
local=dict(name=current, value=current),
|
local=dict(name=current, value=current),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue