mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Flake8 fixes
This commit is contained in:
parent
b9a05b8516
commit
72d5218080
|
@ -883,7 +883,7 @@ class Image(object):
|
||||||
try:
|
try:
|
||||||
t = trns_im.palette.getcolor(t)
|
t = trns_im.palette.getcolor(t)
|
||||||
except:
|
except:
|
||||||
raise ValueError("Couldn't allocate a palette "+
|
raise ValueError("Couldn't allocate a palette " +
|
||||||
"color for transparency")
|
"color for transparency")
|
||||||
trns_im.putpixel((0, 0), t)
|
trns_im.putpixel((0, 0), t)
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,7 @@ def _save(im, fp, tile, bufsize=0):
|
||||||
e.setimage(im.im, b)
|
e.setimage(im.im, b)
|
||||||
if e.pushes_fd:
|
if e.pushes_fd:
|
||||||
e.setfd(fp)
|
e.setfd(fp)
|
||||||
l,s = e.encode_to_pyfd()
|
l, s = e.encode_to_pyfd()
|
||||||
else:
|
else:
|
||||||
while True:
|
while True:
|
||||||
l, s, d = e.encode(bufsize)
|
l, s, d = e.encode(bufsize)
|
||||||
|
@ -492,7 +492,7 @@ def _save(im, fp, tile, bufsize=0):
|
||||||
e.setimage(im.im, b)
|
e.setimage(im.im, b)
|
||||||
if e.pushes_fd:
|
if e.pushes_fd:
|
||||||
e.setfd(fp)
|
e.setfd(fp)
|
||||||
l,s = e.encode_to_pyfd()
|
l, s = e.encode_to_pyfd()
|
||||||
else:
|
else:
|
||||||
s = e.encode_to_file(fh, bufsize)
|
s = e.encode_to_file(fh, bufsize)
|
||||||
if s < 0:
|
if s < 0:
|
||||||
|
|
|
@ -169,7 +169,7 @@ TAGS_V2 = {
|
||||||
45056: ("MPFVersion", UNDEFINED, 1),
|
45056: ("MPFVersion", UNDEFINED, 1),
|
||||||
45057: ("NumberOfImages", LONG, 1),
|
45057: ("NumberOfImages", LONG, 1),
|
||||||
45058: ("MPEntry", UNDEFINED, 1),
|
45058: ("MPEntry", UNDEFINED, 1),
|
||||||
45059: ("ImageUIDList", UNDEFINED, 0), # UNDONE, check
|
45059: ("ImageUIDList", UNDEFINED, 0), # UNDONE, check
|
||||||
45060: ("TotalFrames", LONG, 1),
|
45060: ("TotalFrames", LONG, 1),
|
||||||
45313: ("MPIndividualNum", LONG, 1),
|
45313: ("MPIndividualNum", LONG, 1),
|
||||||
45569: ("PanOrientation", LONG, 1),
|
45569: ("PanOrientation", LONG, 1),
|
||||||
|
|
|
@ -32,6 +32,7 @@ for r in range(8):
|
||||||
for b in range(4):
|
for b in range(4):
|
||||||
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
|
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
|
||||||
|
|
||||||
|
|
||||||
def _accept(prefix):
|
def _accept(prefix):
|
||||||
return prefix[:6] == _MAGIC
|
return prefix[:6] == _MAGIC
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ if hasattr(sys, 'pypy_find_executable'):
|
||||||
# Tested with packages at https://bitbucket.org/pypy/pypy/downloads.
|
# Tested with packages at https://bitbucket.org/pypy/pypy/downloads.
|
||||||
# PyPies 1.6, 2.0 do not have tkinter built in. PyPy3-2.3.1 gives an
|
# PyPies 1.6, 2.0 do not have tkinter built in. PyPy3-2.3.1 gives an
|
||||||
# OSError trying to import tkinter. Otherwise:
|
# OSError trying to import tkinter. Otherwise:
|
||||||
try: # PyPy 5.1, 4.0.0, 2.6.1, 2.6.0
|
try: # PyPy 5.1, 4.0.0, 2.6.1, 2.6.0
|
||||||
TKINTER_LIB = tk.tklib_cffi.__file__
|
TKINTER_LIB = tk.tklib_cffi.__file__
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# PyPy3 2.4, 2.1-beta1; PyPy 2.5.1, 2.5.0, 2.4.0, 2.3, 2.2, 2.1
|
# PyPy3 2.4, 2.1-beta1; PyPy 2.5.1, 2.5.0, 2.4.0, 2.3, 2.2, 2.1
|
||||||
|
|
|
@ -71,7 +71,6 @@ class TestFileEps(PillowTestCase):
|
||||||
target = Image.open('Tests/images/pil_sample_rgb.jpg')
|
target = Image.open('Tests/images/pil_sample_rgb.jpg')
|
||||||
self.assert_image_similar(cmyk_image, target, 10)
|
self.assert_image_similar(cmyk_image, target, 10)
|
||||||
|
|
||||||
|
|
||||||
def test_file_object(self):
|
def test_file_object(self):
|
||||||
# issue 479
|
# issue 479
|
||||||
image1 = Image.open(file1)
|
image1 = Image.open(file1)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class TestFileJpeg2k(PillowTestCase):
|
||||||
|
|
||||||
im = Image.open('Tests/images/test-card-lossless.jp2')
|
im = Image.open('Tests/images/test-card-lossless.jp2')
|
||||||
px = im.load()
|
px = im.load()
|
||||||
self.assertEqual(px[0,0], (0, 0, 0))
|
self.assertEqual(px[0, 0], (0, 0, 0))
|
||||||
self.assertEqual(im.mode, 'RGB')
|
self.assertEqual(im.mode, 'RGB')
|
||||||
self.assertEqual(im.size, (640, 480))
|
self.assertEqual(im.size, (640, 480))
|
||||||
self.assertEqual(im.format, 'JPEG2000')
|
self.assertEqual(im.format, 'JPEG2000')
|
||||||
|
|
|
@ -48,7 +48,7 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
|
||||||
rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)
|
rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)
|
||||||
rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), color)
|
rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), color)
|
||||||
|
|
||||||
return Image.merge(mode, [case] * len(mode))
|
return Image.merge(mode, [case] * len(mode))
|
||||||
|
|
||||||
def make_sample(self, data, size):
|
def make_sample(self, data, size):
|
||||||
"""Restores a sample image from given data string which contains
|
"""Restores a sample image from given data string which contains
|
||||||
|
|
|
@ -264,6 +264,7 @@ class TestImageCms(PillowTestCase):
|
||||||
# Helper function to reduce precision of tuples of floats
|
# Helper function to reduce precision of tuples of floats
|
||||||
# recursively and then check equality.
|
# recursively and then check equality.
|
||||||
power = 10 ** digits
|
power = 10 ** digits
|
||||||
|
|
||||||
def truncate_tuple(tuple_or_float):
|
def truncate_tuple(tuple_or_float):
|
||||||
return tuple(
|
return tuple(
|
||||||
truncate_tuple(val) if isinstance(val, tuple)
|
truncate_tuple(val) if isinstance(val, tuple)
|
||||||
|
|
|
@ -20,7 +20,8 @@ TEST_IMAGE_SIZE = (10, 10)
|
||||||
# the repr is that of a PIL.Image. Size and shape are 1 and (), not the
|
# the repr is that of a PIL.Image. Size and shape are 1 and (), not the
|
||||||
# size and shape of the array. This causes failures in several tests.
|
# size and shape of the array. This causes failures in several tests.
|
||||||
SKIP_NUMPY_ON_PYPY = hasattr(sys, 'pypy_version_info') and (
|
SKIP_NUMPY_ON_PYPY = hasattr(sys, 'pypy_version_info') and (
|
||||||
sys.pypy_version_info <= (5,3,1,'final',0))
|
sys.pypy_version_info <= (5, 3, 1, 'final', 0))
|
||||||
|
|
||||||
|
|
||||||
class TestNumpy(PillowTestCase):
|
class TestNumpy(PillowTestCase):
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ class TestNumpy(PillowTestCase):
|
||||||
img = Image.fromarray(a)
|
img = Image.fromarray(a)
|
||||||
|
|
||||||
img_px = img.load()
|
img_px = img.load()
|
||||||
self.assertEqual(img_px[0,0], pixel_value)
|
self.assertEqual(img_px[0, 0], pixel_value)
|
||||||
|
|
||||||
@unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy")
|
@unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy")
|
||||||
def test_to_array(self):
|
def test_to_array(self):
|
||||||
|
|
|
@ -64,7 +64,7 @@ def install():
|
||||||
return
|
return
|
||||||
|
|
||||||
if fl_win or fl_cygwin:
|
if fl_win or fl_cygwin:
|
||||||
#windows barfs on multiprocessing installs
|
# windows barfs on multiprocessing installs
|
||||||
print("Single threaded build for windows")
|
print("Single threaded build for windows")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user