MCPcopy Create free account
hub / github.com/StackStorm/st2 / complex_semver_match

Function complex_semver_match

st2common/st2common/util/versioning.py:51–80  ·  view source on GitHub ↗

Custom semver match function which also supports complex semver specifiers such as >=1.6, <2.0, etc. NOTE: This function also supports special "all" version specifier. When "all" is specified, any version provided will be considered valid. :rtype: ``bool``

(version, version_specifier)

Source from the content-addressed store, hash-verified

49
50
51def complex_semver_match(version, version_specifier):
52 """
53 Custom semver match function which also supports complex semver specifiers
54 such as >=1.6, <2.0, etc.
55
56 NOTE: This function also supports special "all" version specifier. When "all"
57 is specified, any version provided will be considered valid.
58
59 :rtype: ``bool``
60 """
61 if version_specifier == "all":
62 return True
63
64 split_version_specifier = version_specifier.split(",")
65
66 if len(split_version_specifier) == 1:
67 # No comma, we can do a simple comparision
68 return semver.Version.parse(version).match(version_specifier)
69 else:
70 # Compare part by part
71 for version_specifier_part in split_version_specifier:
72 version_specifier_part = version_specifier_part.strip()
73
74 if not version_specifier_part:
75 continue
76
77 if not semver.Version.parse(version).match(version_specifier_part):
78 return False
79
80 return True

Callers 2

verify_pack_versionFunction · 0.90

Calls 2

parseMethod · 0.80
matchMethod · 0.45

Tested by 1