def __cmp__(self, other): r = mx.compare(self._low, other._low) if r != 0: return r if self._high is None: if other._high is None: return 0 # self has no high bound, other does return 1 elif other._high is None: # other has no high bound, self does return -1 return mx.compare(self._high, other._high)
def __contains__(self, other): if isinstance(other, (int, str)): other = JavaCompliance(other) assert other._high_bound( ) is not None, "Contains check cannot be done with version ranges" r = mx.compare(self.value, other.value) if r == 0: return True elif r > 0: return False else: # r < 0 if self._high_bound() is None: return True else: return mx.compare(self._high_bound(), other.value) >= 0
def __cmp__(self, other): if isinstance(other, str): other = JavaCompliance(other) return mx.compare(self._parts, other._parts)