Add initial blueprint support (#42469)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Paulus Schoutsen 2020-11-02 15:00:13 +01:00 committed by GitHub
parent a84dc14569
commit 0fb587727c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 2144 additions and 22 deletions

View file

@ -87,7 +87,7 @@ from homeassistant.helpers import (
template as template_helper,
)
from homeassistant.helpers.logging import KeywordStyleAdapter
from homeassistant.util import slugify as util_slugify
from homeassistant.util import sanitize_path, slugify as util_slugify
import homeassistant.util.dt as dt_util
# pylint: disable=invalid-name
@ -113,6 +113,17 @@ port = vol.All(vol.Coerce(int), vol.Range(min=1, max=65535))
T = TypeVar("T")
def path(value: Any) -> str:
"""Validate it's a safe path."""
if not isinstance(value, str):
raise vol.Invalid("Expected a string")
if sanitize_path(value) != value:
raise vol.Invalid("Invalid path")
return value
# Adapted from:
# https://github.com/alecthomas/voluptuous/issues/115#issuecomment-144464666
def has_at_least_one_key(*keys: str) -> Callable: