MCPcopy
hub / github.com/saltstack/salt / __compare__

Method __compare__

salt/version.py:506–540  ·  view source on GitHub ↗
(self, other, method)

Source from the content-addressed store, hash-verified

504 return self.string
505
506 def __compare__(self, other, method):
507 if not isinstance(other, SaltStackVersion):
508 if isinstance(other, str):
509 other = SaltStackVersion.parse(other)
510 elif isinstance(other, (list, tuple)):
511 other = SaltStackVersion(*other)
512 else:
513 raise ValueError(
514 f"Cannot instantiate Version from type '{type(other)}'"
515 )
516 pre_type = self.pre_index
517 other_pre_type = other.pre_index
518 other_noc_info = list(other.noc_info)
519 noc_info = list(self.noc_info)
520
521 if self.new_version(self.major):
522 if self.minor and not other.minor:
523 # We have minor information, the other side does not
524 if self.minor > 0:
525 other_noc_info[1] = 0
526
527 if not self.minor and other.minor:
528 # The other side has minor information, we don't
529 if other.minor > 0:
530 noc_info[1] = 0
531
532 if self.pre_type and not other.pre_type:
533 # We have pre-release information, the other side doesn't
534 other_noc_info[other_pre_type] = "zzzzz"
535
536 if not self.pre_type and other.pre_type:
537 # The other side has pre-release information, we don't
538 noc_info[pre_type] = "zzzzz"
539
540 return method(tuple(noc_info), tuple(other_noc_info))
541
542 def __lt__(self, other):
543 return self.__compare__(other, lambda _self, _other: _self < _other)

Callers 6

__lt__Method · 0.95
__le__Method · 0.95
__eq__Method · 0.95
__ne__Method · 0.95
__ge__Method · 0.95
__gt__Method · 0.95

Calls 4

new_versionMethod · 0.95
SaltStackVersionClass · 0.85
listFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected