mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-16 14:30:26 +00:00
Make discovery persistent (#727)
* Make discovery persistent * fix file handling * fix detection * Smooth * Fix ring import * Fix handling * fix schema * fix validate * fix discovery cleanup
This commit is contained in:
28
hassio/utils/validate.py
Normal file
28
hassio/utils/validate.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Validate utils."""
|
||||
|
||||
import pytz
|
||||
import voluptuous as vol
|
||||
|
||||
|
||||
def schema_or(schema):
|
||||
"""Allow schema or empty."""
|
||||
def _wrapper(value):
|
||||
"""Wrapper for validator."""
|
||||
if not value:
|
||||
return value
|
||||
return schema(value)
|
||||
|
||||
return _wrapper
|
||||
|
||||
|
||||
def validate_timezone(timezone):
|
||||
"""Validate voluptuous timezone."""
|
||||
try:
|
||||
pytz.timezone(timezone)
|
||||
except pytz.exceptions.UnknownTimeZoneError:
|
||||
raise vol.Invalid(
|
||||
"Invalid time zone passed in. Valid options can be found here: "
|
||||
"http://en.wikipedia.org/wiki/List_of_tz_database_time_zones") \
|
||||
from None
|
||||
|
||||
return timezone
|
||||
Reference in New Issue
Block a user