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.
#
from __future__ import print_function
from PIL import Image, FontFile
from .exceptions import InvalidFileType
@ -108,20 +107,6 @@ class BdfFontFile(FontFile.FontFile):
if s.find(b"LogicalFontDescription") < 0:
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:
c = bdf_char(fp)
if not c:

View File

@ -16,7 +16,6 @@
# See the README file for information on usage and redistribution.
#
from __future__ import print_function
from PIL import Image, BmpImagePlugin, _binary
from .exceptions import InvalidFileType
@ -60,14 +59,6 @@ class CurImageFile(BmpImagePlugin.BmpImageFile):
m = s
elif i8(s[0]) > i8(m[0]) and i8(s[1]) > i8(m[1]):
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:
raise TypeError("No cursors were found")

View File

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

View File

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

View File

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

View File

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

View File

@ -5,11 +5,10 @@
#
# Copyright (c) 2014 Dov Grobgeld <dov.grobgeld@gmail.com>
from __future__ import print_function
import re
from PIL import Image
from PIL import _imagingmorph
import re
LUT_SIZE = 1 << 9
@ -152,11 +151,6 @@ class LutBuilder(object):
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
for i, pattern in enumerate(patterns):
p = pattern[0].replace('.', 'X').replace('X', '[01]')

View File

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

View File

@ -15,7 +15,6 @@
# See the README file for information on usage and redistribution.
#
from __future__ import print_function
import os
import tempfile
from PIL import Image, ImageFile, _binary
@ -44,12 +43,6 @@ def i(c):
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
# from TIFF and JPEG files, use the <b>getiptcinfo</b> function.
@ -108,8 +101,6 @@ class IptcImageFile(ImageFile.ImageFile):
else:
self.info[tag] = tagdata
# print(tag, self.info[tag])
# mode
layers = i8(self.info[(3, 60)][0])
component = i8(self.info[(3, 60)][1])

View File

@ -32,8 +32,6 @@
# See the README file for information on usage and redistribution.
#
from __future__ import print_function
import array
import struct
import io
@ -319,7 +317,6 @@ class JpegImageFile(ImageFile.ImageFile):
if i in MARKER:
name, description, handler = MARKER[i]
# print(hex(i), name, description)
if handler is not None:
handler(self, i)
if i == 0xFFDA: # start of scan

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,27 +39,6 @@ class TestFileIptc(PillowTestCase):
# Assert
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__':
unittest.main()

View File

@ -48,29 +48,6 @@ class TestImageSpider(PillowTestCase):
self.assertEqual(im.n_frames, 1)
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):
# Arrange
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 itertools
from PIL import Image
from helper import unittest, PillowTestCase, hopper
class TestFormatHSV(PillowTestCase):
@ -47,10 +44,6 @@ class TestFormatHSV(PillowTestCase):
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
def to_xxx_colorsys(self, im, func, mode):
@ -95,15 +88,6 @@ class TestFormatHSV(PillowTestCase):
im = src.convert('HSV')
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],
1, "Hue conversion is wrong")
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],
1, "Value conversion is wrong")
# print(im.getpixel((192, 64)))
comparable = src
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],
3, "R conversion is wrong")
self.assert_image_similar(im.split()[1], comparable.split()[1],
@ -132,12 +109,6 @@ class TestFormatHSV(PillowTestCase):
im = hopper('RGB').convert('HSV')
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],
1, "Hue conversion is wrong")
self.assert_image_similar(im.split()[1], comparable.split()[1],
@ -150,12 +121,6 @@ class TestFormatHSV(PillowTestCase):
converted = comparable.convert('RGB')
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],
3, "R conversion is wrong")
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 helper import unittest, PillowTestCase, hopper
class TestImagingResampleVulnerability(PillowTestCase):
@ -324,10 +323,8 @@ class CoreResamplePassesTest(PillowTestCase):
class CoreResampleCoefficientsTest(PillowTestCase):
def test_reduce(self):
test_color = 254
# print()
for size in range(400000, 400010, 2):
# print(size)
i = Image.new('L', (size, 1), 0)
draw = ImageDraw.Draw(i)
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()
if px[2, 0] != test_color // 2:
self.assertEqual(test_color // 2, px[2, 0])
# print('>', size, test_color // 2, px[2, 0])
def test_nonzero_coefficients(self):
# 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 PIL import Image
from PIL import ImageMath
def pixel(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 PIL import Image
import locale
# ref https://github.com/python-pillow/Pillow/issues/272
# on windows, in polish locale:

View File

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

View File

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