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 '--' # print '--'
# compile the patterns into regular expressions for speed # compile the patterns into regular expressions for speed
for i in range(len(patterns)): for i, pattern in enumerate(patterns):
p = patterns[i][0].replace('.', 'X').replace('X', '[01]') p = pattern[0].replace('.', 'X').replace('X', '[01]')
p = re.compile(p) p = re.compile(p)
patterns[i] = (p, patterns[i][1]) patterns[i] = (p, pattern[1])
# Step through table and find patterns that match. # Step through table and find patterns that match.
# Note that all the patterns are searched. The last one # 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 # so build a prototype image to be used for palette resampling
def build_prototype_image(): def build_prototype_image():
image = Image.new("L", (1, len(_Palm8BitColormapValues),)) image = Image.new("L", (1, len(_Palm8BitColormapValues)))
image.putdata(list(range(len(_Palm8BitColormapValues)))) image.putdata(list(range(len(_Palm8BitColormapValues))))
palettedata = () palettedata = ()
for i in range(len(_Palm8BitColormapValues)): for colormapValue in _Palm8BitColormapValues:
palettedata = palettedata + _Palm8BitColormapValues[i] palettedata += colormapValue
for i in range(256 - len(_Palm8BitColormapValues)): palettedata += (0, 0, 0)*(256 - len(_Palm8BitColormapValues))
palettedata = palettedata + (0, 0, 0)
image.putpalette(palettedata) image.putpalette(palettedata)
return image return image

View File

@ -1246,12 +1246,12 @@ class TiffImageFile(ImageFile.ImageFile):
a = None a = None
else: else:
for i in range(len(offsets)): for i, offset in enumerate(offsets):
a = self._decoder(rawmode, l, i) a = self._decoder(rawmode, l, 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)),
offsets[i], a)) offset, a))
if DEBUG: if DEBUG:
print("tiles: ", self.tile) print("tiles: ", self.tile)
y = y + h y = y + h