Skip to content

Commit

Permalink
dep: support all comparison methods for UseDep objects
Browse files Browse the repository at this point in the history
  • Loading branch information
radhermit committed Dec 17, 2023
1 parent 2a8bbf6 commit 3e58a42
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/pkgcraft/dep/use.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ cdef class UseDep:
inst.missing = UseDepDefault(ptr.missing[0])
return inst

def __lt__(self, other):
if isinstance(other, UseDep):
return C.pkgcraft_use_dep_cmp(self.ptr, (<UseDep>other).ptr) == -1
return NotImplemented

def __le__(self, other):
if isinstance(other, UseDep):
return C.pkgcraft_use_dep_cmp(self.ptr, (<UseDep>other).ptr) <= 0
return NotImplemented

def __eq__(self, other):
if isinstance(other, UseDep):
return C.pkgcraft_use_dep_cmp(self.ptr, (<UseDep>other).ptr) == 0
Expand All @@ -100,6 +110,16 @@ cdef class UseDep:
return C.pkgcraft_use_dep_cmp(self.ptr, (<UseDep>other).ptr) != 0
return NotImplemented

def __ge__(self, other):
if isinstance(other, UseDep):
return C.pkgcraft_use_dep_cmp(self.ptr, (<UseDep>other).ptr) >= 0
return NotImplemented

def __gt__(self, other):
if isinstance(other, UseDep):
return C.pkgcraft_use_dep_cmp(self.ptr, (<UseDep>other).ptr) == 1
return NotImplemented

def __hash__(self):
if not self._hash:
self._hash = C.pkgcraft_use_dep_hash(self.ptr)
Expand Down

0 comments on commit 3e58a42

Please sign in to comment.