mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user