mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-29 22:24:26 +00:00 
			
		
		
		
	Lint
This commit is contained in:
		| @@ -46,7 +46,7 @@ def validate_pillow_installed(value): | ||||
|     try: | ||||
|         import PIL | ||||
|     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)") | ||||
|  | ||||
|     if PIL.__version__[0] < '4': | ||||
| @@ -103,7 +103,7 @@ def to_code(config): | ||||
|             _, (offset_x, offset_y) = font.font.getsize(glyph) | ||||
|             width, height = mask.size | ||||
|             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 x in range(width): | ||||
|                     if not mask.getpixel((x, y)): | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import voluptuous as vol | ||||
|  | ||||
| import esphomeyaml.config_validation as cv | ||||
| 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.core import HexInt | ||||
| from esphomeyaml.helpers import App, ArrayInitializer, MockObj, Pvariable, RawExpression, add | ||||
| @@ -18,17 +18,6 @@ DEPENDENCIES = ['display'] | ||||
| 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): | ||||
|     value = cv.string(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' | ||||
|  | ||||
| FONT_SCHEMA = vol.Schema({ | ||||
| IMAGE_SCHEMA = vol.Schema({ | ||||
|     vol.Required(CONF_ID): cv.declare_variable_id(Image_), | ||||
|     vol.Required(CONF_FILE): validate_image_file, | ||||
|     vol.Optional(CONF_RESIZE): cv.dimensions, | ||||
|     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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user