2024-10-16 15:53:52 +00:00
|
|
|
"""Package for experimental."""
|
2024-10-29 09:30:30 +00:00
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
class Experimental:
|
|
|
|
"""Class for enabling experimental functionality."""
|
|
|
|
|
|
|
|
_enabled: bool | None = None
|
|
|
|
ENV_VAR = "KASA_EXPERIMENTAL"
|
|
|
|
|
|
|
|
@classmethod
|
2024-11-10 18:55:13 +00:00
|
|
|
def set_enabled(cls, enabled: bool) -> None:
|
2024-10-29 09:30:30 +00:00
|
|
|
"""Set the enabled value."""
|
|
|
|
cls._enabled = enabled
|
|
|
|
|
|
|
|
@classmethod
|
2024-11-10 18:55:13 +00:00
|
|
|
def enabled(cls) -> bool:
|
2024-10-29 09:30:30 +00:00
|
|
|
"""Get the enabled value."""
|
|
|
|
if cls._enabled is not None:
|
|
|
|
return cls._enabled
|
|
|
|
|
|
|
|
if env_var := os.getenv(cls.ENV_VAR):
|
|
|
|
return env_var.lower() in {"true", "1", "t", "on"}
|
|
|
|
|
|
|
|
return False
|