1234567891011121314151617181920212223242526272829303132333435 |
- import re
- import systemctl_mqtt._utils
- NODE_ID_ALLOWED_CHARS = r"a-zA-Z0-9_-"
- def get_default_node_id() -> str:
- return re.sub(
- f"[^{NODE_ID_ALLOWED_CHARS}]",
- "",
-
- systemctl_mqtt._utils.get_hostname(),
- )
- def validate_node_id(node_id: str) -> bool:
- return re.match(f"^[{NODE_ID_ALLOWED_CHARS}]+$", node_id) is not None
|