python-kasa/kasa/experimental/__init__.py

29 lines
647 B
Python
Raw Normal View History

"""Package for experimental."""
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:
"""Set the enabled value."""
cls._enabled = enabled
@classmethod
2024-11-10 18:55:13 +00:00
def enabled(cls) -> bool:
"""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