Skip to content

Commit 8b05e62

Browse files
Vetoshkin Nikitamumrah
authored andcommitted
style: fix camelCase variable names
Conflicts: kafka/util.py
1 parent e392e0c commit 8b05e62

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

kafka/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ def _load_metadata_for_topics(self, *topics):
6161
Discover brokers and metadata for a set of topics. This method will
6262
recurse in the event of a retry.
6363
"""
64-
requestId = self._next_id()
64+
request_id = self._next_id()
6565
request = KafkaProtocol.encode_metadata_request(self.client_id,
66-
requestId, topics)
66+
request_id, topics)
6767

68-
response = self._send_broker_unaware_request(requestId, request)
68+
response = self._send_broker_unaware_request(request_id, request)
6969
if response is None:
7070
raise Exception("All servers failed to process request")
7171

kafka/conn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def send(self, requestId, payload):
7979
if sent != None:
8080
raise RuntimeError("Kafka went away")
8181

82-
def recv(self, requestId):
82+
def recv(self, request_id):
8383
"""
8484
Get a response from Kafka
8585
"""
86-
log.debug("Reading response %d from Kafka" % requestId)
86+
log.debug("Reading response %d from Kafka" % request_id)
8787
self.data = self._consume_response()
8888
return self.data
8989

kafka/protocol.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -361,43 +361,43 @@ def decode_metadata_response(cls, data):
361361
======
362362
data: bytes to decode
363363
"""
364-
((correlation_id, numBrokers), cur) = relative_unpack('>ii', data, 0)
364+
((correlation_id, numbrokers), cur) = relative_unpack('>ii', data, 0)
365365

366366
# Broker info
367367
brokers = {}
368-
for i in range(numBrokers):
368+
for i in range(numbrokers):
369369
((nodeId, ), cur) = relative_unpack('>i', data, cur)
370370
(host, cur) = read_short_string(data, cur)
371371
((port,), cur) = relative_unpack('>i', data, cur)
372372
brokers[nodeId] = BrokerMetadata(nodeId, host, port)
373373

374374
# Topic info
375375
((num_topics,), cur) = relative_unpack('>i', data, cur)
376-
topicMetadata = {}
376+
topic_metadata = {}
377377

378378
for i in range(num_topics):
379-
((topicError,), cur) = relative_unpack('>h', data, cur)
380-
(topicName, cur) = read_short_string(data, cur)
379+
((topic_error,), cur) = relative_unpack('>h', data, cur)
380+
(topic_name, cur) = read_short_string(data, cur)
381381
((num_partitions,), cur) = relative_unpack('>i', data, cur)
382-
partitionMetadata = {}
382+
partition_metadata = {}
383383

384384
for j in range(num_partitions):
385-
((partitionErrorCode, partition, leader, numReplicas), cur) = \
385+
((partition_error_code, partition, leader, numReplicas), cur) = \
386386
relative_unpack('>hiii', data, cur)
387387

388388
(replicas, cur) = relative_unpack('>%di' % numReplicas,
389389
data, cur)
390390

391-
((numIsr,), cur) = relative_unpack('>i', data, cur)
392-
(isr, cur) = relative_unpack('>%di' % numIsr, data, cur)
391+
((num_isr,), cur) = relative_unpack('>i', data, cur)
392+
(isr, cur) = relative_unpack('>%di' % num_isr, data, cur)
393393

394-
partitionMetadata[partition] = \
395-
PartitionMetadata(topicName, partition, leader,
394+
partition_metadata[partition] = \
395+
PartitionMetadata(topic_name, partition, leader,
396396
replicas, isr)
397397

398-
topicMetadata[topicName] = partitionMetadata
398+
topic_metadata[topic_name] = partition_metadata
399399

400-
return (brokers, topicMetadata)
400+
return (brokers, topic_metadata)
401401

402402
@classmethod
403403
def encode_offset_commit_request(cls, client_id, correlation_id,

kafka/util.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,33 @@ def read_short_string(data, cur):
2424
if len(data) < cur + 2:
2525
raise BufferUnderflowError("Not enough data left")
2626

27-
(strLen,) = struct.unpack('>h', data[cur:cur + 2])
28-
if strLen == -1:
27+
(strlen,) = struct.unpack('>h', data[cur:cur + 2])
28+
if strlen == -1:
2929
return (None, cur + 2)
3030

3131
cur += 2
32-
if len(data) < cur + strLen:
32+
if len(data) < cur + strlen:
3333
raise BufferUnderflowError("Not enough data left")
3434

35-
out = data[cur:cur + strLen]
36-
return (out, cur + strLen)
35+
out = data[cur:cur + strlen]
36+
return (out, cur + strlen)
3737

3838

3939
def read_int_string(data, cur):
4040
if len(data) < cur + 4:
4141
raise BufferUnderflowError(
4242
"Not enough data left to read string len (%d < %d)" % (len(data), cur + 4))
4343

44-
(strLen,) = struct.unpack('>i', data[cur:cur + 4])
45-
if strLen == -1:
44+
(strlen,) = struct.unpack('>i', data[cur:cur + 4])
45+
if strlen == -1:
4646
return (None, cur + 4)
4747

4848
cur += 4
49-
if len(data) < cur + strLen:
50-
raise BufferUnderflowError(
51-
"Not enough data left to read string (%d < %d)" % (len(data), cur + strLen))
49+
if len(data) < cur + strlen:
50+
raise BufferUnderflowError("Not enough data left")
5251

53-
out = data[cur:cur + strLen]
54-
return (out, cur + strLen)
52+
out = data[cur:cur + strlen]
53+
return (out, cur + strlen)
5554

5655

5756
def relative_unpack(fmt, data, cur):

0 commit comments

Comments
 (0)