mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
[image] Fix linting and formatting issues (#7440)
This commit is contained in:
parent
08c0715a30
commit
e4c90489f7
1 changed files with 9 additions and 8 deletions
|
@ -1,18 +1,17 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
import io
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from magic import Magic
|
from magic import Magic
|
||||||
|
|
||||||
from esphome import core
|
from esphome import core, external_files
|
||||||
from esphome.components import font
|
|
||||||
from esphome import external_files
|
|
||||||
import esphome.config_validation as cv
|
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
|
from esphome.components import font
|
||||||
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_DITHER,
|
CONF_DITHER,
|
||||||
CONF_FILE,
|
CONF_FILE,
|
||||||
|
@ -239,12 +238,11 @@ CONFIG_SCHEMA = cv.All(font.validate_pillow_installed, IMAGE_SCHEMA)
|
||||||
|
|
||||||
def load_svg_image(file: bytes, resize: tuple[int, int]):
|
def load_svg_image(file: bytes, resize: tuple[int, int]):
|
||||||
# Local import only to allow "validate_pillow_installed" to run *before* importing it
|
# Local import only to allow "validate_pillow_installed" to run *before* importing it
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
# This import is only needed in case of SVG images; adding it
|
# This import is only needed in case of SVG images; adding it
|
||||||
# to the top would force configurations not using SVG to also have it
|
# to the top would force configurations not using SVG to also have it
|
||||||
# installed for no reason.
|
# installed for no reason.
|
||||||
from cairosvg import svg2png
|
from cairosvg import svg2png
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
if resize:
|
if resize:
|
||||||
req_width, req_height = resize
|
req_width, req_height = resize
|
||||||
|
@ -274,6 +272,9 @@ async def to_code(config):
|
||||||
elif conf_file[CONF_SOURCE] == SOURCE_WEB:
|
elif conf_file[CONF_SOURCE] == SOURCE_WEB:
|
||||||
path = compute_local_image_path(conf_file).as_posix()
|
path = compute_local_image_path(conf_file).as_posix()
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise core.EsphomeError(f"Unknown image source: {conf_file[CONF_SOURCE]}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(path, "rb") as f:
|
with open(path, "rb") as f:
|
||||||
file_contents = f.read()
|
file_contents = f.read()
|
||||||
|
|
Loading…
Reference in a new issue