mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 08:28:12 +01:00
Lint
This commit is contained in:
parent
9ea9b4b102
commit
1576e1847e
5 changed files with 12 additions and 20 deletions
|
@ -15,7 +15,8 @@ RUN platformio settings set enable_telemetry No && \
|
||||||
platformio run -e espressif32 -e espressif8266; exit 0
|
platformio run -e espressif32 -e espressif8266; exit 0
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pip install -e .
|
RUN pip install -e . && \
|
||||||
|
pip install pillow tzlocal
|
||||||
|
|
||||||
WORKDIR /config
|
WORKDIR /config
|
||||||
ENTRYPOINT ["esphomeyaml"]
|
ENTRYPOINT ["esphomeyaml"]
|
||||||
|
|
|
@ -27,6 +27,6 @@ RUN apt-get update && apt-get install -y \
|
||||||
binfmt-support \
|
binfmt-support \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY hassio-builder.sh /usr/bin/
|
COPY docker/hassio-builder.sh /usr/bin/
|
||||||
|
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
FROM python:2.7
|
FROM python:2.7
|
||||||
|
|
||||||
RUN pip install -r requirements.txt && \
|
COPY requirements.txt /requirements.txt
|
||||||
pip install flake8==3.5.0 pylint==1.8.4
|
|
||||||
|
RUN pip install -r /requirements.txt && \
|
||||||
|
pip install flake8==3.5.0 pylint==1.8.4 tzlocal pillow
|
||||||
|
|
|
@ -46,7 +46,7 @@ def validate_pillow_installed(value):
|
||||||
try:
|
try:
|
||||||
import PIL
|
import PIL
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise vol.Invalid("Please install the pillow python package to use fonts. "
|
raise vol.Invalid("Please install the pillow python package to use this feature. "
|
||||||
"(pip2 install pillow)")
|
"(pip2 install pillow)")
|
||||||
|
|
||||||
if PIL.__version__[0] < '4':
|
if PIL.__version__[0] < '4':
|
||||||
|
@ -103,7 +103,7 @@ def to_code(config):
|
||||||
_, (offset_x, offset_y) = font.font.getsize(glyph)
|
_, (offset_x, offset_y) = font.font.getsize(glyph)
|
||||||
width, height = mask.size
|
width, height = mask.size
|
||||||
width8 = ((width + 7) // 8) * 8
|
width8 = ((width + 7) // 8) * 8
|
||||||
glyph_data = [0 for _ in range(height * width8 // 8)]
|
glyph_data = [0 for _ in range(height * width8 // 8)] # noqa: F812
|
||||||
for y in range(height):
|
for y in range(height):
|
||||||
for x in range(width):
|
for x in range(width):
|
||||||
if not mask.getpixel((x, y)):
|
if not mask.getpixel((x, y)):
|
||||||
|
|
|
@ -6,7 +6,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
import esphomeyaml.config_validation as cv
|
import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml import core
|
from esphomeyaml import core
|
||||||
from esphomeyaml.components import display
|
from esphomeyaml.components import display, font
|
||||||
from esphomeyaml.const import CONF_FILE, CONF_ID, CONF_RESIZE
|
from esphomeyaml.const import CONF_FILE, CONF_ID, CONF_RESIZE
|
||||||
from esphomeyaml.core import HexInt
|
from esphomeyaml.core import HexInt
|
||||||
from esphomeyaml.helpers import App, ArrayInitializer, MockObj, Pvariable, RawExpression, add
|
from esphomeyaml.helpers import App, ArrayInitializer, MockObj, Pvariable, RawExpression, add
|
||||||
|
@ -18,17 +18,6 @@ DEPENDENCIES = ['display']
|
||||||
Image_ = display.display_ns.Image
|
Image_ = display.display_ns.Image
|
||||||
|
|
||||||
|
|
||||||
def validate_pillow_installed(value):
|
|
||||||
try:
|
|
||||||
# pylint: disable=unused-variable
|
|
||||||
import PIL
|
|
||||||
except ImportError:
|
|
||||||
raise vol.Invalid("Please install the pillow python package to use images. "
|
|
||||||
"(pip2 install pillow)")
|
|
||||||
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def validate_image_file(value):
|
def validate_image_file(value):
|
||||||
value = cv.string(value)
|
value = cv.string(value)
|
||||||
path = os.path.join(os.path.dirname(core.CONFIG_PATH), value)
|
path = os.path.join(os.path.dirname(core.CONFIG_PATH), value)
|
||||||
|
@ -39,14 +28,14 @@ def validate_image_file(value):
|
||||||
|
|
||||||
CONF_RAW_DATA_ID = 'raw_data_id'
|
CONF_RAW_DATA_ID = 'raw_data_id'
|
||||||
|
|
||||||
FONT_SCHEMA = vol.Schema({
|
IMAGE_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_ID): cv.declare_variable_id(Image_),
|
vol.Required(CONF_ID): cv.declare_variable_id(Image_),
|
||||||
vol.Required(CONF_FILE): validate_image_file,
|
vol.Required(CONF_FILE): validate_image_file,
|
||||||
vol.Optional(CONF_RESIZE): cv.dimensions,
|
vol.Optional(CONF_RESIZE): cv.dimensions,
|
||||||
cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_variable_id(None),
|
cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_variable_id(None),
|
||||||
})
|
})
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.All(validate_pillow_installed, cv.ensure_list, [FONT_SCHEMA])
|
CONFIG_SCHEMA = vol.All(font.validate_pillow_installed, cv.ensure_list, [IMAGE_SCHEMA])
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
|
|
Loading…
Reference in a new issue