mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-01 02:13:11 +03:00
Merge pull request #2551 from jdufresne/keys
Remove unnecessary calls to dict.keys()
This commit is contained in:
commit
c16ba722f2
|
@ -176,8 +176,8 @@ class IcoFile(object):
|
||||||
# figure out where AND mask image starts
|
# figure out where AND mask image starts
|
||||||
mode = a[0]
|
mode = a[0]
|
||||||
bpp = 8
|
bpp = 8
|
||||||
for k in BmpImagePlugin.BIT2MODE.keys():
|
for k, v in BmpImagePlugin.BIT2MODE.items():
|
||||||
if mode == BmpImagePlugin.BIT2MODE[k][1]:
|
if mode == v[1]:
|
||||||
bpp = k
|
bpp = k
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ def _conv_type_shape(im):
|
||||||
return shape+(extra,), typ
|
return shape+(extra,), typ
|
||||||
|
|
||||||
|
|
||||||
MODES = sorted(_MODEINFO.keys())
|
MODES = sorted(_MODEINFO)
|
||||||
|
|
||||||
# raw modes that may be memory mapped. NOTE: if you change this, you
|
# raw modes that may be memory mapped. NOTE: if you change this, you
|
||||||
# may have to modify the stride calculation in map.c too!
|
# may have to modify the stride calculation in map.c too!
|
||||||
|
|
|
@ -95,7 +95,7 @@ class IptcImageFile(ImageFile.ImageFile):
|
||||||
tagdata = self.fp.read(size)
|
tagdata = self.fp.read(size)
|
||||||
else:
|
else:
|
||||||
tagdata = None
|
tagdata = None
|
||||||
if tag in list(self.info.keys()):
|
if tag in self.info:
|
||||||
if isinstance(self.info[tag], list):
|
if isinstance(self.info[tag], list):
|
||||||
self.info[tag].append(tagdata)
|
self.info[tag].append(tagdata)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -439,7 +439,7 @@ class TestFileJpeg(PillowTestCase):
|
||||||
def test_no_duplicate_0x1001_tag(self):
|
def test_no_duplicate_0x1001_tag(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
from PIL import ExifTags
|
from PIL import ExifTags
|
||||||
tag_ids = dict(zip(ExifTags.TAGS.values(), ExifTags.TAGS.keys()))
|
tag_ids = {v: k for k, v in ExifTags.TAGS.items()}
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(tag_ids['RelatedImageWidth'], 0x1001)
|
self.assertEqual(tag_ids['RelatedImageWidth'], 0x1001)
|
||||||
|
|
|
@ -189,7 +189,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
# Exclude ones that have special meaning
|
# Exclude ones that have special meaning
|
||||||
# that we're already testing them
|
# that we're already testing them
|
||||||
im = Image.open('Tests/images/hopper_g4.tif')
|
im = Image.open('Tests/images/hopper_g4.tif')
|
||||||
for tag in im.tag_v2.keys():
|
for tag in im.tag_v2:
|
||||||
try:
|
try:
|
||||||
del(core_items[tag])
|
del(core_items[tag])
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -119,7 +119,7 @@ class TestImageColor(PillowTestCase):
|
||||||
# look for rounding errors (based on code by Tim Hatch)
|
# look for rounding errors (based on code by Tim Hatch)
|
||||||
def test_rounding_errors(self):
|
def test_rounding_errors(self):
|
||||||
|
|
||||||
for color in list(ImageColor.colormap.keys()):
|
for color in ImageColor.colormap:
|
||||||
expected = Image.new(
|
expected = Image.new(
|
||||||
"RGB", (1, 1), color).convert("L").getpixel((0, 0))
|
"RGB", (1, 1), color).convert("L").getpixel((0, 0))
|
||||||
actual = ImageColor.getcolor(color, 'L')
|
actual = ImageColor.getcolor(color, 'L')
|
||||||
|
|
|
@ -12,7 +12,7 @@ from config import (compilers, compiler_from_env, pythons, pyversion_from_env,
|
||||||
|
|
||||||
def setup_vms():
|
def setup_vms():
|
||||||
ret = []
|
ret = []
|
||||||
for py in pythons.keys():
|
for py in pythons:
|
||||||
for arch in ('', X64_EXT):
|
for arch in ('', X64_EXT):
|
||||||
ret.append("virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s"
|
ret.append("virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s"
|
||||||
% (py, arch, VIRT_BASE, py, arch))
|
% (py, arch, VIRT_BASE, py, arch))
|
||||||
|
|
|
@ -116,7 +116,7 @@ def pyversion_from_env():
|
||||||
py = os.environ['PYTHON']
|
py = os.environ['PYTHON']
|
||||||
|
|
||||||
py_version = '27'
|
py_version = '27'
|
||||||
for k in pythons.keys():
|
for k in pythons:
|
||||||
if k in py:
|
if k in py:
|
||||||
py_version = k
|
py_version = k
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user