Skip to content

Commit

Permalink
Flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 10, 2015
1 parent 1c99b39 commit c27110a
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion PIL/BmpImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _bitmap(self, header=0, offset=0):
16: [(0xf800, 0x7e0, 0x1f), (0x7c00, 0x3e0, 0x1f)]}
MASK_MODES = {
(32, (0xff0000, 0xff00, 0xff, 0x0)): "BGRX",
(32, (0xff0000, 0xff00, 0xff, 0xff000000)):"BGRA",
(32, (0xff0000, 0xff00, 0xff, 0xff000000)): "BGRA",
(32, (0x0, 0x0, 0x0, 0x0)): "BGRA",
(24, (0xff0000, 0xff00, 0xff)): "BGR",
(16, (0xf800, 0x7e0, 0x1f)): "BGR;16",
Expand Down
6 changes: 3 additions & 3 deletions PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,9 @@ def __setstate__(self, state):
def tobytes(self, encoder_name="raw", *args):
"""
Return image as a bytes object.
.. warning::
This method returns the raw image data from the internal
storage. For compressed image data (e.g. PNG, JPEG) use
:meth:`~.save`, with a BytesIO parameter for in-memory
Expand Down Expand Up @@ -2277,7 +2277,7 @@ def _open_core(fp, filename, prefix):
except (SyntaxError, IndexError, TypeError, struct.error):
# Leave disabled by default, spams the logs with image
# opening failures that are entirely expected.
#logger.debug("", exc_info=True)
# logger.debug("", exc_info=True)
continue
return None

Expand Down
1 change: 1 addition & 0 deletions PIL/ImageDraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# Application code should use the <b>Draw</b> factory, instead of
# directly.


class ImageDraw(object):

##
Expand Down
2 changes: 2 additions & 0 deletions PIL/ImageQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def fromqpixmap(im):
# bytes_io.seek(0)
# return Image.open(bytes_io)


def align8to32(bytes, width, mode):
"""
converts each scanline of data from 8 bit to 32 bit aligned
Expand Down Expand Up @@ -113,6 +114,7 @@ def align8to32(bytes, width, mode):

return b''.join(new_data)


def _toqclass_helper(im):
data = None
colortable = None
Expand Down
2 changes: 1 addition & 1 deletion PIL/PyAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, img, readonly=False):

# Debugging is polluting test traces, only useful here
# when hacking on PyAccess
#logger.debug("%s", vals)
# logger.debug("%s", vals)
self._post_init()

def _post_init(self):
Expand Down
2 changes: 1 addition & 1 deletion Scripts/pilprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def description(filepath, image):
printerArgs = ["lpr"]
elif o == "-P":
# printer channel
printerArgs = ["lpr","-P%s" % a]
printerArgs = ["lpr", "-P%s" % a]

for filepath in argv:
try:
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_file_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_isInt_not_a_number(self):

def test_invalid_file(self):
invalid_file = "Tests/images/invalid.spider"

self.assertRaises(IOError, lambda: Image.open(invalid_file))


Expand Down
6 changes: 3 additions & 3 deletions Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def test_xyres_tiff(self):
filename = "Tests/images/pil168.tif"
im = Image.open(filename)

#legacy api
# legacy api
self.assert_(isinstance(im.tag[X_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[Y_RESOLUTION], float))

Expand Down Expand Up @@ -249,7 +249,7 @@ def test_as_dict(self):
{256: 55, 257: 43, 258: (8, 8, 8, 8), 259: 1,
262: 2, 296: 2, 273: (8,), 338: (1,), 277: 4,
279: (9460,), 282: 72.0, 283: 72.0, 284: 1})

# legacy interface
self.assertEqual(
im.tag.as_dict(),
Expand Down
8 changes: 3 additions & 5 deletions Tests/test_file_tiff_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_rt_metadata(self):
#
# For text items, we still have to decode('ascii','replace') because
# the tiff file format can't take 8 bit bytes in that field.

basetextdata = "This is some arbitrary metadata for a text field"
bindata = basetextdata.encode('ascii') + b" \xff"
textdata = basetextdata + " " + chr(255)
Expand All @@ -40,7 +40,7 @@ def test_rt_metadata(self):
ImageJMetaData = tag_ids['ImageJMetaData']
ImageJMetaDataByteCounts = tag_ids['ImageJMetaDataByteCounts']
ImageDescription = tag_ids['ImageDescription']

info[ImageJMetaDataByteCounts] = len(bindata)
info[ImageJMetaData] = bindata
info[tag_ids['RollAngle']] = floatdata
Expand All @@ -49,7 +49,7 @@ def test_rt_metadata(self):
info.tagtype[tag_ids['YawAngle']] = 12

info[ImageDescription] = textdata

f = self.tempfile("temp.tif")

img.save(f, tiffinfo=info)
Expand All @@ -70,7 +70,6 @@ def test_rt_metadata(self):
loaded_double = loaded.tag[tag_ids['YawAngle']][0]
self.assertAlmostEqual(loaded_double, doubledata)


def test_read_metadata(self):
img = Image.open('Tests/images/hopper_g4.tif')

Expand Down Expand Up @@ -167,7 +166,6 @@ def test_iccprofile_binary(self):
self.assert_(im.info['icc_profile'])



if __name__ == '__main__':
unittest.main()

Expand Down
2 changes: 1 addition & 1 deletion Tests/test_image_fromqimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TestFromQImage(PillowQtTestCase, PillowTestCase):
Image.open('Tests/images/transparent.png'),
Image.open('Tests/images/7x13.png'),
]

def roundtrip(self, expected):
# PIL -> Qt
intermediate = expected.toqimage()
Expand Down
20 changes: 9 additions & 11 deletions Tests/test_imagewin_pointers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

if sys.platform.startswith('win32'):
import ctypes.wintypes

class BITMAPFILEHEADER(ctypes.Structure):
_pack_ = 2
_fields_ = [
Expand Down Expand Up @@ -40,27 +40,26 @@ class BITMAPINFOHEADER(ctypes.Structure):
DIB_RGB_COLORS = 0

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.argtypes = [ ctypes.wintypes.HDC ]
CreateCompatibleDC.argtypes = [ctypes.wintypes.HDC]
CreateCompatibleDC.restype = ctypes.wintypes.HDC

DeleteDC = ctypes.windll.gdi32.DeleteDC
DeleteDC.argtypes = [ ctypes.wintypes.HDC ]
DeleteDC.argtypes = [ctypes.wintypes.HDC]

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

DeleteObject = ctypes.windll.gdi32.DeleteObject
DeleteObject.argtypes = [ ctypes.wintypes.HGDIOBJ ]
DeleteObject.argtypes = [ctypes.wintypes.HGDIOBJ]

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


def serialize_dib(bi, pixels):
bf = BITMAPFILEHEADER()
bf.bfType = 0x4d42
Expand All @@ -78,7 +77,7 @@ def serialize_dib(bi, pixels):
class TestImageWinPointers(PillowTestCase):
def test_pointer(self):
im = hopper()
(width, height) =im.size
(width, height) = im.size
opath = self.tempfile('temp.png')
imdib = ImageWin.Dib(im)

Expand All @@ -94,7 +93,7 @@ def test_pointer(self):
hdr.biClrImportant = 0

hdc = CreateCompatibleDC(None)
#print('hdc:',hex(hdc))
# print('hdc:',hex(hdc))
pixels = ctypes.c_void_p()
dib = CreateDIBSection(hdc, ctypes.byref(hdr), DIB_RGB_COLORS, ctypes.byref(pixels), None, 0)
SelectObject(hdc, dib)
Expand All @@ -108,4 +107,3 @@ def test_pointer(self):

if __name__ == '__main__':
unittest.main()

0 comments on commit c27110a

Please sign in to comment.