mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-16 06:20:10 +00:00
* Replace pycrpytodome with cryptocraphy * Fix typing * fix typing * Fix lints * Fix build * Add musl libc * Fix lint * fix lint * Fix algo * Add more typing fix crypto imports v2 * Fix padding
30 lines
662 B
Python
30 lines
662 B
Python
"""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
|