Replaced range(len())

This commit is contained in:
Andrew Murray 2016-11-06 12:38:59 +11:00
parent 5aeb0ed972
commit 8fc90fe4fa
3 changed files with 9 additions and 10 deletions

View File

@ -156,10 +156,10 @@ class LutBuilder(object):
# print '--'
# compile the patterns into regular expressions for speed
for i in range(len(patterns)):
p = patterns[i][0].replace('.', 'X').replace('X', '[01]')
for i, pattern in enumerate(patterns):
p = pattern[0].replace('.', 'X').replace('X', '[01]')
p = re.compile(p)
patterns[i] = (p, patterns[i][1])
patterns[i] = (p, pattern[1])
# Step through table and find patterns that match.
# Note that all the patterns are searched. The last one

View File

@ -80,13 +80,12 @@ _Palm8BitColormapValues = (
# so build a prototype image to be used for palette resampling
def build_prototype_image():
image = Image.new("L", (1, len(_Palm8BitColormapValues),))
image = Image.new("L", (1, len(_Palm8BitColormapValues)))
image.putdata(list(range(len(_Palm8BitColormapValues))))
palettedata = ()
for i in range(len(_Palm8BitColormapValues)):
palettedata = palettedata + _Palm8BitColormapValues[i]
for i in range(256 - len(_Palm8BitColormapValues)):
palettedata = palettedata + (0, 0, 0)
for colormapValue in _Palm8BitColormapValues:
palettedata += colormapValue
palettedata += (0, 0, 0)*(256 - len(_Palm8BitColormapValues))
image.putpalette(palettedata)
return image

View File

@ -1246,12 +1246,12 @@ class TiffImageFile(ImageFile.ImageFile):
a = None
else:
for i in range(len(offsets)):
for i, offset in enumerate(offsets):
a = self._decoder(rawmode, l, i)
self.tile.append(
(self._compression,
(0, min(y, ysize), w, min(y+h, ysize)),
offsets[i], a))
offset, a))
if DEBUG:
print("tiles: ", self.tile)
y = y + h