Merge pull request #3685 from radarhere/file

Renamed file variable
This commit is contained in:
Hugo 2019-03-03 10:15:33 +02:00 committed by GitHub
commit 571aca6610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -12,11 +12,11 @@ YA_EXTRA_DIR = "Tests/images/msp"
class TestFileMsp(PillowTestCase):
def test_sanity(self):
file = self.tempfile("temp.msp")
test_file = self.tempfile("temp.msp")
hopper("1").save(file)
hopper("1").save(test_file)
im = Image.open(file)
im = Image.open(test_file)
im.load()
self.assertEqual(im.mode, "1")
self.assertEqual(im.size, (128, 128))

View File

@ -604,16 +604,16 @@ def _save_netpbm(im, fp, filename):
import os
from subprocess import Popen, check_call, PIPE, CalledProcessError
file = im._dump()
tempfile = im._dump()
with open(filename, 'wb') as f:
if im.mode != "RGB":
with open(os.devnull, 'wb') as devnull:
check_call(["ppmtogif", file], stdout=f, stderr=devnull)
check_call(["ppmtogif", tempfile], stdout=f, stderr=devnull)
else:
# Pipe ppmquant output into ppmtogif
# "ppmquant 256 %s | ppmtogif > %s" % (file, filename)
quant_cmd = ["ppmquant", "256", file]
# "ppmquant 256 %s | ppmtogif > %s" % (tempfile, filename)
quant_cmd = ["ppmquant", "256", tempfile]
togif_cmd = ["ppmtogif"]
with open(os.devnull, 'wb') as devnull:
quant_proc = Popen(quant_cmd, stdout=PIPE, stderr=devnull)
@ -632,7 +632,7 @@ def _save_netpbm(im, fp, filename):
raise CalledProcessError(retcode, togif_cmd)
try:
os.unlink(file)
os.unlink(tempfile)
except OSError:
pass