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:
parent
a84dc14569
commit
0fb587727c
30 changed files with 2144 additions and 22 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue