Ambiguous variable name 'l'

This commit is contained in:
Andrew Murray 2018-06-15 23:44:22 +10:00
parent e7cfa15216
commit 145589ef14
5 changed files with 48 additions and 46 deletions

View File

@ -67,13 +67,13 @@ class TestImageConvert(PillowTestCase):
f = self.tempfile('temp.png') f = self.tempfile('temp.png')
l = im.convert('L') im_l = im.convert('L')
self.assertEqual(l.info['transparency'], 0) # undone self.assertEqual(im_l.info['transparency'], 0) # undone
l.save(f) im_l.save(f)
rgb = im.convert('RGB') im_rgb = im.convert('RGB')
self.assertEqual(rgb.info['transparency'], (0, 0, 0)) # undone self.assertEqual(im_rgb.info['transparency'], (0, 0, 0)) # undone
rgb.save(f) im_rgb.save(f)
# ref https://github.com/python-pillow/Pillow/issues/664 # ref https://github.com/python-pillow/Pillow/issues/664
@ -83,12 +83,12 @@ class TestImageConvert(PillowTestCase):
im.info['transparency'] = 128 im.info['transparency'] = 128
# Act # Act
rgba = im.convert('RGBA') im_rgba = im.convert('RGBA')
# Assert # Assert
self.assertNotIn('transparency', rgba.info) self.assertNotIn('transparency', im_rgba.info)
# https://github.com/python-pillow/Pillow/issues/2702 # https://github.com/python-pillow/Pillow/issues/2702
self.assertEqual(rgba.palette, None) self.assertEqual(im_rgba.palette, None)
def test_trns_l(self): def test_trns_l(self):
im = hopper('L') im = hopper('L')
@ -96,19 +96,20 @@ class TestImageConvert(PillowTestCase):
f = self.tempfile('temp.png') f = self.tempfile('temp.png')
rgb = im.convert('RGB') im_rgb = im.convert('RGB')
self.assertEqual(rgb.info['transparency'], (128, 128, 128)) # undone self.assertEqual(im_rgb.info['transparency'],
rgb.save(f) (128, 128, 128)) # undone
im_rgb.save(f)
p = im.convert('P') im_p = im.convert('P')
self.assertIn('transparency', p.info) self.assertIn('transparency', im_p.info)
p.save(f) im_p.save(f)
p = self.assert_warning( im_p = self.assert_warning(
UserWarning, UserWarning,
im.convert, 'P', palette=Image.ADAPTIVE) im.convert, 'P', palette=Image.ADAPTIVE)
self.assertNotIn('transparency', p.info) self.assertNotIn('transparency', im_p.info)
p.save(f) im_p.save(f)
def test_trns_RGB(self): def test_trns_RGB(self):
im = hopper('RGB') im = hopper('RGB')
@ -116,23 +117,24 @@ class TestImageConvert(PillowTestCase):
f = self.tempfile('temp.png') f = self.tempfile('temp.png')
l = im.convert('L') im_l = im.convert('L')
self.assertEqual(l.info['transparency'], l.getpixel((0, 0))) # undone self.assertEqual(im_l.info['transparency'],
l.save(f) im_l.getpixel((0, 0))) # undone
im_l.save(f)
p = im.convert('P') im_p = im.convert('P')
self.assertIn('transparency', p.info) self.assertIn('transparency', im_p.info)
p.save(f) im_p.save(f)
p = im.convert('RGBA') im_rgba = im.convert('RGBA')
self.assertNotIn('transparency', p.info) self.assertNotIn('transparency', im_rgba.info)
p.save(f) im_rgba.save(f)
p = self.assert_warning( im_p = self.assert_warning(
UserWarning, UserWarning,
im.convert, 'P', palette=Image.ADAPTIVE) im.convert, 'P', palette=Image.ADAPTIVE)
self.assertNotIn('transparency', p.info) self.assertNotIn('transparency', im_p.info)
p.save(f) im_p.save(f)
def test_p_la(self): def test_p_la(self):
im = hopper('RGBA') im = hopper('RGBA')

View File

@ -196,13 +196,13 @@ class TestImageCms(PillowTestCase):
# not a linear luminance map. so L != 128: # not a linear luminance map. so L != 128:
self.assertEqual(k, (137, 128, 128)) self.assertEqual(k, (137, 128, 128))
l = i_lab.getdata(0) l_data = i_lab.getdata(0)
a = i_lab.getdata(1) a_data = i_lab.getdata(1)
b = i_lab.getdata(2) b_data = i_lab.getdata(2)
self.assertEqual(list(l), [137] * 100) self.assertEqual(list(l_data), [137] * 100)
self.assertEqual(list(a), [128] * 100) self.assertEqual(list(a_data), [128] * 100)
self.assertEqual(list(b), [128] * 100) self.assertEqual(list(b_data), [128] * 100)
def test_lab_color(self): def test_lab_color(self):
psRGB = ImageCms.createProfile("sRGB") psRGB = ImageCms.createProfile("sRGB")

View File

@ -107,10 +107,10 @@ class ContainerIO(object):
:returns: A list of 8-bit strings. :returns: A list of 8-bit strings.
""" """
l = [] lines = []
while True: while True:
s = self.readline() s = self.readline()
if not s: if not s:
break break
l.append(s) lines.append(s)
return l return lines

View File

@ -110,11 +110,11 @@ class Stat(object):
v = [] v = []
for i in self.bands: for i in self.bands:
s = 0 s = 0
l = self.count[i]//2 half = self.count[i]//2
b = i * 256 b = i * 256
for j in range(256): for j in range(256):
s = s + self.h[b+j] s = s + self.h[b+j]
if s > l: if s > half:
break break
v.append(j) v.append(j)
return v return v

View File

@ -1245,7 +1245,7 @@ class TiffImageFile(ImageFile.ImageFile):
self.info["resolution"] = xres, yres self.info["resolution"] = xres, yres
# build tile descriptors # build tile descriptors
x = y = l = 0 x = y = layer = 0
self.tile = [] self.tile = []
self.use_load_libtiff = False self.use_load_libtiff = False
if STRIPOFFSETS in self.tag_v2: if STRIPOFFSETS in self.tag_v2:
@ -1305,7 +1305,7 @@ class TiffImageFile(ImageFile.ImageFile):
else: else:
for i, offset in enumerate(offsets): for i, offset in enumerate(offsets):
a = self._decoder(rawmode, l, i) a = self._decoder(rawmode, layer, i)
self.tile.append( self.tile.append(
(self._compression, (self._compression,
(0, min(y, ysize), w, min(y+h, ysize)), (0, min(y, ysize), w, min(y+h, ysize)),
@ -1315,7 +1315,7 @@ class TiffImageFile(ImageFile.ImageFile):
y = y + h y = y + h
if y >= self.size[1]: if y >= self.size[1]:
x = y = 0 x = y = 0
l += 1 layer += 1
a = None a = None
elif TILEOFFSETS in self.tag_v2: elif TILEOFFSETS in self.tag_v2:
# tiled image # tiled image
@ -1324,7 +1324,7 @@ class TiffImageFile(ImageFile.ImageFile):
a = None a = None
for o in self.tag_v2[TILEOFFSETS]: for o in self.tag_v2[TILEOFFSETS]:
if not a: if not a:
a = self._decoder(rawmode, l) a = self._decoder(rawmode, layer)
# FIXME: this doesn't work if the image size # FIXME: this doesn't work if the image size
# is not a multiple of the tile size... # is not a multiple of the tile size...
self.tile.append( self.tile.append(
@ -1336,7 +1336,7 @@ class TiffImageFile(ImageFile.ImageFile):
x, y = 0, y + h x, y = 0, y + h
if y >= self.size[1]: if y >= self.size[1]:
x = y = 0 x = y = 0
l += 1 layer += 1
a = None a = None
else: else:
if DEBUG: if DEBUG: