mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-23 15:20:33 +03:00
Replace slice and comparison with endswith
This commit is contained in:
parent
1e574e6f8b
commit
9665eb3972
|
@ -155,9 +155,9 @@ class ImImageFile(ImageFile.ImageFile):
|
||||||
msg = "not an IM file"
|
msg = "not an IM file"
|
||||||
raise SyntaxError(msg)
|
raise SyntaxError(msg)
|
||||||
|
|
||||||
if s[-2:] == b"\r\n":
|
if s.endswith(b"\r\n"):
|
||||||
s = s[:-2]
|
s = s[:-2]
|
||||||
elif s[-1:] == b"\n":
|
elif s.endswith(b"\n"):
|
||||||
s = s[:-1]
|
s = s[:-1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -54,7 +54,7 @@ class MicImageFile(TiffImagePlugin.TiffImageFile):
|
||||||
self.images = [
|
self.images = [
|
||||||
path
|
path
|
||||||
for path in self.ole.listdir()
|
for path in self.ole.listdir()
|
||||||
if path[1:] and path[0][-4:] == ".ACI" and path[1] == "Image"
|
if path[1:] and path[0].endswith(".ACI") and path[1] == "Image"
|
||||||
]
|
]
|
||||||
|
|
||||||
# if we didn't find any images, this is probably not
|
# if we didn't find any images, this is probably not
|
||||||
|
|
|
@ -67,9 +67,9 @@ class XpmImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
for _ in range(pal):
|
for _ in range(pal):
|
||||||
s = self.fp.readline()
|
s = self.fp.readline()
|
||||||
if s[-2:] == b"\r\n":
|
if s.endswith(b"\r\n"):
|
||||||
s = s[:-2]
|
s = s[:-2]
|
||||||
elif s[-1:] in b"\r\n":
|
elif s.endswith((b"\r", b"\n")):
|
||||||
s = s[:-1]
|
s = s[:-1]
|
||||||
|
|
||||||
c = s[1]
|
c = s[1]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user