From aa1368f55115b6c33b9a741b55ee805bb567f209 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 23 Apr 2015 23:40:42 +1000 Subject: [PATCH] Flake8 fixes --- PIL/GifImagePlugin.py | 31 +++++++++++++++++-------------- Tests/test_file_gif.py | 4 ++-- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py index 69df28b30..cc41da949 100644 --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -308,6 +308,7 @@ def _save(im, fp, filename): except: pass + def get_interlace(im): try: interlace = im.encoderinfo["interlace"] @@ -317,9 +318,10 @@ def get_interlace(im): # workaround for @PIL153 if min(im.size) < 16: interlace = 0 - + return interlace + def get_local_header(fp, im, offset=(0, 0)): transparent_color_exists = False try: @@ -348,38 +350,39 @@ def get_local_header(fp, im, offset=(0, 0)): transparency_flag = 1 if transparent_color_exists else 0 if not transparent_color_exists: transparency = 0 - + fp.write(b"!" + - o8(249) + # extension intro - o8(4) + # length - o8(transparency_flag) + # transparency info present - o16(duration) + # duration - o8(transparency) + # transparency index + o8(249) + # extension intro + o8(4) + # length + o8(transparency_flag) + # transparency info present + o16(duration) + # duration + o8(transparency) + # transparency index o8(0)) if "loop" in im.encoderinfo: number_of_loops = im.encoderinfo["loop"] fp.write(b"!" + - o8(255) + # extension intro + o8(255) + # extension intro o8(11) + b"NETSCAPE2.0" + o8(3) + o8(1) + - o16(number_of_loops) + # number of loops + o16(number_of_loops) + # number of loops o8(0)) flags = 0 if get_interlace(im): flags = flags | 64 - + fp.write(b"," + - o16(offset[0]) + # offset + o16(offset[0]) + # offset o16(offset[1]) + - o16(im.size[0]) + # size + o16(im.size[0]) + # size o16(im.size[1]) + - o8(flags) + # flags - o8(8)) # bits + o8(flags) + # flags + o8(8)) # bits + def _save_netpbm(im, fp, filename): diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 1378fb3f6..3b682f86b 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -174,7 +174,7 @@ class TestFileGif(PillowTestCase): out = self.tempfile('temp.gif') fp = open(out, "wb") - im = Image.new('L',(100,100),'#000') + im = Image.new('L', (100, 100), '#000') for s in GifImagePlugin.getheader(im)[0] + GifImagePlugin.getdata(im, duration=duration): fp.write(s) fp.write(b";") @@ -188,7 +188,7 @@ class TestFileGif(PillowTestCase): out = self.tempfile('temp.gif') fp = open(out, "wb") - im = Image.new('L',(100,100),'#000') + im = Image.new('L', (100, 100), '#000') for s in GifImagePlugin.getheader(im)[0] + GifImagePlugin.getdata(im, loop=number_of_loops): fp.write(s) fp.write(b";")