mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-23 17:32:57 +02:00
unbound-dhcp-leases-bridge: Make Leases hashable and equal by IP address
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -488,20 +488,25 @@ class Lease(object):
|
||||
self._properties = properties
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s %s for %s (%s)>" % (self.__class__.__name__,
|
||||
self.ipaddr, self.hwaddr, self.hostname)
|
||||
return "<%s for %s (%s)>" % (self.__class__.__name__, self.ipaddr, self.hostname)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.ipaddr == other.ipaddr and self.hwaddr == other.hwaddr
|
||||
if isinstance(other, self.__class__):
|
||||
return self.ipaddr == other.ipaddr
|
||||
|
||||
return NotImplemented
|
||||
|
||||
def __gt__(self, other):
|
||||
if not self.ipaddr == other.ipaddr:
|
||||
return
|
||||
if isinstance(other, self.__class__):
|
||||
if not self.ipaddr == other.ipaddr:
|
||||
return NotImplemented
|
||||
|
||||
if not self.hwaddr == other.hwaddr:
|
||||
return
|
||||
return self.time_starts > other.time_starts
|
||||
|
||||
return self.time_starts > other.time_starts
|
||||
return NotImplemented
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.ipaddr)
|
||||
|
||||
@property
|
||||
def binding_state(self):
|
||||
|
||||
Reference in New Issue
Block a user