Ejemplo n.º 1
0
Archivo: rpm.py Proyecto: odra/anitya
    def __eq__(self, other):
        """
        Compare two versions for equality using the RPM rules with pre-release
        support.
        """
        v1, rc1, rcn1 = self.split_rc(self.parse())
        v2, rc2, rcn2 = self.split_rc(other.parse())
        result = _compare_rpm_labels((None, v1, None), (None, v2, None))
        if result != 0:
            return False

        if rc1 == rc2 and rcn1 == rcn2:
            return True
        else:
            return False
Ejemplo n.º 2
0
    def __eq__(self, other):
        """
        Compare two versions for equality using the RPM rules with pre-release
        support.
        """
        v1, rc1, rcn1 = self.split_rc(self.parse())
        v2, rc2, rcn2 = self.split_rc(other.parse())
        result = _compare_rpm_labels((None, v1, None), (None, v2, None))
        if result != 0:
            return False

        if rc1 == rc2 and rcn1 == rcn2:
            return True
        else:
            return False
Ejemplo n.º 3
0
Archivo: rpm.py Proyecto: odra/anitya
    def __lt__(self, other):
        v1, rc1, rcn1 = self.split_rc(self.parse())
        v2, rc2, rcn2 = self.split_rc(other.parse())
        result = _compare_rpm_labels((None, v1, None), (None, v2, None))
        if result == -1:
            return True
        elif result == 1:
            return False

        if rc1 and rc2:
            # both are rc, higher rc is newer
            rc1_text = rc1.lower()
            rc2_text = rc2.lower()
            # rc > pre > beta > alpha
            if rc1_text < rc2_text:
                return True
            if rc1_text > rc2_text:
                return False
            if rcn1 and rcn2:
                # both have rc number
                return int(rcn1) < int(rcn2)
            if rcn1:
                # only first has rc number, then it is newer
                return False
            if rcn2:
                # only second has rc number, then it is newer
                return True
            # both rc numbers are missing or same
            return False

        if rc1:
            # only first is rc, then second is newer
            return True
        if rc2:
            # only second is rc, then first is newer
            return False

        # neither is a rc
        return False
Ejemplo n.º 4
0
    def __lt__(self, other):
        v1, rc1, rcn1 = self.split_rc(self.parse())
        v2, rc2, rcn2 = self.split_rc(other.parse())
        result = _compare_rpm_labels((None, v1, None), (None, v2, None))
        if result == -1:
            return True
        elif result == 1:
            return False

        if rc1 and rc2:
            # both are rc, higher rc is newer
            rc1_text = rc1.lower()
            rc2_text = rc2.lower()
            # rc > pre > beta > alpha
            if rc1_text < rc2_text:
                return True
            if rc1_text > rc2_text:
                return False
            if rcn1 and rcn2:
                # both have rc number
                return int(rcn1) < int(rcn2)
            if rcn1:
                # only first has rc number, then it is newer
                return False
            if rcn2:
                # only second has rc number, then it is newer
                return True
            # both rc numbers are missing or same
            return False

        if rc1:
            # only first is rc, then second is newer
            return True
        if rc2:
            # only second is rc, then first is newer
            return False

        # neither is a rc
        return False
Ejemplo n.º 5
0
def rpm_cmp(v1, v2):
    diff = _compare_rpm_labels((None, v1, None), (None, v2, None))
    return diff