Remove unnecessary print_function calls

This commit is contained in:
Jerome Leclanche 2017-01-06 06:17:44 +02:00
parent f30439b824
commit aca1bcbe2b
25 changed files with 14 additions and 186 deletions

View File

@ -17,7 +17,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
from PIL import Image, FontFile from PIL import Image, FontFile
from .exceptions import InvalidFileType from .exceptions import InvalidFileType
@ -108,20 +107,6 @@ class BdfFontFile(FontFile.FontFile):
if s.find(b"LogicalFontDescription") < 0: if s.find(b"LogicalFontDescription") < 0:
comments.append(s[i+1:-1].decode('ascii')) comments.append(s[i+1:-1].decode('ascii'))
# font = props["FONT"].split("-")
# font[4] = bdf_slant[font[4].upper()]
# font[11] = bdf_spacing[font[11].upper()]
# ascent = int(props["FONT_ASCENT"])
# descent = int(props["FONT_DESCENT"])
# fontname = ";".join(font[1:])
# print("#", fontname)
# for i in comments:
# print("#", i)
while True: while True:
c = bdf_char(fp) c = bdf_char(fp)
if not c: if not c:

View File

@ -16,7 +16,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
from PIL import Image, BmpImagePlugin, _binary from PIL import Image, BmpImagePlugin, _binary
from .exceptions import InvalidFileType from .exceptions import InvalidFileType
@ -60,14 +59,6 @@ class CurImageFile(BmpImagePlugin.BmpImageFile):
m = s m = s
elif i8(s[0]) > i8(m[0]) and i8(s[1]) > i8(m[1]): elif i8(s[0]) > i8(m[0]) and i8(s[1]) > i8(m[1]):
m = s m = s
# print("width", i8(s[0]))
# print("height", i8(s[1]))
# print("colors", i8(s[2]))
# print("reserved", i8(s[3]))
# print("hotspot x", i16(s[4:]))
# print("hotspot y", i16(s[6:]))
# print("bytes", i32(s[8:]))
# print("offset", i32(s[12:]))
if not m: if not m:
raise TypeError("No cursors were found") raise TypeError("No cursors were found")

View File

@ -14,8 +14,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
import os import os
from PIL import Image, _binary from PIL import Image, _binary
@ -90,7 +88,6 @@ class FontFile(object):
x = xx x = xx
s = src[0] + x0, src[1] + y0, src[2] + x0, src[3] + y0 s = src[0] + x0, src[1] + y0, src[2] + x0, src[3] + y0
self.bitmap.paste(im.crop(src), s) self.bitmap.paste(im.crop(src), s)
# print(chr(i), dst, s)
self.metrics[i] = d, dst, s self.metrics[i] = d, dst, s
def save(self, filename): def save(self, filename):

View File

@ -15,7 +15,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
import olefile import olefile
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
from .exceptions import InvalidFileType, PILReadError from .exceptions import InvalidFileType, PILReadError
@ -116,8 +115,6 @@ class FpxImageFile(ImageFile.ImageFile):
if id in prop: if id in prop:
self.jpeg[i] = prop[id] self.jpeg[i] = prop[id]
# print(len(self.jpeg), "tables loaded")
self._open_subimage(1, self.maxid) self._open_subimage(1, self.maxid)
def _open_subimage(self, index=1, subimage=0): def _open_subimage(self, index=1, subimage=0):
@ -145,8 +142,6 @@ class FpxImageFile(ImageFile.ImageFile):
offset = i32(s, 28) offset = i32(s, 28)
length = i32(s, 32) length = i32(s, 32)
# print(size, self.mode, self.rawmode)
if size != self.size: if size != self.size:
raise PILReadError("subimage mismatch") raise PILReadError("subimage mismatch")

View File

@ -24,12 +24,9 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
import logging import logging
import math import math
import warnings import warnings
from PIL import VERSION, PILLOW_VERSION, _plugins from PIL import VERSION, PILLOW_VERSION, _plugins
from .exceptions import PILReadError, NoPluginFound from .exceptions import PILReadError, NoPluginFound
@ -419,7 +416,6 @@ def _getdecoder(mode, decoder_name, args, extra=()):
try: try:
# get decoder # get decoder
decoder = getattr(core, decoder_name + "_decoder") decoder = getattr(core, decoder_name + "_decoder")
# print(decoder, mode, args + extra)
return decoder(mode, *args + extra) return decoder(mode, *args + extra)
except AttributeError: except AttributeError:
raise IOError("decoder %s not available" % decoder_name) raise IOError("decoder %s not available" % decoder_name)
@ -436,7 +432,6 @@ def _getencoder(mode, encoder_name, args, extra=()):
try: try:
# get encoder # get encoder
encoder = getattr(core, encoder_name + "_encoder") encoder = getattr(core, encoder_name + "_encoder")
# print(encoder, mode, args + extra)
return encoder(mode, *args + extra) return encoder(mode, *args + extra)
except AttributeError: except AttributeError:
raise IOError("encoder %s not available" % encoder_name) raise IOError("encoder %s not available" % encoder_name)
@ -2195,7 +2190,6 @@ def fromarray(obj, mode=None):
typekey = (1, 1) + shape[2:], arr['typestr'] typekey = (1, 1) + shape[2:], arr['typestr']
mode, rawmode = _fromarray_typemap[typekey] mode, rawmode = _fromarray_typemap[typekey]
except KeyError: except KeyError:
# print(typekey)
raise TypeError("Cannot handle this data type") raise TypeError("Cannot handle this data type")
else: else:
rawmode = mode rawmode = mode

View File

@ -15,7 +15,6 @@
# See the README file for information on usage and redistribution. See # See the README file for information on usage and redistribution. See
# below for the original description. # below for the original description.
from __future__ import print_function
import sys import sys
from PIL import Image from PIL import Image
@ -28,6 +27,7 @@ except ImportError as ex:
_imagingcms = deferred_error(ex) _imagingcms = deferred_error(ex)
from PIL._util import isStringType from PIL._util import isStringType
DESCRIPTION = """ DESCRIPTION = """
pyCMS pyCMS
@ -149,7 +149,6 @@ for flag in FLAGS.values():
# Profile. # Profile.
class ImageCmsProfile(object): class ImageCmsProfile(object):
def __init__(self, profile): def __init__(self, profile):
""" """
:param profile: Either a string representing a filename, :param profile: Either a string representing a filename,
@ -166,7 +165,6 @@ class ImageCmsProfile(object):
self._set(profile) self._set(profile)
else: else:
raise TypeError("Invalid type for Profile") raise TypeError("Invalid type for Profile")
def _set(self, profile, filename=None): def _set(self, profile, filename=None):
self.profile = profile self.profile = profile

View File

@ -5,11 +5,10 @@
# #
# Copyright (c) 2014 Dov Grobgeld <dov.grobgeld@gmail.com> # Copyright (c) 2014 Dov Grobgeld <dov.grobgeld@gmail.com>
from __future__ import print_function import re
from PIL import Image from PIL import Image
from PIL import _imagingmorph from PIL import _imagingmorph
import re
LUT_SIZE = 1 << 9 LUT_SIZE = 1 << 9
@ -152,11 +151,6 @@ class LutBuilder(object):
patterns += self._pattern_permute(pattern, options, result) patterns += self._pattern_permute(pattern, options, result)
# # Debugging
# for p,r in patterns:
# print(p,r)
# print('--')
# compile the patterns into regular expressions for speed # compile the patterns into regular expressions for speed
for i, pattern in enumerate(patterns): for i, pattern in enumerate(patterns):
p = pattern[0].replace('.', 'X').replace('X', '[01]') p = pattern[0].replace('.', 'X').replace('X', '[01]')

View File

@ -12,8 +12,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
from PIL import Image from PIL import Image
import os import os
import sys import sys

View File

@ -15,7 +15,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
import os import os
import tempfile import tempfile
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
@ -44,12 +43,6 @@ def i(c):
return i32((PAD + c)[-4:]) return i32((PAD + c)[-4:])
def dump(c):
for i in c:
print("%02x" % i8(i), end=' ')
print()
## ##
# Image plugin for IPTC/NAA datastreams. To read IPTC/NAA fields # Image plugin for IPTC/NAA datastreams. To read IPTC/NAA fields
# from TIFF and JPEG files, use the <b>getiptcinfo</b> function. # from TIFF and JPEG files, use the <b>getiptcinfo</b> function.
@ -108,8 +101,6 @@ class IptcImageFile(ImageFile.ImageFile):
else: else:
self.info[tag] = tagdata self.info[tag] = tagdata
# print(tag, self.info[tag])
# mode # mode
layers = i8(self.info[(3, 60)][0]) layers = i8(self.info[(3, 60)][0])
component = i8(self.info[(3, 60)][1]) component = i8(self.info[(3, 60)][1])

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.
# #
from __future__ import print_function
import array import array
import struct import struct
import io import io
@ -319,7 +317,6 @@ class JpegImageFile(ImageFile.ImageFile):
if i in MARKER: if i in MARKER:
name, description, handler = MARKER[i] name, description, handler = MARKER[i]
# print(hex(i), name, description)
if handler is not None: if handler is not None:
handler(self, i) handler(self, i)
if i == 0xFFDA: # start of scan if i == 0xFFDA: # start of scan

View File

@ -25,8 +25,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
import logging import logging
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
from .exceptions import InvalidFileType, PILReadError from .exceptions import InvalidFileType, PILReadError
@ -54,7 +52,6 @@ class PcxImageFile(ImageFile.ImageFile):
format_description = "Paintbrush" format_description = "Paintbrush"
def _open(self): def _open(self):
# header # header
s = self.fp.read(128) s = self.fp.read(128)
if not _accept(s): if not _accept(s):

View File

@ -31,8 +31,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
from __future__ import print_function
import logging import logging
import re import re
import zlib import zlib

View File

@ -20,11 +20,8 @@
# Access.c implementation. # Access.c implementation.
# #
from __future__ import print_function
import logging import logging
import sys import sys
from cffi import FFI from cffi import FFI

View File

@ -21,8 +21,6 @@
# http://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml # http://www.flipcode.com/archives/Quake_2_BSP_File_Format.shtml
# and has been tested with a few sample files found using google. # and has been tested with a few sample files found using google.
from __future__ import print_function
from PIL import Image, _binary from PIL import Image, _binary
try: try:

View File

@ -19,8 +19,6 @@
# http://wvware.sourceforge.net/caolan/index.html # http://wvware.sourceforge.net/caolan/index.html
# http://wvware.sourceforge.net/caolan/ora-wmf.html # http://wvware.sourceforge.net/caolan/ora-wmf.html
from __future__ import print_function
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
from .exceptions import InvalidFileType from .exceptions import InvalidFileType
@ -112,8 +110,6 @@ class WmfStubImageFile(ImageFile.StubImageFile):
self.info["dpi"] = 72 self.info["dpi"] = 72
# print(self.mode, self.size, self.info)
# sanity check (standard metafile header) # sanity check (standard metafile header)
if s[22:26] != b"\x01\x00\t\x00": if s[22:26] != b"\x01\x00\t\x00":
raise NotImplementedError("Unsupported WMF file format") raise NotImplementedError("Unsupported WMF file format")

View File

@ -1,12 +1,10 @@
""" """
Helper functions. Helper functions.
""" """
from __future__ import print_function import os
import sys import sys
import tempfile import tempfile
import os
import unittest import unittest
from PIL import Image, ImageMath from PIL import Image, ImageMath

View File

@ -1,8 +1,7 @@
from __future__ import print_function import os
from PIL import Image
from helper import unittest, PillowTestCase from helper import unittest, PillowTestCase
from PIL import Image
import os
base = os.path.join('Tests', 'images', 'bmp') base = os.path.join('Tests', 'images', 'bmp')
@ -22,7 +21,6 @@ class TestBmpReference(PillowTestCase):
im.load() im.load()
except Exception: # as msg: except Exception: # as msg:
pass pass
# print("Bad Image %s: %s" %(f,msg))
def test_questionable(self): def test_questionable(self):
""" These shouldn't crash/dos, but it's not well defined that these """ These shouldn't crash/dos, but it's not well defined that these
@ -47,7 +45,6 @@ class TestBmpReference(PillowTestCase):
except Exception: # as msg: except Exception: # as msg:
if os.path.basename(f) in supported: if os.path.basename(f) in supported:
raise raise
# print("Bad Image %s: %s" %(f,msg))
def test_good(self): def test_good(self):
""" These should all work. There's a set of target files in the """ These should all work. There's a set of target files in the

View File

@ -39,27 +39,6 @@ class TestFileIptc(PillowTestCase):
# Assert # Assert
self.assertEqual(ret, 97) self.assertEqual(ret, 97)
def test_dump(self):
# Arrange
c = b"abc"
# Temporarily redirect stdout
try:
from cStringIO import StringIO
except ImportError:
from io import StringIO
import sys
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
# Act
IptcImagePlugin.dump(c)
# Reset stdout
sys.stdout = old_stdout
# Assert
self.assertEqual(mystdout.getvalue(), "61 62 63 \n")
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -48,29 +48,6 @@ class TestImageSpider(PillowTestCase):
self.assertEqual(im.n_frames, 1) self.assertEqual(im.n_frames, 1)
self.assertFalse(im.is_animated) self.assertFalse(im.is_animated)
def test_loadImageSeries(self):
# Arrange
not_spider_file = "Tests/images/hopper.ppm"
file_list = [TEST_FILE, not_spider_file, "path/not_found.ext"]
# Act
img_list = SpiderImagePlugin.loadImageSeries(file_list)
# Assert
self.assertEqual(len(img_list), 1)
self.assertIsInstance(img_list[0], Image.Image)
self.assertEqual(img_list[0].size, (128, 128))
def test_loadImageSeries_no_input(self):
# Arrange
file_list = None
# Act
img_list = SpiderImagePlugin.loadImageSeries(file_list)
# Assert
self.assertEqual(img_list, None)
def test_isInt_not_a_number(self): def test_isInt_not_a_number(self):
# Arrange # Arrange
not_a_number = "a" not_a_number = "a"

View File

@ -1,10 +1,7 @@
from __future__ import print_function
from helper import unittest, PillowTestCase, hopper
from PIL import Image
import colorsys import colorsys
import itertools import itertools
from PIL import Image
from helper import unittest, PillowTestCase, hopper
class TestFormatHSV(PillowTestCase): class TestFormatHSV(PillowTestCase):
@ -47,10 +44,6 @@ class TestFormatHSV(PillowTestCase):
img = Image.merge('RGB', (r, g, b)) img = Image.merge('RGB', (r, g, b))
# print(("%d, %d -> "% (int(1.75*px),int(.25*px))) + \
# "(%s, %s, %s)"%img.getpixel((1.75*px, .25*px)))
# print(("%d, %d -> "% (int(.75*px),int(.25*px))) + \
# "(%s, %s, %s)"%img.getpixel((.75*px, .25*px)))
return img return img
def to_xxx_colorsys(self, im, func, mode): def to_xxx_colorsys(self, im, func, mode):
@ -95,15 +88,6 @@ class TestFormatHSV(PillowTestCase):
im = src.convert('HSV') im = src.convert('HSV')
comparable = self.to_hsv_colorsys(src) comparable = self.to_hsv_colorsys(src)
# print(im.getpixel((448, 64)))
# print(comparable.getpixel((448, 64)))
# print(im.split()[0].histogram())
# print(comparable.split()[0].histogram())
# im.split()[0].show()
# comparable.split()[0].show()
self.assert_image_similar(im.split()[0], comparable.split()[0], self.assert_image_similar(im.split()[0], comparable.split()[0],
1, "Hue conversion is wrong") 1, "Hue conversion is wrong")
self.assert_image_similar(im.split()[1], comparable.split()[1], self.assert_image_similar(im.split()[1], comparable.split()[1],
@ -111,16 +95,9 @@ class TestFormatHSV(PillowTestCase):
self.assert_image_similar(im.split()[2], comparable.split()[2], self.assert_image_similar(im.split()[2], comparable.split()[2],
1, "Value conversion is wrong") 1, "Value conversion is wrong")
# print(im.getpixel((192, 64)))
comparable = src comparable = src
im = im.convert('RGB') im = im.convert('RGB')
# im.split()[0].show()
# comparable.split()[0].show()
# print(im.getpixel((192, 64)))
# print(comparable.getpixel((192, 64)))
self.assert_image_similar(im.split()[0], comparable.split()[0], self.assert_image_similar(im.split()[0], comparable.split()[0],
3, "R conversion is wrong") 3, "R conversion is wrong")
self.assert_image_similar(im.split()[1], comparable.split()[1], self.assert_image_similar(im.split()[1], comparable.split()[1],
@ -132,12 +109,6 @@ class TestFormatHSV(PillowTestCase):
im = hopper('RGB').convert('HSV') im = hopper('RGB').convert('HSV')
comparable = self.to_hsv_colorsys(hopper('RGB')) comparable = self.to_hsv_colorsys(hopper('RGB'))
# print([ord(x) for x in im.split()[0].tobytes()[:80]])
# print([ord(x) for x in comparable.split()[0].tobytes()[:80]])
# print(im.split()[0].histogram())
# print(comparable.split()[0].histogram())
self.assert_image_similar(im.split()[0], comparable.split()[0], self.assert_image_similar(im.split()[0], comparable.split()[0],
1, "Hue conversion is wrong") 1, "Hue conversion is wrong")
self.assert_image_similar(im.split()[1], comparable.split()[1], self.assert_image_similar(im.split()[1], comparable.split()[1],
@ -150,12 +121,6 @@ class TestFormatHSV(PillowTestCase):
converted = comparable.convert('RGB') converted = comparable.convert('RGB')
comparable = self.to_rgb_colorsys(comparable) comparable = self.to_rgb_colorsys(comparable)
# print(converted.split()[1].histogram())
# print(target.split()[1].histogram())
# print([ord(x) for x in target.split()[1].tobytes()[:80]])
# print([ord(x) for x in converted.split()[1].tobytes()[:80]])
self.assert_image_similar(converted.split()[0], comparable.split()[0], self.assert_image_similar(converted.split()[0], comparable.split()[0],
3, "R conversion is wrong") 3, "R conversion is wrong")
self.assert_image_similar(converted.split()[1], comparable.split()[1], self.assert_image_similar(converted.split()[1], comparable.split()[1],

View File

@ -1,6 +1,5 @@
from __future__ import print_function
from helper import unittest, PillowTestCase, hopper
from PIL import Image, ImageDraw, ImageMode from PIL import Image, ImageDraw, ImageMode
from helper import unittest, PillowTestCase, hopper
class TestImagingResampleVulnerability(PillowTestCase): class TestImagingResampleVulnerability(PillowTestCase):
@ -324,10 +323,8 @@ class CoreResamplePassesTest(PillowTestCase):
class CoreResampleCoefficientsTest(PillowTestCase): class CoreResampleCoefficientsTest(PillowTestCase):
def test_reduce(self): def test_reduce(self):
test_color = 254 test_color = 254
# print()
for size in range(400000, 400010, 2): for size in range(400000, 400010, 2):
# print(size)
i = Image.new('L', (size, 1), 0) i = Image.new('L', (size, 1), 0)
draw = ImageDraw.Draw(i) draw = ImageDraw.Draw(i)
draw.rectangle((0, 0, i.size[0] // 2 - 1, 0), test_color) draw.rectangle((0, 0, i.size[0] // 2 - 1, 0), test_color)
@ -335,7 +332,6 @@ class CoreResampleCoefficientsTest(PillowTestCase):
px = i.resize((5, i.size[1]), Image.BICUBIC).load() px = i.resize((5, i.size[1]), Image.BICUBIC).load()
if px[2, 0] != test_color // 2: if px[2, 0] != test_color // 2:
self.assertEqual(test_color // 2, px[2, 0]) self.assertEqual(test_color // 2, px[2, 0])
# print('>', size, test_color // 2, px[2, 0])
def test_nonzero_coefficients(self): def test_nonzero_coefficients(self):
# regression test for the wrong coefficients calculation # regression test for the wrong coefficients calculation

View File

@ -1,9 +1,6 @@
from __future__ import print_function from PIL import Image, ImageMath
from helper import unittest, PillowTestCase from helper import unittest, PillowTestCase
from PIL import Image
from PIL import ImageMath
def pixel(im): def pixel(im):
if hasattr(im, "im"): if hasattr(im, "im"):

View File

@ -1,9 +1,7 @@
from __future__ import print_function import locale
from PIL import Image
from helper import unittest, PillowTestCase from helper import unittest, PillowTestCase
from PIL import Image
import locale
# ref https://github.com/python-pillow/Pillow/issues/272 # ref https://github.com/python-pillow/Pillow/issues/272
# on windows, in polish locale: # on windows, in polish locale:

View File

@ -54,7 +54,6 @@ class TestNumpy(PillowTestCase):
i = Image.fromarray(a) i = Image.fromarray(a)
if list(i.split()[0].getdata()) != list(range(100)): if list(i.split()[0].getdata()) != list(range(100)):
print("data mismatch for", dtype) print("data mismatch for", dtype)
# print(dtype, list(i.getdata()))
return i return i
# Check supported 1-bit integer formats # Check supported 1-bit integer formats

View File

@ -1,11 +1,7 @@
from __future__ import print_function from fractions import Fraction
from helper import unittest, PillowTestCase, hopper
from PIL import TiffImagePlugin, Image from PIL import TiffImagePlugin, Image
from PIL.TiffImagePlugin import IFDRational from PIL.TiffImagePlugin import IFDRational
from helper import unittest, PillowTestCase, hopper
from fractions import Fraction
class Test_IFDRational(PillowTestCase): class Test_IFDRational(PillowTestCase):