flake8 + typo: infile_temo -> infile_temp

This commit is contained in:
hugovk 2014-09-14 12:08:31 +03:00
parent 1de128d6b6
commit 8f9e338303

View File

@ -149,21 +149,26 @@ def Ghostscript(tile, size, fp, scale=1):
finally: finally:
try: try:
os.unlink(outfile) os.unlink(outfile)
if infile_temo: if infile_temp:
os.unlink(infile_temp) os.unlink(infile_temp)
except: pass except:
pass
return im return im
class PSFile: class PSFile:
"""Wrapper for bytesio object that treats either CR or LF as end of line.""" """
Wrapper for bytesio object that treats either CR or LF as end of line.
"""
def __init__(self, fp): def __init__(self, fp):
self.fp = fp self.fp = fp
self.char = None self.char = None
def seek(self, offset, whence=0): def seek(self, offset, whence=0):
self.char = None self.char = None
self.fp.seek(offset, whence) self.fp.seek(offset, whence)
def readline(self): def readline(self):
s = self.char or b"" s = self.char or b""
self.char = None self.char = None
@ -180,6 +185,7 @@ class PSFile:
return s.decode('latin-1') return s.decode('latin-1')
def _accept(prefix): def _accept(prefix):
return prefix[:4] == b"%!PS" or i32(prefix) == 0xC6D3D0C5 return prefix[:4] == b"%!PS" or i32(prefix) == 0xC6D3D0C5
@ -208,7 +214,7 @@ class EpsImageFile(ImageFile.ImageFile):
else: else:
# Python3, can use bare open command. # Python3, can use bare open command.
fp = open(self.fp.name, "Ur", encoding='latin-1') fp = open(self.fp.name, "Ur", encoding='latin-1')
except Exception as msg: except:
# Expect this for bytesio/stringio # Expect this for bytesio/stringio
fp = PSFile(self.fp) fp = PSFile(self.fp)
@ -314,7 +320,8 @@ class EpsImageFile(ImageFile.ImageFile):
# FIX for: Some EPS file not handled correctly / issue #302 # FIX for: Some EPS file not handled correctly / issue #302
# EPS can contain binary data # EPS can contain binary data
# or start directly with latin coding # or start directly with latin coding
# more info see http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf # more info see:
# http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf
offset = i32(s[4:8]) offset = i32(s[4:8])
length = i32(s[8:12]) length = i32(s[8:12])
else: else: