Minor PEP-8 fixes
This commit is contained in:
@@ -51,16 +51,19 @@ try:
|
||||
except ImportError: # Python <2.7
|
||||
from cassandra.util import OrderedDict # NOQA
|
||||
|
||||
|
||||
def trim_if_startswith(s, prefix):
|
||||
if s.startswith(prefix):
|
||||
return s[len(prefix):]
|
||||
return s
|
||||
|
||||
|
||||
def unix_time_from_uuid1(u):
|
||||
return (u.get_time() - 0x01B21DD213814000) / 10000000.0
|
||||
|
||||
_casstypes = {}
|
||||
|
||||
|
||||
class CassandraTypeType(type):
|
||||
"""
|
||||
The CassandraType objects in this module will normally be used directly,
|
||||
@@ -391,6 +394,7 @@ class IntegerType(_CassandraType):
|
||||
|
||||
have_ipv6_packing = hasattr(socket, 'inet_ntop')
|
||||
|
||||
|
||||
class InetAddressType(_CassandraType):
|
||||
typename = 'inet'
|
||||
|
||||
@@ -482,6 +486,7 @@ class DateType(_CassandraType):
|
||||
|
||||
return int64_pack(long(converted))
|
||||
|
||||
|
||||
class TimeUUIDType(DateType):
|
||||
typename = 'timeuuid'
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ from cassandra.cqltypes import (AsciiType, BytesType, BooleanType,
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NotSupportedError(Exception):
|
||||
pass
|
||||
|
||||
@@ -75,6 +76,7 @@ def ordered_dict_factory(colnames, rows):
|
||||
_message_types_by_name = {}
|
||||
_message_types_by_opcode = {}
|
||||
|
||||
|
||||
class _register_msg_type(type):
|
||||
def __init__(cls, name, bases, dct):
|
||||
if not name.startswith('_'):
|
||||
|
||||
@@ -38,6 +38,7 @@ _loop.unref()
|
||||
_loop_started = None
|
||||
_loop_lock = Lock()
|
||||
|
||||
|
||||
def _run_loop():
|
||||
while True:
|
||||
end_condition = _loop.start()
|
||||
@@ -53,6 +54,7 @@ def _run_loop():
|
||||
_loop_started = False
|
||||
break
|
||||
|
||||
|
||||
def _start_loop():
|
||||
global _loop_started
|
||||
should_start = False
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import struct
|
||||
|
||||
|
||||
def _make_packer(format_string):
|
||||
try:
|
||||
packer = struct.Struct(format_string) # new in Python 2.5
|
||||
packer = struct.Struct(format_string) # new in Python 2.5
|
||||
except AttributeError:
|
||||
pack = lambda x: struct.pack(format_string, x)
|
||||
unpack = lambda s: struct.unpack(format_string, s)
|
||||
@@ -22,12 +23,14 @@ uint8_pack, uint8_unpack = _make_packer('>B')
|
||||
float_pack, float_unpack = _make_packer('>f')
|
||||
double_pack, double_unpack = _make_packer('>d')
|
||||
|
||||
|
||||
def varint_unpack(term):
|
||||
val = int(term.encode('hex'), 16)
|
||||
if (ord(term[0]) & 128) != 0:
|
||||
val = val - (1 << (len(term) * 8))
|
||||
return val
|
||||
|
||||
|
||||
def bitlength(n):
|
||||
bitlen = 0
|
||||
while n > 0:
|
||||
@@ -35,6 +38,7 @@ def bitlength(n):
|
||||
bitlen += 1
|
||||
return bitlen
|
||||
|
||||
|
||||
def varint_pack(big):
|
||||
pos = True
|
||||
if big == 0:
|
||||
|
||||
@@ -425,6 +425,7 @@ class SimpleStrategy(ReplicationStrategy):
|
||||
|
||||
return self.replication_factor == other.replication_factor
|
||||
|
||||
|
||||
class NetworkTopologyStrategy(ReplicationStrategy):
|
||||
|
||||
name = "NetworkTopologyStrategy"
|
||||
@@ -500,6 +501,7 @@ class NetworkTopologyStrategy(ReplicationStrategy):
|
||||
|
||||
return self.dc_replication_factors == other.dc_replication_factors
|
||||
|
||||
|
||||
class LocalStrategy(ReplicationStrategy):
|
||||
|
||||
name = "LocalStrategy"
|
||||
|
||||
@@ -5,6 +5,7 @@ from greplin import scales
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Metrics(object):
|
||||
|
||||
request_timer = None
|
||||
|
||||
@@ -6,6 +6,7 @@ from cassandra import ConsistencyLevel
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HostDistance(object):
|
||||
"""
|
||||
A measure of how "distant" a node is from the client, which
|
||||
|
||||
@@ -13,6 +13,7 @@ from cassandra.cqltypes import unix_time_from_uuid1
|
||||
from cassandra.decoder import (cql_encoders, cql_encode_object,
|
||||
cql_encode_sequence)
|
||||
|
||||
|
||||
class Statement(object):
|
||||
"""
|
||||
An abstract class representing a single query. There are two subclasses:
|
||||
|
||||
@@ -26,6 +26,7 @@ from __future__ import with_statement
|
||||
|
||||
from UserDict import DictMixin
|
||||
|
||||
|
||||
class OrderedDict(dict, DictMixin):
|
||||
""" A dictionary which maintains the insertion order of keys. """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user