add total_ordering to Time/Date/Host/Token
PYTHON-714
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
from binascii import unhexlify
|
||||
from bisect import bisect_right
|
||||
from collections import defaultdict, Mapping
|
||||
from functools import total_ordering
|
||||
from hashlib import md5
|
||||
from itertools import islice, cycle
|
||||
import json
|
||||
@@ -1492,6 +1493,7 @@ class TokenMap(object):
|
||||
return []
|
||||
|
||||
|
||||
@total_ordering
|
||||
class Token(object):
|
||||
"""
|
||||
Abstract class representing a token.
|
||||
@@ -1512,14 +1514,6 @@ class Token(object):
|
||||
def from_string(cls, token_string):
|
||||
raise NotImplementedError()
|
||||
|
||||
def __cmp__(self, other):
|
||||
if self.value < other.value:
|
||||
return -1
|
||||
elif self.value == other.value:
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.value == other.value
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
Connection pooling and host management.
|
||||
"""
|
||||
|
||||
from functools import total_ordering
|
||||
import logging
|
||||
import socket
|
||||
import time
|
||||
@@ -41,6 +42,7 @@ class NoConnectionsAvailable(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@total_ordering
|
||||
class Host(object):
|
||||
"""
|
||||
Represents a single Cassandra node.
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
from __future__ import with_statement
|
||||
import calendar
|
||||
import datetime
|
||||
from functools import total_ordering
|
||||
import random
|
||||
import six
|
||||
import uuid
|
||||
@@ -861,6 +862,7 @@ if six.PY3:
|
||||
long = int
|
||||
|
||||
|
||||
@total_ordering
|
||||
class Time(object):
|
||||
'''
|
||||
Idealized time, independent of day.
|
||||
@@ -985,6 +987,7 @@ class Time(object):
|
||||
self.second, self.nanosecond)
|
||||
|
||||
|
||||
@total_ordering
|
||||
class Date(object):
|
||||
'''
|
||||
Idealized date: year, month, day
|
||||
|
||||
Reference in New Issue
Block a user