mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Remove FitsStubImagePlugin, deprecated in 9.1.0
This commit is contained in:
parent
c8ec15980b
commit
575a038f97
|
@ -2,7 +2,7 @@ from io import BytesIO
|
|||
|
||||
import pytest
|
||||
|
||||
from PIL import FitsImagePlugin, FitsStubImagePlugin, Image
|
||||
from PIL import FitsImagePlugin, Image
|
||||
|
||||
from .helper import assert_image_equal, hopper
|
||||
|
||||
|
@ -48,39 +48,3 @@ def test_comment():
|
|||
image_data = b"SIMPLE = T / comment string"
|
||||
with pytest.raises(OSError):
|
||||
FitsImagePlugin.FitsImageFile(BytesIO(image_data))
|
||||
|
||||
|
||||
def test_stub_deprecated():
|
||||
class Handler:
|
||||
opened = False
|
||||
loaded = False
|
||||
|
||||
def open(self, im):
|
||||
self.opened = True
|
||||
|
||||
def load(self, im):
|
||||
self.loaded = True
|
||||
im.fp.close()
|
||||
return Image.new("RGB", (1, 1))
|
||||
|
||||
handler = Handler()
|
||||
with pytest.warns(DeprecationWarning):
|
||||
FitsStubImagePlugin.register_handler(handler)
|
||||
|
||||
with Image.open(TEST_FILE) as im:
|
||||
assert im.format == "FITS"
|
||||
assert im.size == (128, 128)
|
||||
assert im.mode == "L"
|
||||
|
||||
assert handler.opened
|
||||
assert not handler.loaded
|
||||
|
||||
im.load()
|
||||
assert handler.loaded
|
||||
|
||||
FitsStubImagePlugin._handler = None
|
||||
Image.register_open(
|
||||
FitsImagePlugin.FitsImageFile.format,
|
||||
FitsImagePlugin.FitsImageFile,
|
||||
FitsImagePlugin._accept,
|
||||
)
|
||||
|
|
|
@ -12,15 +12,6 @@ Deprecated features
|
|||
Below are features which are considered deprecated. Where appropriate,
|
||||
a ``DeprecationWarning`` is issued.
|
||||
|
||||
FitsStubImagePlugin
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 9.1.0
|
||||
|
||||
The stub image plugin ``FitsStubImagePlugin`` has been deprecated and will be removed in
|
||||
Pillow 10.0.0 (2023-07-01). FITS images can be read without a handler through
|
||||
:mod:`~PIL.FitsImagePlugin` instead.
|
||||
|
||||
FreeTypeFont.getmask2 fill parameter
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -207,6 +198,15 @@ Removed Use instead
|
|||
``PngImagePlugin.APNG_BLEND_OP_OVER`` ``PngImagePlugin.Blend.OP_OVER``
|
||||
===================================================== ============================================================
|
||||
|
||||
FitsStubImagePlugin
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 9.1.0
|
||||
.. versionremoved:: 10.0.0
|
||||
|
||||
The stub image plugin ``FitsStubImagePlugin`` has been removed.
|
||||
FITS images can be read without a handler through :mod:`~PIL.FitsImagePlugin` instead.
|
||||
|
||||
PyQt5 and PySide2
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
#
|
||||
# The Python Imaging Library
|
||||
# $Id$
|
||||
#
|
||||
# FITS stub adapter
|
||||
#
|
||||
# Copyright (c) 1998-2003 by Fredrik Lundh
|
||||
#
|
||||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from . import FitsImagePlugin, Image, ImageFile
|
||||
from ._deprecate import deprecate
|
||||
|
||||
_handler = None
|
||||
|
||||
|
||||
def register_handler(handler):
|
||||
"""
|
||||
Install application-specific FITS image handler.
|
||||
|
||||
:param handler: Handler object.
|
||||
"""
|
||||
global _handler
|
||||
_handler = handler
|
||||
|
||||
deprecate(
|
||||
"FitsStubImagePlugin",
|
||||
10,
|
||||
action="FITS images can now be read without "
|
||||
"a handler through FitsImagePlugin instead",
|
||||
)
|
||||
|
||||
# Override FitsImagePlugin with this handler
|
||||
# for backwards compatibility
|
||||
try:
|
||||
Image.ID.remove(FITSStubImageFile.format)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
Image.register_open(
|
||||
FITSStubImageFile.format, FITSStubImageFile, FitsImagePlugin._accept
|
||||
)
|
||||
|
||||
|
||||
class FITSStubImageFile(ImageFile.StubImageFile):
|
||||
format = FitsImagePlugin.FitsImageFile.format
|
||||
format_description = FitsImagePlugin.FitsImageFile.format_description
|
||||
|
||||
def _open(self):
|
||||
offset = self.fp.tell()
|
||||
|
||||
im = FitsImagePlugin.FitsImageFile(self.fp)
|
||||
self._size = im.size
|
||||
self.mode = im.mode
|
||||
self.tile = []
|
||||
|
||||
self.fp.seek(offset)
|
||||
|
||||
loader = self._load()
|
||||
if loader:
|
||||
loader.open(self)
|
||||
|
||||
def _load(self):
|
||||
return _handler
|
||||
|
||||
|
||||
def _save(im, fp, filename):
|
||||
msg = "FITS save handler not installed"
|
||||
raise OSError(msg)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Registry
|
||||
|
||||
Image.register_save(FITSStubImageFile.format, _save)
|
|
@ -31,7 +31,6 @@ _plugins = [
|
|||
"DdsImagePlugin",
|
||||
"EpsImagePlugin",
|
||||
"FitsImagePlugin",
|
||||
"FitsStubImagePlugin",
|
||||
"FliImagePlugin",
|
||||
"FpxImagePlugin",
|
||||
"FtexImagePlugin",
|
||||
|
|
Loading…
Reference in New Issue
Block a user