From 92c34c8182ee4d268f2c270c9745afddadf12743 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 13 Sep 2016 16:34:22 +0200 Subject: [PATCH 1/2] Migrate to voluptuous --- homeassistant/components/logger.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/homeassistant/components/logger.py b/homeassistant/components/logger.py index ed17e7520d0358..13fd9e6771d737 100644 --- a/homeassistant/components/logger.py +++ b/homeassistant/components/logger.py @@ -7,6 +7,10 @@ import logging from collections import OrderedDict +import voluptuous as vol + +import homeassistant.helpers.config_validation as cv + DOMAIN = 'logger' LOGSEVERITY = { @@ -23,6 +27,22 @@ LOGGER_DEFAULT = 'default' LOGGER_LOGS = 'logs' +_LOGS_SCHEMA = vol.All( + cv.ensure_list, + [ + vol.Schema({ + cv.string: vol.In(vol.Lower(list(LOGSEVERITY))), + }) + ] +) + +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({ + vol.Required(LOGGER_DEFAULT): vol.In(vol.Lower(list(LOGSEVERITY))), + vol.Required(LOGGER_LOGS): _LOGS_SCHEMA, + }), +}, extra=vol.ALLOW_EXTRA) + class HomeAssistantLogFilter(logging.Filter): """A log filter.""" From 44809ed8c03aea9c7527264bb0ef59f0c22c5aa9 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 16 Sep 2016 11:15:17 +0200 Subject: [PATCH 2/2] No list for configuration check --- homeassistant/components/logger.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/logger.py b/homeassistant/components/logger.py index 13fd9e6771d737..58e745e3004e5e 100644 --- a/homeassistant/components/logger.py +++ b/homeassistant/components/logger.py @@ -27,14 +27,9 @@ LOGGER_DEFAULT = 'default' LOGGER_LOGS = 'logs' -_LOGS_SCHEMA = vol.All( - cv.ensure_list, - [ - vol.Schema({ - cv.string: vol.In(vol.Lower(list(LOGSEVERITY))), - }) - ] -) +_LOGS_SCHEMA = vol.Schema({ + cv.string: vol.In(vol.Lower(list(LOGSEVERITY))), +}) CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({