Ejemplo n.º 1
0
 def _cmp(self, other):
     # LooseVersion checks isinstance(StringType), so work around it.
     if six.PY2 and isinstance(other, six.text_type):
         other = other.encode("ascii")
     if six.PY2:
         return LooseVersion.__cmp__(self, other)
     return LooseVersion._cmp(self, other)
Ejemplo n.º 2
0
    def _cmp(self, other):
        if isinstance(other, str):
            other = KafkaVersion(other)

        if other.is_dev:
            if self.is_dev:
                return 0
            return -1
        elif self.is_dev:
            return 1

        return LooseVersion._cmp(self, other)
Ejemplo n.º 3
0
        def _cmp(self, other):
            if isinstance(other, six.string_types):
                other = LooseVersion(other)

            string_in_version = False
            for part in self.version + other.version:
                if not isinstance(part, int):
                    string_in_version = True
                    break

            if string_in_version is False:
                return _LooseVersion._cmp(self, other)

            # If we reached this far, it means at least a part of the version contains a string
            # In python 3, strings and integers are not comparable
            if self._str_version == other._str_version:
                return 0
            if self._str_version < other._str_version:
                return -1
            if self._str_version > other._str_version:
                return 1
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 def _cmp(self, other):
     if isinstance(other, six.string_types):
         other = LooseVersion(other)
     return _LooseVersion._cmp(self, other)