diff options
author | Jeff Widman <jeff@jeffwidman.com> | 2018-10-22 01:24:50 -0700 |
---|---|---|
committer | Jeff Widman <jeff@jeffwidman.com> | 2018-10-22 14:30:33 -0700 |
commit | b83feeca2ec6f6ad745fb7ea47c6484304bb55d8 (patch) | |
tree | 7580e387521b388f3af629b9d25278faa26ee349 /kafka | |
parent | a6be21e7b3a20ce2e25ef26140c43b59cc356f38 (diff) | |
download | kafka-python-b83feeca2ec6f6ad745fb7ea47c6484304bb55d8.tar.gz |
Vendor `six` consistently
Use vendored `six`, and also `six.moves.range` rather than `xrange`
Diffstat (limited to 'kafka')
-rw-r--r-- | kafka/codec.py | 4 | ||||
-rw-r--r-- | kafka/producer/simple.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/kafka/codec.py b/kafka/codec.py index 4d180dd..aa9fc82 100644 --- a/kafka/codec.py +++ b/kafka/codec.py @@ -6,7 +6,7 @@ import platform import struct from kafka.vendor import six -from kafka.vendor.six.moves import xrange # pylint: disable=import-error +from kafka.vendor.six.moves import range _XERIAL_V1_HEADER = (-126, b'S', b'N', b'A', b'P', b'P', b'Y', 0, 1, 1) _XERIAL_V1_FORMAT = 'bccccccBii' @@ -150,7 +150,7 @@ def snappy_encode(payload, xerial_compatible=True, xerial_blocksize=32*1024): chunker = lambda payload, i, size: memoryview(payload)[i:size+i].tobytes() for chunk in (chunker(payload, i, xerial_blocksize) - for i in xrange(0, len(payload), xerial_blocksize)): + for i in range(0, len(payload), xerial_blocksize)): block = snappy.compress(chunk) block_size = len(block) diff --git a/kafka/producer/simple.py b/kafka/producer/simple.py index 91e0abc..e06e659 100644 --- a/kafka/producer/simple.py +++ b/kafka/producer/simple.py @@ -4,7 +4,7 @@ from itertools import cycle import logging import random -from kafka.vendor.six.moves import xrange # pylint: disable=import-error +from kafka.vendor.six.moves import range from kafka.producer.base import Producer @@ -39,7 +39,7 @@ class SimpleProducer(Producer): # Randomize the initial partition that is returned if self.random_start: num_partitions = len(self.client.get_partition_ids_for_topic(topic)) - for _ in xrange(random.randint(0, num_partitions-1)): + for _ in range(random.randint(0, num_partitions-1)): next(self.partition_cycles[topic]) return next(self.partition_cycles[topic]) |