Flake8 fixes

This commit is contained in:
Andrew Murray 2015-08-25 22:27:18 +10:00
parent 926a08cdb3
commit c6b13d294f
44 changed files with 168 additions and 173 deletions

View File

@ -24,12 +24,10 @@
# #
__version__ = "0.7"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
import math import math
__version__ = "0.7"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16le i16 = _binary.i16le

View File

@ -17,10 +17,9 @@
# #
__version__ = "0.1"
from PIL import Image, BmpImagePlugin, _binary from PIL import Image, BmpImagePlugin, _binary
__version__ = "0.1"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -21,12 +21,11 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.2"
from PIL import Image, _binary from PIL import Image, _binary
from PIL.PcxImagePlugin import PcxImageFile from PIL.PcxImagePlugin import PcxImageFile
__version__ = "0.2"
MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then? MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then?
i32 = _binary.i32le i32 = _binary.i32le

View File

@ -20,12 +20,13 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.5"
import re import re
import io import io
import sys
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.5"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -36,7 +37,6 @@ split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$")
field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$") field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$")
gs_windows_binary = None gs_windows_binary = None
import sys
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
import shutil import shutil
if hasattr(shutil, 'which'): if hasattr(shutil, 'which'):
@ -187,7 +187,8 @@ class PSFile(object):
def _accept(prefix): def _accept(prefix):
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5) return prefix[:4] == b"%!PS" or \
(len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
## ##
# Image plugin for Encapsulated Postscript. This plugin supports only # Image plugin for Encapsulated Postscript. This plugin supports only

View File

@ -16,10 +16,10 @@
# #
__version__ = "0.2"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.2"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16le i16 = _binary.i16le
i32 = _binary.i32le i32 = _binary.i32le

View File

@ -16,12 +16,11 @@
# #
__version__ = "0.1"
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL.OleFileIO import i8, i32, MAGIC, OleFileIO from PIL.OleFileIO import i8, i32, MAGIC, OleFileIO
__version__ = "0.1"
# we map from colour field tuples to (mode, rawmode) descriptors # we map from colour field tuples to (mode, rawmode) descriptors
MODES = { MODES = {

View File

@ -23,11 +23,11 @@
# purposes only. # purposes only.
__version__ = "0.1"
from PIL import ImageFile, ImagePalette, _binary from PIL import ImageFile, ImagePalette, _binary
from PIL._util import isPath from PIL._util import isPath
__version__ = "0.1"
try: try:
import builtins import builtins
except ImportError: except ImportError:

View File

@ -22,14 +22,14 @@
# * http://msdn.microsoft.com/en-us/library/ms997538.aspx # * http://msdn.microsoft.com/en-us/library/ms997538.aspx
__version__ = "0.1"
import struct import struct
from io import BytesIO from io import BytesIO
from PIL import Image, ImageFile, BmpImagePlugin, PngImagePlugin, _binary from PIL import Image, ImageFile, BmpImagePlugin, PngImagePlugin, _binary
from math import log, ceil from math import log, ceil
__version__ = "0.1"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -26,12 +26,12 @@
# #
__version__ = "0.7"
import re import re
from PIL import Image, ImageFile, ImagePalette from PIL import Image, ImageFile, ImagePalette
from PIL._binary import i8 from PIL._binary import i8
__version__ = "0.7"
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Standard tags # Standard tags

View File

@ -33,7 +33,7 @@ import io
import logging import logging
import os import os
import sys import sys
import traceback # import traceback
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -275,7 +275,8 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None):
# According to the freedesktop spec, XDG_DATA_DIRS should # According to the freedesktop spec, XDG_DATA_DIRS should
# default to /usr/share # default to /usr/share
lindirs = '/usr/share' lindirs = '/usr/share'
dirs += [os.path.join(lindir, "fonts") for lindir in lindirs.split(":")] dirs += [os.path.join(lindir, "fonts")
for lindir in lindirs.split(":")]
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
dirs += ['/Library/Fonts', '/System/Library/Fonts', dirs += ['/Library/Fonts', '/System/Library/Fonts',
os.path.expanduser('~/Library/Fonts')] os.path.expanduser('~/Library/Fonts')]

View File

@ -15,12 +15,13 @@
# #
__version__ = "0.2"
import re import re
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.2"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -17,13 +17,12 @@
from __future__ import print_function from __future__ import print_function
__version__ = "0.3"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
import os import os
import tempfile import tempfile
__version__ = "0.3"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be

View File

@ -32,8 +32,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.6"
import array import array
import struct import struct
import io import io
@ -48,6 +46,8 @@ o8 = _binary.o8
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be
__version__ = "0.6"
# #
# Parser # Parser

View File

@ -16,11 +16,11 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.2"
import struct import struct
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.2"
def _accept(s): def _accept(s):
return s[:8] == b"\x00\x00\x00\x00\x00\x00\x00\x04" return s[:8] == b"\x00\x00\x00\x00\x00\x00\x00\x04"

View File

@ -17,12 +17,11 @@
# #
__version__ = "0.1"
from PIL import Image, TiffImagePlugin from PIL import Image, TiffImagePlugin
from PIL.OleFileIO import MAGIC, OleFileIO from PIL.OleFileIO import MAGIC, OleFileIO
__version__ = "0.1"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -13,11 +13,12 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.1"
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL._binary import i8 from PIL._binary import i8
__version__ = "0.1"
# #
# Bitstream parser # Bitstream parser

View File

@ -18,10 +18,10 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.1"
from PIL import Image, JpegImagePlugin from PIL import Image, JpegImagePlugin
__version__ = "0.1"
def _accept(prefix): def _accept(prefix):
return JpegImagePlugin._accept(prefix) return JpegImagePlugin._accept(prefix)

View File

@ -17,10 +17,10 @@
# #
__version__ = "0.1"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.1"
# #
# read MSP files # read MSP files

View File

@ -7,10 +7,10 @@
# Image plugin for Palm pixmap images (output only). # Image plugin for Palm pixmap images (output only).
## ##
__version__ = "1.0"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "1.0"
_Palm8BitColormapValues = ( _Palm8BitColormapValues = (
(255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255), (255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255),
(255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204), (255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204),

View File

@ -15,11 +15,10 @@
# #
__version__ = "0.1"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.1"
i8 = _binary.i8 i8 = _binary.i8

View File

@ -20,12 +20,12 @@
# Image plugin for PDF images (output only). # Image plugin for PDF images (output only).
## ##
__version__ = "0.4"
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL._binary import i8 from PIL._binary import i8
import io import io
__version__ = "0.4"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -19,10 +19,10 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.1"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.1"
# #
# helpers # helpers

View File

@ -33,14 +33,14 @@
from __future__ import print_function from __future__ import print_function
__version__ = "0.9"
import logging import logging
import re import re
import zlib import zlib
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.9"
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
i8 = _binary.i8 i8 = _binary.i8

View File

@ -15,12 +15,12 @@
# #
__version__ = "0.2"
import string import string
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.2"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -18,11 +18,10 @@
# #
__version__ = "0.2"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.2"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be

View File

@ -17,11 +17,10 @@
# #
__version__ = "0.3"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.3"
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be

View File

@ -17,10 +17,10 @@
# #
__version__ = "0.3"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.3"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -41,9 +41,6 @@
from __future__ import print_function from __future__ import print_function
__version__ = "1.3.5"
DEBUG = False # Needs to be merged with the new logging approach.
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL import ImagePalette from PIL import ImagePalette
from PIL import _binary from PIL import _binary
@ -57,6 +54,9 @@ import itertools
import os import os
import io import io
__version__ = "1.3.5"
DEBUG = False # Needs to be merged with the new logging approach.
# Set these to true to force use of libtiff for reading or writing. # Set these to true to force use of libtiff for reading or writing.
READ_LIBTIFF = False READ_LIBTIFF = False
WRITE_LIBTIFF = False WRITE_LIBTIFF = False
@ -702,7 +702,8 @@ class TiffImageFile(ImageFile.ImageFile):
if not self.__next: if not self.__next:
raise EOFError("no more images in TIFF file") raise EOFError("no more images in TIFF file")
if DEBUG: if DEBUG:
print("Seeking to frame %s, on frame %s, __next %s, location: %s" % print("Seeking to frame %s, on frame %s, " +
"__next %s, location: %s" %
(frame, self.__frame, self.__next, self.fp.tell())) (frame, self.__frame, self.__next, self.fp.tell()))
# reset python3 buffered io handle in case fp # reset python3 buffered io handle in case fp
# was passed to libtiff, invalidating the buffer # was passed to libtiff, invalidating the buffer

View File

@ -15,10 +15,10 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.2"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.2"
_handler = None _handler = None
if str != bytes: if str != bytes:

View File

@ -17,10 +17,10 @@
# FIXME: make save work (this requires quantization support) # FIXME: make save work (this requires quantization support)
# #
__version__ = "0.1"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.1"
o8 = _binary.o8 o8 = _binary.o8
# standard color palette for thumbnails (RGB332) # standard color palette for thumbnails (RGB332)

View File

@ -19,11 +19,11 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.6"
import re import re
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.6"
# XBM header # XBM header
xbm_head = re.compile( xbm_head = re.compile(
b"\s*#define[ \t]+.*_width[ \t]+(?P<width>[0-9]+)[\r\n]+" b"\s*#define[ \t]+.*_width[ \t]+(?P<width>[0-9]+)[\r\n]+"

View File

@ -15,13 +15,12 @@
# #
__version__ = "0.2"
import re import re
from PIL import Image, ImageFile, ImagePalette from PIL import Image, ImageFile, ImagePalette
from PIL._binary import i8, o8 from PIL._binary import i8, o8
__version__ = "0.2"
# XPM header # XPM header
xpm_head = re.compile(b"\"([0-9]*) ([0-9]*) ([0-9]*) ([0-9]*)") xpm_head = re.compile(b"\"([0-9]*) ([0-9]*) ([0-9]*) ([0-9]*)")

View File

@ -12,8 +12,6 @@
from __future__ import print_function from __future__ import print_function
VERSION = "0.4"
import glob import glob
import sys import sys
@ -21,6 +19,8 @@ import sys
from PIL import BdfFontFile from PIL import BdfFontFile
from PIL import PcfFontFile from PIL import PcfFontFile
VERSION = "0.4"
if len(sys.argv) <= 1: if len(sys.argv) <= 1:
print("PILFONT", VERSION, "-- PIL font compiler.") print("PILFONT", VERSION, "-- PIL font compiler.")
print() print()

View File

@ -1,9 +1,9 @@
import sys
sys.path.insert(0, ".")
import helper import helper
import timeit import timeit
import sys
sys.path.insert(0, ".")
def bench(mode): def bench(mode):
im = helper.hopper(mode) im = helper.hopper(mode)

View File

@ -1,11 +1,12 @@
from __future__ import print_function from __future__ import print_function
import sys
sys.path.insert(0, ".")
import glob import glob
import os import os
import traceback import traceback
import sys
sys.path.insert(0, ".")
for file in glob.glob("PIL/*.py"): for file in glob.glob("PIL/*.py"):
module = os.path.basename(file)[:-3] module = os.path.basename(file)[:-3]
try: try:

View File

@ -1,9 +1,9 @@
import sys
sys.path.insert(0, ".")
from PIL import Image from PIL import Image
from PIL import ImageCms from PIL import ImageCms
import sys
sys.path.insert(0, ".")
try: try:
filename = sys.argv[1] filename = sys.argv[1]
except IndexError: except IndexError:

View File

@ -1,10 +1,11 @@
from __future__ import print_function from __future__ import print_function
import sys
sys.path.insert(0, ".")
from PIL import Image from PIL import Image
from PIL import ImageMath from PIL import ImageMath
import sys
sys.path.insert(0, ".")
try: try:
filename = sys.argv[1] filename = sys.argv[1]
except IndexError: except IndexError:

View File

@ -88,7 +88,6 @@ class TestFileTiff(PillowTestCase):
self.assertRaises(SyntaxError, self.assertRaises(SyntaxError,
lambda: TiffImagePlugin.TiffImageFile(invalid_file)) lambda: TiffImagePlugin.TiffImageFile(invalid_file))
def test_bad_exif(self): def test_bad_exif(self):
try: try:
Image.open('Tests/images/hopper_bad_exif.jpg')._getexif() Image.open('Tests/images/hopper_bad_exif.jpg')._getexif()

View File

@ -5,14 +5,14 @@ from PIL import ImageColor
from PIL import ImageDraw from PIL import ImageDraw
import os.path import os.path
import sys
BLACK = (0, 0, 0) BLACK = (0, 0, 0)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
GRAY = (190, 190, 190) GRAY = (190, 190, 190)
DEFAULT_MODE = 'RGB' DEFAULT_MODE = 'RGB'
IMAGES_PATH = os.path.join('Tests', 'images', 'imagedraw') IMAGES_PATH = os.path.join('Tests', 'images', 'imagedraw')
import sys
# Image size # Image size
W, H = 100, 100 W, H = 100, 100