def _cmp(self, other): has_esr = set() if isinstance( other, LooseModernMozillaVersion) and str(other).endswith("esr"): # If other version ends with esr, coerce through MozillaVersion ending up with # a StrictVersion if possible has_esr.add("other") other = MozillaVersion( str(other)[:-3]) # strip ESR from end of string if isinstance(self, LooseModernMozillaVersion) and str(self).endswith("esr"): # If our version ends with esr, coerce through MozillaVersion ending up with # a StrictVersion if possible has_esr.add("self") self = MozillaVersion( str(self)[:-3]) # strip ESR from end of string if isinstance(other, LooseModernMozillaVersion) or isinstance( self, LooseModernMozillaVersion): # If we're still LooseVersion for self or other, run LooseVersion compare # Being sure to pass through Loose Version type first val = LooseVersion._cmp( LooseModernMozillaVersion(str(self)), LooseModernMozillaVersion(str(other)), ) else: # No versions are loose, therefore we can use StrictVersion val = StrictVersion._cmp(self, other) if has_esr.isdisjoint(set(["other", "self"])) or has_esr.issuperset( set(["other", "self"])): # If both had esr string or neither, then _cmp() was accurate return val elif val != 0: # cmp is accurate here even if esr is present in only 1 compare, since # versions are not equal return val elif "other" in has_esr: return -1 # esr is not greater than non esr return 1 # non esr is greater than esr
def _cmp(self, other): if isinstance(other, six.string_types): other = StrictVersion(other) return _StrictVersion._cmp(self, other)
def _cmp(self, other): if isinstance(other, str): other = StrictVersion(other) return _StrictVersion._cmp(self, other)
def _cmp(self, other): if isinstance(other, str): other = OmicronVersion(other) return StrictVersion._cmp(self, other)