mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-21 04:34:47 +03:00
Add unregistered CommandViewer
This commit is contained in:
parent
d6e42f3307
commit
7ac3ae990f
|
@ -258,6 +258,26 @@ except ImportError:
|
|||
else:
|
||||
register(IPythonViewer)
|
||||
|
||||
class CommandViewer(Viewer):
|
||||
"""
|
||||
The viewer that use commands.
|
||||
Should be suitable for any OS
|
||||
"""
|
||||
|
||||
def get_command(self, file, **options):
|
||||
"""
|
||||
Substitute ``{}`` specifiers in ``command``
|
||||
:param options: kwargs that should have 'command' in it
|
||||
"""
|
||||
|
||||
if not "command" in options:
|
||||
raise TypeError("CommandViewer missing required keyword-only argument 'command'")
|
||||
command = options["command"]
|
||||
if not isinstance(command, str):
|
||||
raise TypeError(f"'command' must be 'str' not '{type(command)}'")
|
||||
values = {'file': file, **options}
|
||||
return command.format(values)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user