Skip to content

Commit b1bc7fc

Browse files
author
devoh747
authored
More pylint fixes
1 parent e385886 commit b1bc7fc

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

adafruit_sdcard.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _cmd(self, cmd, arg=0, crc=0, response_buf=None, data_block=True, wait=True)
236236
buf[4] = arg & 0xff
237237

238238
if (crc == 0):
239-
buf[5] = self.calculate_crc(buf[:-1])
239+
buf[5] = calculate_crc(buf[:-1])
240240
else:
241241
buf[5] = crc
242242

@@ -287,7 +287,7 @@ def _block_cmd(self, cmd, block, crc, response_buf=None):
287287
buf[4] = 0
288288

289289
if (crc == 0):
290-
buf[5] = self.calculate_crc(buf[:-1])
290+
buf[5] = calculate_crc(buf[:-1])
291291
else:
292292
buf[5] = crc
293293

@@ -456,32 +456,32 @@ def writeblocks(self, start_block, buf):
456456
self._cmd_nodata(_TOKEN_STOP_TRAN, 0x0)
457457
return 0
458458

459-
def calculate_crc(self, message):
460-
"""
461-
Calculate the CRC of a message.
462-
:param bytearray message: Where each index is a byte
463-
"""
459+
def calculate_crc(message):
460+
"""
461+
Calculate the CRC of a message.
462+
:param bytearray message: Where each index is a byte
463+
"""
464464
# Code converted from https://github.com/hazelnusse/crc7/blob/master/crc7.cc by devoh747
465465
# With permission from Dale Lukas Peterson <hazelnusse@gmail.com>
466466
# 8/6/2019
467467

468-
crc_table = bytearray(256)
468+
crc_table = bytearray(256)
469469

470-
crc_poly = const(0x89) # the value of our CRC-7 polynomial
470+
crc_poly = const(0x89) # the value of our CRC-7 polynomial
471471

472-
# generate a table value for all 256 possible byte values
473-
for i in range(256):
474-
if (i & 0x80):
475-
crc_table[i] = i ^ crc_poly
476-
else:
477-
crc_table[i] = i
478-
for _ in range(1, 8):
479-
crc_table[i] = crc_table[i] << 1
480-
if (crc_table[i] & 0x80):
481-
crc_table[i] = crc_table[i] ^ crc_poly
472+
# generate a table value for all 256 possible byte values
473+
for i in range(256):
474+
if (i & 0x80):
475+
crc_table[i] = i ^ crc_poly
476+
else:
477+
crc_table[i] = i
478+
for _ in range(1, 8):
479+
crc_table[i] = crc_table[i] << 1
480+
if (crc_table[i] & 0x80):
481+
crc_table[i] = crc_table[i] ^ crc_poly
482482

483-
crc = 0
484-
for i in range(len(message)):
485-
crc = crc_table[(crc << 1) ^ message[i]]
483+
crc = 0
484+
for i in range(len(message)):
485+
crc = crc_table[(crc << 1) ^ message[i]]
486486

487-
return ((crc << 1) | 1)
487+
return ((crc << 1) | 1)

0 commit comments

Comments
 (0)