Skip to content

Commit 1f0afd6

Browse files
author
Matt Land
committed
rename variables
1 parent 31fb576 commit 1f0afd6

5 files changed

Lines changed: 21 additions & 13 deletions

File tree

adafruit_imageload/pnm/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
3434

3535

3636
def load(file, header, *, bitmap=None, palette=None):
37-
# Read the header
37+
"""
38+
Scan for netpbm format info, skip over comments, and and delegate to a submodule
39+
to do the actual data loading.
40+
Formats P1, P4 have two space padded pieces of information: width and height.
41+
All other formats have three: width, height, and max color value.
42+
"""
3843
magic_number = header[:2]
3944
file.seek(2)
4045
pnm_header = []

adafruit_imageload/pnm/pgm/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def load(file, magic_number, header, *, bitmap=None, palette=None):
100100

101101

102102
def build_palette(palette_class, palette_colors):
103+
"""
104+
construct the Palette, and populate it with the set of palette_colors
105+
"""
103106
palette = palette_class(len(palette_colors))
104107
for counter, color in enumerate(palette_colors):
105108
palette[counter] = bytes([color, color, color])

adafruit_imageload/tests/test_pbm_load.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def test_load_works_p1_ascii(self):
2424
"images",
2525
"netpbm_p1_mono_ascii.pbm",
2626
)
27-
with open(test_file, "rb") as f:
27+
with open(test_file, "rb") as file:
2828
bitmap, palette = pnm.load(
29-
f, b"P1", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
29+
file, b"P1", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
3030
)
3131
self.assertTrue(isinstance(bitmap, Bitmap_C_Interface), bitmap)
3232
self.assertEqual(1, bitmap.colors)
@@ -57,9 +57,9 @@ def test_load_works_p4_binary(self):
5757
"images",
5858
"netpbm_p4_mono_binary.pbm",
5959
)
60-
with open(test_file, "rb") as f:
60+
with open(test_file, "rb") as file:
6161
bitmap, palette = pnm.load(
62-
f, b"P4", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
62+
file, b"P4", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
6363
)
6464
self.assertEqual(1, palette.num_colors)
6565
palette.validate()
@@ -79,9 +79,9 @@ def test_load_works_p4_binary_high_res(self):
7979
"images",
8080
"netpbm_p4_mono_large.pbm",
8181
)
82-
with open(test_file, "rb") as f:
82+
with open(test_file, "rb") as file:
8383
bitmap, palette = pnm.load(
84-
f, b"P4", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
84+
file, b"P4", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
8585
)
8686
self.assertTrue(isinstance(bitmap, Bitmap_C_Interface))
8787
self.assertEqual(1, bitmap.colors)

adafruit_imageload/tests/test_pgm_load.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def test_load_works_p2_ascii(self):
1414
"images",
1515
"netpbm_p2_ascii.pgm",
1616
)
17-
with open(test_file, "rb") as f:
17+
with open(test_file, "rb") as file:
1818
bitmap, palette = pnm.load(
19-
f, b"P2", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
19+
file, b"P2", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
2020
)
2121
self.assertTrue(isinstance(bitmap, Bitmap_C_Interface), bitmap)
2222
self.assertEqual(6, bitmap.colors)
@@ -36,9 +36,9 @@ def test_load_works_p5_binary(self):
3636
"images",
3737
"netpbm_p5_binary.pgm",
3838
)
39-
with open(test_file, "rb") as f:
39+
with open(test_file, "rb") as file:
4040
bitmap, palette = pnm.load(
41-
f, b"P5", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
41+
file, b"P5", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
4242
)
4343
self.assertTrue(isinstance(bitmap, Bitmap_C_Interface), bitmap)
4444

adafruit_imageload/tests/test_ppm_load.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def test_load_works_p6_binary(self):
3838
"images",
3939
"netpbm_p6_binary.ppm",
4040
)
41-
with open(test_file, "rb") as f:
41+
with open(test_file, "rb") as file:
4242
bitmap, palette = pnm.load(
43-
f, b"P6", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
43+
file, b"P6", bitmap=Bitmap_C_Interface, palette=Palette_C_Interface
4444
)
4545
self.assertEqual(6, palette.num_colors)
4646
palette.validate()

0 commit comments

Comments
 (0)