Skip to content

Commit 2cb93b7

Browse files
committed
Fixed duplicate-code failures
1 parent 883bbe9 commit 2cb93b7

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

adafruit_imageload/bmp/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def load(file, *, bitmap=None, palette=None):
3232
# bmp_header_length = int.from_bytes(file.read(4), 'little')
3333
# print(bmp_header_length)
3434
file.seek(0x12) # Width of the bitmap in pixels
35-
width = int.from_bytes(file.read(4), "little")
35+
_width = int.from_bytes(file.read(4), "little")
3636
try:
37-
height = int.from_bytes(file.read(4), "little")
37+
_height = int.from_bytes(file.read(4), "little")
3838
except OverflowError as error:
3939
raise NotImplementedError(
4040
"Negative height BMP files are not supported on builds without longint"
@@ -58,8 +58,8 @@ def load(file, *, bitmap=None, palette=None):
5858

5959
return indexed.load(
6060
file,
61-
width,
62-
height,
61+
_width,
62+
_height,
6363
data_start,
6464
colors,
6565
color_depth,

adafruit_imageload/pnm/pgm/ascii.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def load(file, width, height, bitmap=None, palette=None):
2121
Load a PGM ascii file (P2)
2222
"""
2323
data_start = file.tell() # keep this so we can rewind
24-
palette_colors = set()
24+
_palette_colors = set()
2525
pixel = bytearray()
2626
# build a set of all colors present in the file, so palette and bitmap can be constructed
2727
while True:
@@ -30,14 +30,14 @@ def load(file, width, height, bitmap=None, palette=None):
3030
break
3131
if not byte.isdigit():
3232
int_pixel = int("".join(["%c" % char for char in pixel]))
33-
palette_colors.add(int_pixel)
33+
_palette_colors.add(int_pixel)
3434
pixel = bytearray()
3535
pixel += byte
3636
if palette:
37-
palette = build_palette(palette, palette_colors)
37+
palette = build_palette(palette, _palette_colors)
3838
if bitmap:
39-
bitmap = bitmap(width, height, len(palette_colors))
40-
palette_colors = list(palette_colors)
39+
bitmap = bitmap(width, height, len(_palette_colors))
40+
_palette_colors = list(_palette_colors)
4141
file.seek(data_start)
4242
for y in range(height):
4343
for x in range(width):
@@ -48,11 +48,11 @@ def load(file, width, height, bitmap=None, palette=None):
4848
break
4949
pixel += byte
5050
int_pixel = int("".join(["%c" % char for char in pixel]))
51-
bitmap[x, y] = palette_colors.index(int_pixel)
51+
bitmap[x, y] = _palette_colors.index(int_pixel)
5252
return bitmap, palette
5353

5454

55-
def build_palette(palette_class, palette_colors):
55+
def build_palette(palette_class, palette_colors): # pylint: disable=duplicate-code
5656
"""
5757
construct the Palette, and populate it with the set of palette_colors
5858
"""

adafruit_imageload/pnm/pgm/binary.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def build_palette(palette_class, palette_colors):
4444
"""
4545
construct the Palette, and populate it with the set of palette_colors
4646
"""
47-
palette = palette_class(len(palette_colors))
47+
_palette = palette_class(len(palette_colors))
4848
for counter, color in enumerate(palette_colors):
49-
palette[counter] = bytes([color, color, color])
50-
return palette
49+
_palette[counter] = bytes([color, color, color])
50+
return _palette

0 commit comments

Comments
 (0)