1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

EqualityTupleMixin impl, use everywhere we were doing tuple compares

This commit is contained in:
Ross McFarland
2019-10-14 08:13:07 -07:00
parent 74048bf974
commit 2b33f95c17
4 changed files with 126 additions and 202 deletions

30
octodns/equality.py Normal file
View File

@@ -0,0 +1,30 @@
#
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
class EqualityTupleMixin:
def _equality_tuple(self):
raise NotImplementedError('_equality_tuple method not implemented')
def __eq__(self, other):
return self._equality_tuple() == other._equality_tuple()
def __ne__(self, other):
return self._equality_tuple() != other._equality_tuple()
def __lt__(self, other):
return self._equality_tuple() < other._equality_tuple()
def __le__(self, other):
return self._equality_tuple() <= other._equality_tuple()
def __gt__(self, other):
return self._equality_tuple() > other._equality_tuple()
def __ge__(self, other):
return self._equality_tuple() >= other._equality_tuple()