Skip to content

Commit 022fd34

Browse files
author
Arthur Gautier
committed
adds python3 comparators
Signed-off-by: Arthur Gautier <baloo@gandi.net>
1 parent 66d4bd5 commit 022fd34

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

pymysqlreplication/gtid.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ def __sub__(self, other):
169169

170170
return result
171171

172-
def __cmp__(self, other):
173-
if other.sid != self.sid:
174-
return cmp(self.sid, other.sid)
175-
return cmp(self.intervals, other.intervals)
176-
177172
def __str__(self):
178173
"""We represent the human value here - a single number
179174
for one transaction, or a closed interval (decrementing b)"""
@@ -235,6 +230,36 @@ def decode(cls, payload):
235230
else '%d' % x
236231
for x in intervals])))
237232

233+
def __cmp__(self, other):
234+
if other.sid != self.sid:
235+
return cmp(self.sid, other.sid)
236+
return cmp(self.intervals, other.intervals)
237+
238+
def __eq__(self, other):
239+
if other.sid != self.sid:
240+
return False
241+
return self.intervals == other.intervals
242+
243+
def __lt__(self, other):
244+
if other.sid != self.sid:
245+
return self.sid < other.sid
246+
return self.intervals < other.intervals
247+
248+
def __le__(self, other):
249+
if other.sid != self.sid:
250+
return self.sid <= other.sid
251+
return self.intervals <= other.intervals
252+
253+
def __gt__(self, other):
254+
if other.sid != self.sid:
255+
return self.sid > other.sid
256+
return self.intervals > other.intervals
257+
258+
def __ge__(self, other):
259+
if other.sid != self.sid:
260+
return self.sid >= other.sid
261+
return self.intervals >= other.intervals
262+
238263

239264
class GtidSet(object):
240265
def __init__(self, gtid_set):
@@ -297,3 +322,6 @@ def decode(cls, payload):
297322
(n_sid,) = struct.unpack('<Q', payload.read(8))
298323

299324
return cls([Gtid.decode(payload) for _ in range(0, n_sid)])
325+
326+
def __eq__(self, other):
327+
return self.gtids == other.gtids

0 commit comments

Comments
 (0)