MCPcopy Index your code
hub / github.com/saltstack/salt / SaltStackVersion

Class SaltStackVersion

salt/version.py:241–581  ·  view source on GitHub ↗

Handle SaltStack versions class. Knows how to parse ``git describe`` output, knows about release candidates and also supports version comparison.

Source from the content-addressed store, hash-verified

239
240
241class SaltStackVersion:
242 """
243 Handle SaltStack versions class.
244
245 Knows how to parse ``git describe`` output, knows about release candidates
246 and also supports version comparison.
247 """
248
249 __slots__ = (
250 "name",
251 "major",
252 "minor",
253 "bugfix",
254 "mbugfix",
255 "pre_type",
256 "pre_num",
257 "noc",
258 "sha",
259 )
260
261 git_sha_regex = r"(?P<sha>g?[a-f0-9]{7,40})"
262
263 git_describe_regex = re.compile(
264 r"(?:[^\d]+)?(?P<major>[\d]{1,4})"
265 r"(?:\.(?P<minor>[\d]{1,2}))?"
266 r"(?:\.(?P<bugfix>[\d]{0,2}))?"
267 r"(?:\.(?P<mbugfix>[\d]{0,2}))?"
268 r"(?:(?P<pre_type>rc|a|b|alpha|beta|nb)(?P<pre_num>[\d]+))?"
269 r"(?:(?:.*)(?:\+|-)(?P<noc>(?:0na|[\d]+|n/a))(?:-|\.)" + git_sha_regex + r")?"
270 )
271 git_sha_regex = r"^" + git_sha_regex
272
273 git_sha_regex = re.compile(git_sha_regex)
274
275 NAMES = {v.name: v.info for v in SaltVersionsInfo.versions()}
276 LNAMES = {k.lower(): v for (k, v) in iter(NAMES.items())}
277 VNAMES = {v: k for (k, v) in iter(NAMES.items())}
278 RMATCH = {v[:2]: k for (k, v) in iter(NAMES.items())}
279
280 def __init__(
281 self, # pylint: disable=C0103
282 major,
283 minor=None,
284 bugfix=None,
285 mbugfix=0,
286 pre_type=None,
287 pre_num=None,
288 noc=0,
289 sha=None,
290 ):
291 if isinstance(major, str):
292 major = int(major)
293
294 if isinstance(minor, str):
295 if not minor:
296 # Empty string
297 minor = None
298 else:

Callers 11

test_string_new_versionFunction · 0.90
test_string_old_versionFunction · 0.90
test_discover_versionFunction · 0.90
test_info_new_versionFunction · 0.90
test_info_old_versionFunction · 0.90
test_bugfix_stringFunction · 0.90
test_version_reprFunction · 0.90
__compare__Method · 0.85
__discover_versionFunction · 0.85

Calls 2

versionsMethod · 0.80
itemsMethod · 0.45

Tested by 9

test_string_new_versionFunction · 0.72
test_string_old_versionFunction · 0.72
test_discover_versionFunction · 0.72
test_info_new_versionFunction · 0.72
test_info_old_versionFunction · 0.72
test_bugfix_stringFunction · 0.72
test_version_reprFunction · 0.72