Add a stub Image class, to let poezio run even when Pillow isn’t installed.
This commit is contained in:
parent
d19046b5b1
commit
71ef2a362e
1 changed files with 5 additions and 2 deletions
|
@ -9,6 +9,9 @@ try:
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
HAS_PIL = True
|
HAS_PIL = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
class Image:
|
||||||
|
class Image:
|
||||||
|
pass
|
||||||
HAS_PIL = False
|
HAS_PIL = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -28,7 +31,7 @@ from poezio.config import config
|
||||||
from typing import Tuple, Optional, Callable
|
from typing import Tuple, Optional, Callable
|
||||||
|
|
||||||
|
|
||||||
def render_from_svg(svg: bytes) -> Optional[Image.Image]:
|
def render_svg(svg: bytes) -> Optional[Image.Image]:
|
||||||
if not HAS_RSVG:
|
if not HAS_RSVG:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
|
@ -79,7 +82,7 @@ class ImageWin(Win):
|
||||||
except OSError:
|
except OSError:
|
||||||
# TODO: Make the caller pass the MIME type, so we don’t
|
# TODO: Make the caller pass the MIME type, so we don’t
|
||||||
# have to try all renderers like that.
|
# have to try all renderers like that.
|
||||||
image = render_from_svg(data)
|
image = render_svg(data)
|
||||||
if image is None:
|
if image is None:
|
||||||
raise
|
raise
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
Loading…
Reference in a new issue