mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-28 02:04:36 +03:00
Merge pull request #5380 from radarhere/accept
This commit is contained in:
commit
e2ac1d1c34
|
@ -136,25 +136,25 @@ def test_uncompressed_rgb():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test__validate_true():
|
def test__accept_true():
|
||||||
"""Check valid prefix"""
|
"""Check valid prefix"""
|
||||||
# Arrange
|
# Arrange
|
||||||
prefix = b"DDS etc"
|
prefix = b"DDS etc"
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
output = DdsImagePlugin._validate(prefix)
|
output = DdsImagePlugin._accept(prefix)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert output
|
assert output
|
||||||
|
|
||||||
|
|
||||||
def test__validate_false():
|
def test__accept_false():
|
||||||
"""Check invalid prefix"""
|
"""Check invalid prefix"""
|
||||||
# Arrange
|
# Arrange
|
||||||
prefix = b"something invalid"
|
prefix = b"something invalid"
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
output = DdsImagePlugin._validate(prefix)
|
output = DdsImagePlugin._accept(prefix)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert not output
|
assert not output
|
||||||
|
|
|
@ -417,9 +417,11 @@ class BLP2Decoder(_BLPBaseDecoder):
|
||||||
self.set_as_raw(bytes(data))
|
self.set_as_raw(bytes(data))
|
||||||
|
|
||||||
|
|
||||||
Image.register_open(
|
def _accept(prefix):
|
||||||
BlpImageFile.format, BlpImageFile, lambda p: p[:4] in (b"BLP1", b"BLP2")
|
return prefix[:4] in (b"BLP1", b"BLP2")
|
||||||
)
|
|
||||||
|
|
||||||
|
Image.register_open(BlpImageFile.format, BlpImageFile, _accept)
|
||||||
Image.register_extension(BlpImageFile.format, ".blp")
|
Image.register_extension(BlpImageFile.format, ".blp")
|
||||||
|
|
||||||
Image.register_decoder("BLP1", BLP1Decoder)
|
Image.register_decoder("BLP1", BLP1Decoder)
|
||||||
|
|
|
@ -182,9 +182,9 @@ class DdsImageFile(ImageFile.ImageFile):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _validate(prefix):
|
def _accept(prefix):
|
||||||
return prefix[:4] == b"DDS "
|
return prefix[:4] == b"DDS "
|
||||||
|
|
||||||
|
|
||||||
Image.register_open(DdsImageFile.format, DdsImageFile, _validate)
|
Image.register_open(DdsImageFile.format, DdsImageFile, _accept)
|
||||||
Image.register_extension(DdsImageFile.format, ".dds")
|
Image.register_extension(DdsImageFile.format, ".dds")
|
||||||
|
|
|
@ -98,9 +98,9 @@ class FtexImageFile(ImageFile.ImageFile):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _validate(prefix):
|
def _accept(prefix):
|
||||||
return prefix[:4] == MAGIC
|
return prefix[:4] == MAGIC
|
||||||
|
|
||||||
|
|
||||||
Image.register_open(FtexImageFile.format, FtexImageFile, _validate)
|
Image.register_open(FtexImageFile.format, FtexImageFile, _accept)
|
||||||
Image.register_extensions(FtexImageFile.format, [".ftc", ".ftu"])
|
Image.register_extensions(FtexImageFile.format, [".ftc", ".ftu"])
|
||||||
|
|
|
@ -359,7 +359,11 @@ def _save(im, fp, filename):
|
||||||
fp.write(f.read())
|
fp.write(f.read())
|
||||||
|
|
||||||
|
|
||||||
Image.register_open(IcnsImageFile.format, IcnsImageFile, lambda x: x[:4] == b"icns")
|
def _accept(prefix):
|
||||||
|
return prefix[:4] == b"icns"
|
||||||
|
|
||||||
|
|
||||||
|
Image.register_open(IcnsImageFile.format, IcnsImageFile, _accept)
|
||||||
Image.register_extension(IcnsImageFile.format, ".icns")
|
Image.register_extension(IcnsImageFile.format, ".icns")
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user