mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Remove ImageShow.Viewer.show_file file argument, deprecated in 9.1.0
This commit is contained in:
parent
5dbef9e0a8
commit
8d83d5e66a
|
@ -89,20 +89,3 @@ def test_ipythonviewer():
|
|||
|
||||
im = hopper()
|
||||
assert test_viewer.show(im) == 1
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not on_ci() or is_win32(),
|
||||
reason="Only run on CIs; hangs on Windows CIs",
|
||||
)
|
||||
@pytest.mark.parametrize("viewer", ImageShow._viewers)
|
||||
def test_file_deprecated(tmp_path, viewer):
|
||||
f = str(tmp_path / "temp.jpg")
|
||||
hopper().save(f)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
try:
|
||||
viewer.show_file(file=f)
|
||||
except NotImplementedError:
|
||||
pass
|
||||
with pytest.raises(TypeError):
|
||||
viewer.show_file()
|
||||
|
|
|
@ -12,19 +12,6 @@ Deprecated features
|
|||
Below are features which are considered deprecated. Where appropriate,
|
||||
a ``DeprecationWarning`` is issued.
|
||||
|
||||
ImageShow.Viewer.show_file file argument
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 9.1.0
|
||||
|
||||
The ``file`` argument in :py:meth:`~PIL.ImageShow.Viewer.show_file()` has been
|
||||
deprecated and will be removed in Pillow 10.0.0 (2023-07-01). It has been replaced by
|
||||
``path``.
|
||||
|
||||
In effect, ``viewer.show_file("test.jpg")`` will continue to work unchanged.
|
||||
``viewer.show_file(file="test.jpg")`` will raise a deprecation warning, and suggest
|
||||
``viewer.show_file(path="test.jpg")`` instead.
|
||||
|
||||
Constants
|
||||
~~~~~~~~~
|
||||
|
||||
|
@ -208,6 +195,17 @@ Before Pillow 8.3.0, ``ImagePalette`` required palette data of particular length
|
|||
default, and the ``size`` parameter could be used to override that. Pillow 8.3.0
|
||||
removed the default required length, also removing the need for the ``size`` parameter.
|
||||
|
||||
ImageShow.Viewer.show_file file argument
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 9.1.0
|
||||
.. versionremoved:: 10.0.0
|
||||
|
||||
The ``file`` argument in :py:meth:`~PIL.ImageShow.Viewer.show_file()` has been
|
||||
removed and replaced by ``path``.
|
||||
|
||||
In effect, ``viewer.show_file("test.jpg")`` will continue to work unchanged.
|
||||
|
||||
PyQt5 and PySide2
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ from shlex import quote
|
|||
|
||||
from PIL import Image
|
||||
|
||||
from ._deprecate import deprecate
|
||||
|
||||
_viewers = []
|
||||
|
||||
|
||||
|
@ -111,21 +109,10 @@ class Viewer:
|
|||
"""Display the given image."""
|
||||
return self.show_file(self.save_image(image), **options)
|
||||
|
||||
def show_file(self, path=None, **options):
|
||||
def show_file(self, path, **options):
|
||||
"""
|
||||
Display given file.
|
||||
|
||||
Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
|
||||
and will be removed in Pillow 10.0.0 (2023-07-01). ``path`` should be used
|
||||
instead.
|
||||
"""
|
||||
if path is None:
|
||||
if "file" in options:
|
||||
deprecate("The 'file' argument", 10, "'path'")
|
||||
path = options.pop("file")
|
||||
else:
|
||||
msg = "Missing required argument: 'path'"
|
||||
raise TypeError(msg)
|
||||
os.system(self.get_command(path, **options)) # nosec
|
||||
return 1
|
||||
|
||||
|
@ -164,21 +151,10 @@ class MacViewer(Viewer):
|
|||
command = f"({command} {quote(file)}; sleep 20; rm -f {quote(file)})&"
|
||||
return command
|
||||
|
||||
def show_file(self, path=None, **options):
|
||||
def show_file(self, path, **options):
|
||||
"""
|
||||
Display given file.
|
||||
|
||||
Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
|
||||
and will be removed in Pillow 10.0.0 (2023-07-01). ``path`` should be used
|
||||
instead.
|
||||
"""
|
||||
if path is None:
|
||||
if "file" in options:
|
||||
deprecate("The 'file' argument", 10, "'path'")
|
||||
path = options.pop("file")
|
||||
else:
|
||||
msg = "Missing required argument: 'path'"
|
||||
raise TypeError(msg)
|
||||
subprocess.call(["open", "-a", "Preview.app", path])
|
||||
executable = sys.executable or shutil.which("python3")
|
||||
if executable:
|
||||
|
@ -215,21 +191,10 @@ class XDGViewer(UnixViewer):
|
|||
command = executable = "xdg-open"
|
||||
return command, executable
|
||||
|
||||
def show_file(self, path=None, **options):
|
||||
def show_file(self, path, **options):
|
||||
"""
|
||||
Display given file.
|
||||
|
||||
Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
|
||||
and will be removed in Pillow 10.0.0 (2023-07-01). ``path`` should be used
|
||||
instead.
|
||||
"""
|
||||
if path is None:
|
||||
if "file" in options:
|
||||
deprecate("The 'file' argument", 10, "'path'")
|
||||
path = options.pop("file")
|
||||
else:
|
||||
msg = "Missing required argument: 'path'"
|
||||
raise TypeError(msg)
|
||||
subprocess.Popen(["xdg-open", path])
|
||||
return 1
|
||||
|
||||
|
@ -246,20 +211,10 @@ class DisplayViewer(UnixViewer):
|
|||
command += f" -title {quote(title)}"
|
||||
return command, executable
|
||||
|
||||
def show_file(self, path=None, **options):
|
||||
def show_file(self, path, **options):
|
||||
"""
|
||||
Display given file.
|
||||
|
||||
Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
|
||||
and ``path`` should be used instead.
|
||||
"""
|
||||
if path is None:
|
||||
if "file" in options:
|
||||
deprecate("The 'file' argument", 10, "'path'")
|
||||
path = options.pop("file")
|
||||
else:
|
||||
msg = "Missing required argument: 'path'"
|
||||
raise TypeError(msg)
|
||||
args = ["display"]
|
||||
title = options.get("title")
|
||||
if title:
|
||||
|
@ -278,20 +233,10 @@ class GmDisplayViewer(UnixViewer):
|
|||
command = "gm display"
|
||||
return command, executable
|
||||
|
||||
def show_file(self, path=None, **options):
|
||||
def show_file(self, path, **options):
|
||||
"""
|
||||
Display given file.
|
||||
|
||||
Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
|
||||
and ``path`` should be used instead.
|
||||
"""
|
||||
if path is None:
|
||||
if "file" in options:
|
||||
deprecate("The 'file' argument", 10, "'path'")
|
||||
path = options.pop("file")
|
||||
else:
|
||||
msg = "Missing required argument: 'path'"
|
||||
raise TypeError(msg)
|
||||
subprocess.Popen(["gm", "display", path])
|
||||
return 1
|
||||
|
||||
|
@ -304,20 +249,10 @@ class EogViewer(UnixViewer):
|
|||
command = "eog -n"
|
||||
return command, executable
|
||||
|
||||
def show_file(self, path=None, **options):
|
||||
def show_file(self, path, **options):
|
||||
"""
|
||||
Display given file.
|
||||
|
||||
Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
|
||||
and ``path`` should be used instead.
|
||||
"""
|
||||
if path is None:
|
||||
if "file" in options:
|
||||
deprecate("The 'file' argument", 10, "'path'")
|
||||
path = options.pop("file")
|
||||
else:
|
||||
msg = "Missing required argument: 'path'"
|
||||
raise TypeError(msg)
|
||||
subprocess.Popen(["eog", "-n", path])
|
||||
return 1
|
||||
|
||||
|
@ -336,20 +271,10 @@ class XVViewer(UnixViewer):
|
|||
command += f" -name {quote(title)}"
|
||||
return command, executable
|
||||
|
||||
def show_file(self, path=None, **options):
|
||||
def show_file(self, path, **options):
|
||||
"""
|
||||
Display given file.
|
||||
|
||||
Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
|
||||
and ``path`` should be used instead.
|
||||
"""
|
||||
if path is None:
|
||||
if "file" in options:
|
||||
deprecate("The 'file' argument", 10, "'path'")
|
||||
path = options.pop("file")
|
||||
else:
|
||||
msg = "Missing required argument: 'path'"
|
||||
raise TypeError(msg)
|
||||
args = ["xv"]
|
||||
title = options.get("title")
|
||||
if title:
|
||||
|
|
Loading…
Reference in New Issue
Block a user