Skip to content

Commit

Permalink
abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 13, 2024
1 parent dacff6b commit a168649
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ def _ensure_mutable(self):
else:
self.load()

def _dump(self, file: str | None = None, format: str | None = None, **options) -> str:
def _dump(
self, file: str | None = None, format: str | None = None, **options
) -> str:
suffix = ""
if format:
suffix = "." + format
Expand Down
15 changes: 12 additions & 3 deletions src/PIL/ImageShow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
#
from __future__ import annotations

import abc
import os
import shutil
import subprocess
import sys
from shlex import quote
from typing import Any, Type
from typing import Any

from . import Image

Expand Down Expand Up @@ -181,6 +182,10 @@ class UnixViewer(Viewer):
format = "PNG"
options = {"compress_level": 1, "save_all": True}

@abc.abstractmethod
def get_command_ex(self, file: str, **options: Any) -> tuple[str, str]:
pass

def get_command(self, file: str, **options: Any) -> str:
command = self.get_command_ex(file, **options)[0]
return f"({command} {quote(file)}"
Expand Down Expand Up @@ -209,7 +214,9 @@ class DisplayViewer(UnixViewer):
This viewer supports the ``title`` parameter.
"""

def get_command_ex(self, file: str, title: str | None = None, **options: Any) -> tuple[str, str]:
def get_command_ex(
self, file: str, title: str | None = None, **options: Any
) -> tuple[str, str]:
command = executable = "display"
if title:
command += f" -title {quote(title)}"
Expand Down Expand Up @@ -267,7 +274,9 @@ class XVViewer(UnixViewer):
This viewer supports the ``title`` parameter.
"""

def get_command_ex(self, file: str, title: str | None = None, **options: Any) -> tuple[str, str]:
def get_command_ex(
self, file: str, title: str | None = None, **options: Any
) -> tuple[str, str]:
# note: xv is pretty outdated. most modern systems have
# imagemagick's display command instead.
command = executable = "xv"
Expand Down

0 comments on commit a168649

Please sign in to comment.