mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Flake8 fixes
This commit is contained in:
parent
1c99b39239
commit
c27110ab56
|
@ -135,7 +135,7 @@ class BmpImageFile(ImageFile.ImageFile):
|
||||||
16: [(0xf800, 0x7e0, 0x1f), (0x7c00, 0x3e0, 0x1f)]}
|
16: [(0xf800, 0x7e0, 0x1f), (0x7c00, 0x3e0, 0x1f)]}
|
||||||
MASK_MODES = {
|
MASK_MODES = {
|
||||||
(32, (0xff0000, 0xff00, 0xff, 0x0)): "BGRX",
|
(32, (0xff0000, 0xff00, 0xff, 0x0)): "BGRX",
|
||||||
(32, (0xff0000, 0xff00, 0xff, 0xff000000)):"BGRA",
|
(32, (0xff0000, 0xff00, 0xff, 0xff000000)): "BGRA",
|
||||||
(32, (0x0, 0x0, 0x0, 0x0)): "BGRA",
|
(32, (0x0, 0x0, 0x0, 0x0)): "BGRA",
|
||||||
(24, (0xff0000, 0xff00, 0xff)): "BGR",
|
(24, (0xff0000, 0xff00, 0xff)): "BGR",
|
||||||
(16, (0xf800, 0x7e0, 0x1f)): "BGR;16",
|
(16, (0xf800, 0x7e0, 0x1f)): "BGR;16",
|
||||||
|
|
|
@ -2277,7 +2277,7 @@ def open(fp, mode="r"):
|
||||||
except (SyntaxError, IndexError, TypeError, struct.error):
|
except (SyntaxError, IndexError, TypeError, struct.error):
|
||||||
# Leave disabled by default, spams the logs with image
|
# Leave disabled by default, spams the logs with image
|
||||||
# opening failures that are entirely expected.
|
# opening failures that are entirely expected.
|
||||||
#logger.debug("", exc_info=True)
|
# logger.debug("", exc_info=True)
|
||||||
continue
|
continue
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ from PIL._util import isStringType
|
||||||
# Application code should use the <b>Draw</b> factory, instead of
|
# Application code should use the <b>Draw</b> factory, instead of
|
||||||
# directly.
|
# directly.
|
||||||
|
|
||||||
|
|
||||||
class ImageDraw(object):
|
class ImageDraw(object):
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -85,6 +85,7 @@ def fromqpixmap(im):
|
||||||
# bytes_io.seek(0)
|
# bytes_io.seek(0)
|
||||||
# return Image.open(bytes_io)
|
# return Image.open(bytes_io)
|
||||||
|
|
||||||
|
|
||||||
def align8to32(bytes, width, mode):
|
def align8to32(bytes, width, mode):
|
||||||
"""
|
"""
|
||||||
converts each scanline of data from 8 bit to 32 bit aligned
|
converts each scanline of data from 8 bit to 32 bit aligned
|
||||||
|
@ -113,6 +114,7 @@ def align8to32(bytes, width, mode):
|
||||||
|
|
||||||
return b''.join(new_data)
|
return b''.join(new_data)
|
||||||
|
|
||||||
|
|
||||||
def _toqclass_helper(im):
|
def _toqclass_helper(im):
|
||||||
data = None
|
data = None
|
||||||
colortable = None
|
colortable = None
|
||||||
|
|
|
@ -56,7 +56,7 @@ class PyAccess(object):
|
||||||
|
|
||||||
# Debugging is polluting test traces, only useful here
|
# Debugging is polluting test traces, only useful here
|
||||||
# when hacking on PyAccess
|
# when hacking on PyAccess
|
||||||
#logger.debug("%s", vals)
|
# logger.debug("%s", vals)
|
||||||
self._post_init()
|
self._post_init()
|
||||||
|
|
||||||
def _post_init(self):
|
def _post_init(self):
|
||||||
|
|
|
@ -64,7 +64,7 @@ for o, a in opt:
|
||||||
printerArgs = ["lpr"]
|
printerArgs = ["lpr"]
|
||||||
elif o == "-P":
|
elif o == "-P":
|
||||||
# printer channel
|
# printer channel
|
||||||
printerArgs = ["lpr","-P%s" % a]
|
printerArgs = ["lpr", "-P%s" % a]
|
||||||
|
|
||||||
for filepath in argv:
|
for filepath in argv:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -80,11 +80,11 @@ class TestFileTiff(PillowTestCase):
|
||||||
filename = "Tests/images/pil168.tif"
|
filename = "Tests/images/pil168.tif"
|
||||||
im = Image.open(filename)
|
im = Image.open(filename)
|
||||||
|
|
||||||
#legacy api
|
# legacy api
|
||||||
self.assert_(isinstance(im.tag[X_RESOLUTION][0], tuple))
|
self.assert_(isinstance(im.tag[X_RESOLUTION][0], tuple))
|
||||||
self.assert_(isinstance(im.tag[Y_RESOLUTION][0], tuple))
|
self.assert_(isinstance(im.tag[Y_RESOLUTION][0], tuple))
|
||||||
|
|
||||||
#v2 api
|
# v2 api
|
||||||
self.assert_(isinstance(im.tag_v2[X_RESOLUTION], float))
|
self.assert_(isinstance(im.tag_v2[X_RESOLUTION], float))
|
||||||
self.assert_(isinstance(im.tag_v2[Y_RESOLUTION], float))
|
self.assert_(isinstance(im.tag_v2[Y_RESOLUTION], float))
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,6 @@ class TestFileTiffMetadata(PillowTestCase):
|
||||||
loaded_double = loaded.tag[tag_ids['YawAngle']][0]
|
loaded_double = loaded.tag[tag_ids['YawAngle']][0]
|
||||||
self.assertAlmostEqual(loaded_double, doubledata)
|
self.assertAlmostEqual(loaded_double, doubledata)
|
||||||
|
|
||||||
|
|
||||||
def test_read_metadata(self):
|
def test_read_metadata(self):
|
||||||
img = Image.open('Tests/images/hopper_g4.tif')
|
img = Image.open('Tests/images/hopper_g4.tif')
|
||||||
|
|
||||||
|
@ -167,7 +166,6 @@ class TestFileTiffMetadata(PillowTestCase):
|
||||||
self.assert_(im.info['icc_profile'])
|
self.assert_(im.info['icc_profile'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
@ -40,27 +40,26 @@ if sys.platform.startswith('win32'):
|
||||||
DIB_RGB_COLORS = 0
|
DIB_RGB_COLORS = 0
|
||||||
|
|
||||||
memcpy = ctypes.cdll.msvcrt.memcpy
|
memcpy = ctypes.cdll.msvcrt.memcpy
|
||||||
memcpy.argtypes = [ ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t ]
|
memcpy.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t]
|
||||||
|
|
||||||
CreateCompatibleDC = ctypes.windll.gdi32.CreateCompatibleDC
|
CreateCompatibleDC = ctypes.windll.gdi32.CreateCompatibleDC
|
||||||
CreateCompatibleDC.argtypes = [ ctypes.wintypes.HDC ]
|
CreateCompatibleDC.argtypes = [ctypes.wintypes.HDC]
|
||||||
CreateCompatibleDC.restype = ctypes.wintypes.HDC
|
CreateCompatibleDC.restype = ctypes.wintypes.HDC
|
||||||
|
|
||||||
DeleteDC = ctypes.windll.gdi32.DeleteDC
|
DeleteDC = ctypes.windll.gdi32.DeleteDC
|
||||||
DeleteDC.argtypes = [ ctypes.wintypes.HDC ]
|
DeleteDC.argtypes = [ctypes.wintypes.HDC]
|
||||||
|
|
||||||
SelectObject = ctypes.windll.gdi32.SelectObject
|
SelectObject = ctypes.windll.gdi32.SelectObject
|
||||||
SelectObject.argtypes = [ ctypes.wintypes.HDC, ctypes.wintypes.HGDIOBJ ]
|
SelectObject.argtypes = [ctypes.wintypes.HDC, ctypes.wintypes.HGDIOBJ]
|
||||||
SelectObject.restype = ctypes.wintypes.HGDIOBJ
|
SelectObject.restype = ctypes.wintypes.HGDIOBJ
|
||||||
|
|
||||||
DeleteObject = ctypes.windll.gdi32.DeleteObject
|
DeleteObject = ctypes.windll.gdi32.DeleteObject
|
||||||
DeleteObject.argtypes = [ ctypes.wintypes.HGDIOBJ ]
|
DeleteObject.argtypes = [ctypes.wintypes.HGDIOBJ]
|
||||||
|
|
||||||
CreateDIBSection = ctypes.windll.gdi32.CreateDIBSection
|
CreateDIBSection = ctypes.windll.gdi32.CreateDIBSection
|
||||||
CreateDIBSection.argtypes = [ ctypes.wintypes.HDC, ctypes.c_void_p, ctypes.c_uint, ctypes.POINTER(ctypes.c_void_p), ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD ]
|
CreateDIBSection.argtypes = [ctypes.wintypes.HDC, ctypes.c_void_p, ctypes.c_uint, ctypes.POINTER(ctypes.c_void_p), ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD]
|
||||||
CreateDIBSection.restype = ctypes.wintypes.HBITMAP
|
CreateDIBSection.restype = ctypes.wintypes.HBITMAP
|
||||||
|
|
||||||
|
|
||||||
def serialize_dib(bi, pixels):
|
def serialize_dib(bi, pixels):
|
||||||
bf = BITMAPFILEHEADER()
|
bf = BITMAPFILEHEADER()
|
||||||
bf.bfType = 0x4d42
|
bf.bfType = 0x4d42
|
||||||
|
@ -78,7 +77,7 @@ if sys.platform.startswith('win32'):
|
||||||
class TestImageWinPointers(PillowTestCase):
|
class TestImageWinPointers(PillowTestCase):
|
||||||
def test_pointer(self):
|
def test_pointer(self):
|
||||||
im = hopper()
|
im = hopper()
|
||||||
(width, height) =im.size
|
(width, height) = im.size
|
||||||
opath = self.tempfile('temp.png')
|
opath = self.tempfile('temp.png')
|
||||||
imdib = ImageWin.Dib(im)
|
imdib = ImageWin.Dib(im)
|
||||||
|
|
||||||
|
@ -94,7 +93,7 @@ if sys.platform.startswith('win32'):
|
||||||
hdr.biClrImportant = 0
|
hdr.biClrImportant = 0
|
||||||
|
|
||||||
hdc = CreateCompatibleDC(None)
|
hdc = CreateCompatibleDC(None)
|
||||||
#print('hdc:',hex(hdc))
|
# print('hdc:',hex(hdc))
|
||||||
pixels = ctypes.c_void_p()
|
pixels = ctypes.c_void_p()
|
||||||
dib = CreateDIBSection(hdc, ctypes.byref(hdr), DIB_RGB_COLORS, ctypes.byref(pixels), None, 0)
|
dib = CreateDIBSection(hdc, ctypes.byref(hdr), DIB_RGB_COLORS, ctypes.byref(pixels), None, 0)
|
||||||
SelectObject(hdc, dib)
|
SelectObject(hdc, dib)
|
||||||
|
@ -108,4 +107,3 @@ if sys.platform.startswith('win32'):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user