@@ -21,7 +21,7 @@ def load(file, width, height, bitmap=None, palette=None):
21
21
Load a PGM ascii file (P2)
22
22
"""
23
23
data_start = file .tell () # keep this so we can rewind
24
- palette_colors = set ()
24
+ _palette_colors = set ()
25
25
pixel = bytearray ()
26
26
# build a set of all colors present in the file, so palette and bitmap can be constructed
27
27
while True :
@@ -30,14 +30,14 @@ def load(file, width, height, bitmap=None, palette=None):
30
30
break
31
31
if not byte .isdigit ():
32
32
int_pixel = int ("" .join (["%c" % char for char in pixel ]))
33
- palette_colors .add (int_pixel )
33
+ _palette_colors .add (int_pixel )
34
34
pixel = bytearray ()
35
35
pixel += byte
36
36
if palette :
37
- palette = build_palette (palette , palette_colors )
37
+ palette = build_palette (palette , _palette_colors )
38
38
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 )
41
41
file .seek (data_start )
42
42
for y in range (height ):
43
43
for x in range (width ):
@@ -48,11 +48,11 @@ def load(file, width, height, bitmap=None, palette=None):
48
48
break
49
49
pixel += byte
50
50
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 )
52
52
return bitmap , palette
53
53
54
54
55
- def build_palette (palette_class , palette_colors ):
55
+ def build_palette (palette_class , palette_colors ): # pylint: disable=duplicate-code
56
56
"""
57
57
construct the Palette, and populate it with the set of palette_colors
58
58
"""
0 commit comments