2019-05-09 16:07:56 +00:00
|
|
|
"""Custom yaml object types."""
|
2021-02-12 09:58:20 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2020-11-02 14:00:13 +00:00
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
|
|
import yaml
|
2019-05-09 16:07:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
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."""
|
2020-11-02 14:00:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
2020-12-01 17:21:36 +00:00
|
|
|
class Input:
|
|
|
|
"""Input that should be substituted."""
|
2020-11-02 14:00:13 +00:00
|
|
|
|
|
|
|
name: str
|
|
|
|
|
|
|
|
@classmethod
|
2021-02-12 09:58:20 +00:00
|
|
|
def from_node(cls, loader: yaml.Loader, node: yaml.nodes.Node) -> Input:
|
2020-11-02 14:00:13 +00:00
|
|
|
"""Create a new placeholder from a node."""
|
|
|
|
return cls(node.value)
|