1
0
mirror of https://github.com/elisspace/core.git synced 2026-08-30 08:02:02 +00:00
Files
core/homeassistant/util/yaml/objects.py
Paulus Schoutsen 3f32c5d2ad Yaml use dict (#88977)
* Use built-in dict instead of OrderedDict

* Use dict instead of OrderedDict in YAML
2023-03-01 12:29:57 -05:00

31 lines
670 B
Python

"""Custom yaml object types."""
from __future__ import annotations
from dataclasses import dataclass
import yaml
class NodeListClass(list):
"""Wrapper class to be able to add attributes on a list."""
class NodeStrClass(str):
"""Wrapper class to be able to add attributes on a string."""
class NodeDictClass(dict):
"""Wrapper class to be able to add attributes on a dict."""
@dataclass(frozen=True)
class Input:
"""Input that should be substituted."""
name: str
@classmethod
def from_node(cls, loader: yaml.Loader, node: yaml.nodes.Node) -> Input:
"""Create a new placeholder from a node."""
return cls(node.value)