From 923018dfeb31ee88ef7b840b810fe654f2738b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Tue, 7 Jan 2014 21:21:24 -0500 Subject: [PATCH 1/5] MAINT: s/while 1:/while True:/ --- PIL/OleFileIO.py | 2 +- PIL/TiffImagePlugin.py | 2 +- Tests/threaded_save.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PIL/OleFileIO.py b/PIL/OleFileIO.py index b7c984169..2367841e0 100644 --- a/PIL/OleFileIO.py +++ b/PIL/OleFileIO.py @@ -248,7 +248,7 @@ class OleFileIO: if entry[1:2] == "Image": fin = ole.openstream(entry) fout = open(entry[0:1], "wb") - while 1: + while True: s = fin.read(8192) if not s: break diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 3c62fd2dd..68a77e9ca 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1141,7 +1141,7 @@ def _save(im, fp, filename): # print (im.mode, compression, a, im.encoderconfig) e = Image._getencoder(im.mode, 'libtiff', a, im.encoderconfig) e.setimage(im.im, (0,0)+im.size) - while 1: + while True: l, s, d = e.encode(16*1024) # undone, change to self.decodermaxblock if not _fp: fp.write(d) diff --git a/Tests/threaded_save.py b/Tests/threaded_save.py index 8162e713c..471e24815 100644 --- a/Tests/threaded_save.py +++ b/Tests/threaded_save.py @@ -18,7 +18,7 @@ result = [] class Worker(threading.Thread): def run(self): - while 1: + while True: im = queue.get() if im is None: queue.task_done() From 980517587db21fb40b5e73cd0a6bc049bfc38b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Tue, 7 Jan 2014 21:24:21 -0500 Subject: [PATCH 2/5] MAINT: use is instead of == for True, False, None --- PIL/SpiderImagePlugin.py | 2 +- Tests/cms_test.py | 20 ++++++++++---------- Tests/test_file_eps.py | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/PIL/SpiderImagePlugin.py b/PIL/SpiderImagePlugin.py index 9e814932d..cd97c524d 100644 --- a/PIL/SpiderImagePlugin.py +++ b/PIL/SpiderImagePlugin.py @@ -182,7 +182,7 @@ class SpiderImageFile(ImageFile.ImageFile): # given a list of filenames, return a list of images def loadImageSeries(filelist=None): " create a list of Image.images for use in montage " - if filelist == None or len(filelist) < 1: + if filelist is None or len(filelist) < 1: return imglist = [] diff --git a/Tests/cms_test.py b/Tests/cms_test.py index 634e3f717..1bd406ca9 100644 --- a/Tests/cms_test.py +++ b/Tests/cms_test.py @@ -47,7 +47,7 @@ TEST_misc = False ####################################################################### def outputImage(im, funcName = None): # save or display the image, depending on value of SHOW_IMAGES - if SHOW == True: + if SHOW is True: im.show() else: im.save(os.path.join(OUTPUTDIR, "%s.tif" %funcName)) @@ -57,7 +57,7 @@ def outputImage(im, funcName = None): # The tests themselves ####################################################################### -if TEST_error_catching == True: +if TEST_error_catching is True: im = Image.open(IMAGE) try: #neither of these proifles exists (unless you make them), so we should @@ -70,7 +70,7 @@ if TEST_error_catching == True: print("error catching test completed successfully (if you see the message \ above that we caught the error).") -if TEST_profileToProfile == True: +if TEST_profileToProfile is True: # open the image file using the standard PIL function Image.open() im = Image.open(IMAGE) @@ -84,7 +84,7 @@ if TEST_profileToProfile == True: print("profileToProfile test completed successfully.") -if TEST_profileToProfile_inPlace == True: +if TEST_profileToProfile_inPlace is True: # we'll do the same test as profileToProfile, but modify im in place # instead of getting a new image returned to us im = Image.open(IMAGE) @@ -94,7 +94,7 @@ if TEST_profileToProfile_inPlace == True: outputMode = OUTMODE, inPlace = True) # now that the image is converted, save or display it - if result == None: + if result is None: # this is the normal result when modifying in-place outputImage(im, "profileToProfile_inPlace") else: @@ -103,7 +103,7 @@ if TEST_profileToProfile_inPlace == True: print("profileToProfile in-place test completed successfully.") -if TEST_buildTransform == True: +if TEST_buildTransform is True: # make a transform using the input and output profile path strings transform = ImageCms.buildTransform(INPUT_PROFILE, OUTPUT_PROFILE, INMODE, \ OUTMODE) @@ -126,7 +126,7 @@ if TEST_buildTransform == True: # Python should also do this automatically when it goes out of scope. del(transform) -if TEST_buildTransformFromOpenProfiles == True: +if TEST_buildTransformFromOpenProfiles is True: # we'll actually test a couple profile open/creation functions here too # first, get a handle to an input profile, in this case we'll create @@ -160,7 +160,7 @@ if TEST_buildTransformFromOpenProfiles == True: del(outputProfile) del(transform) -if TEST_buildProofTransform == True: +if TEST_buildProofTransform is True: # make a transform using the input and output and proof profile path # strings # images converted with this transform will simulate the appearance @@ -188,7 +188,7 @@ if TEST_buildProofTransform == True: # Python should also do this automatically when it goes out of scope. del(transform) -if TEST_getProfileInfo == True: +if TEST_getProfileInfo is True: # get a profile handle profile = ImageCms.getOpenProfile(INPUT_PROFILE) @@ -212,7 +212,7 @@ if TEST_getProfileInfo == True: print("getProfileInfo test completed successfully.") -if TEST_misc == True: +if TEST_misc is True: # test the versions, about, and copyright functions print("Versions: %s" %str(ImageCms.versions())) print("About:\n\n%s" %ImageCms.about()) diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index f9e1702ef..f9f781dd6 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -3,10 +3,10 @@ from tester import * from PIL import Image, EpsImagePlugin import sys -if EpsImagePlugin.gs_windows_binary == False: - # already checked. Not there. +if EpsImagePlugin.gs_windows_binary is False: + # already checked. Not there. skip() - + if not sys.platform.startswith('win'): import subprocess try: From 9f7765100148fe448e920116157b42ca3c89f2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Tue, 7 Jan 2014 21:30:37 -0500 Subject: [PATCH 3/5] FIX: travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1eecc9c13..1d0f5c191 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ python: - 3.2 - 3.3 -install: "sudo apt-get -qq install libfreetype6-dev liblcms2-dev libwebp-dev python-qt4 ghostscript"" +install: "sudo apt-get -qq install libfreetype6-dev liblcms2-dev libwebp-dev python-qt4 ghostscript" script: - python setup.py clean From 6b53d0d007582bed409bdc679e20417e65ca4e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Wed, 8 Jan 2014 08:43:01 -0500 Subject: [PATCH 4/5] MAINT: replace is True: by : --- Tests/cms_test.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Tests/cms_test.py b/Tests/cms_test.py index 1bd406ca9..464c9c7ef 100644 --- a/Tests/cms_test.py +++ b/Tests/cms_test.py @@ -47,7 +47,7 @@ TEST_misc = False ####################################################################### def outputImage(im, funcName = None): # save or display the image, depending on value of SHOW_IMAGES - if SHOW is True: + if SHOW: im.show() else: im.save(os.path.join(OUTPUTDIR, "%s.tif" %funcName)) @@ -57,7 +57,7 @@ def outputImage(im, funcName = None): # The tests themselves ####################################################################### -if TEST_error_catching is True: +if TEST_error_catching: im = Image.open(IMAGE) try: #neither of these proifles exists (unless you make them), so we should @@ -70,7 +70,7 @@ if TEST_error_catching is True: print("error catching test completed successfully (if you see the message \ above that we caught the error).") -if TEST_profileToProfile is True: +if TEST_profileToProfile: # open the image file using the standard PIL function Image.open() im = Image.open(IMAGE) @@ -84,7 +84,7 @@ if TEST_profileToProfile is True: print("profileToProfile test completed successfully.") -if TEST_profileToProfile_inPlace is True: +if TEST_profileToProfile_inPlace: # we'll do the same test as profileToProfile, but modify im in place # instead of getting a new image returned to us im = Image.open(IMAGE) @@ -103,7 +103,7 @@ if TEST_profileToProfile_inPlace is True: print("profileToProfile in-place test completed successfully.") -if TEST_buildTransform is True: +if TEST_buildTransform: # make a transform using the input and output profile path strings transform = ImageCms.buildTransform(INPUT_PROFILE, OUTPUT_PROFILE, INMODE, \ OUTMODE) @@ -126,7 +126,7 @@ if TEST_buildTransform is True: # Python should also do this automatically when it goes out of scope. del(transform) -if TEST_buildTransformFromOpenProfiles is True: +if TEST_buildTransformFromOpenProfiles: # we'll actually test a couple profile open/creation functions here too # first, get a handle to an input profile, in this case we'll create @@ -160,7 +160,7 @@ if TEST_buildTransformFromOpenProfiles is True: del(outputProfile) del(transform) -if TEST_buildProofTransform is True: +if TEST_buildProofTransform: # make a transform using the input and output and proof profile path # strings # images converted with this transform will simulate the appearance @@ -188,7 +188,7 @@ if TEST_buildProofTransform is True: # Python should also do this automatically when it goes out of scope. del(transform) -if TEST_getProfileInfo is True: +if TEST_getProfileInfo: # get a profile handle profile = ImageCms.getOpenProfile(INPUT_PROFILE) @@ -212,7 +212,7 @@ if TEST_getProfileInfo is True: print("getProfileInfo test completed successfully.") -if TEST_misc is True: +if TEST_misc: # test the versions, about, and copyright functions print("Versions: %s" %str(ImageCms.versions())) print("About:\n\n%s" %ImageCms.about()) From ead121d951f311b7c20781635a82600f71c9ab26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Wed, 8 Jan 2014 22:07:35 -0500 Subject: [PATCH 5/5] MAINT replace is False by not --- PIL/EpsImagePlugin.py | 2 +- Tests/test_file_eps.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PIL/EpsImagePlugin.py b/PIL/EpsImagePlugin.py index a8706b05f..71269036e 100644 --- a/PIL/EpsImagePlugin.py +++ b/PIL/EpsImagePlugin.py @@ -80,7 +80,7 @@ def Ghostscript(tile, size, fp, scale=1): ] if gs_windows_binary is not None: - if gs_windows_binary is False: + if not gs_windows_binary: raise WindowsError('Unable to locate Ghostscript on paths') command[0] = gs_windows_binary diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index f9f781dd6..ed5c77c99 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -3,7 +3,7 @@ from tester import * from PIL import Image, EpsImagePlugin import sys -if EpsImagePlugin.gs_windows_binary is False: +if not EpsImagePlugin.gs_windows_binary: # already checked. Not there. skip()