mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
29 lines
647 B
Python
29 lines
647 B
Python
"""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
|
|
def set_enabled(cls, enabled: bool) -> None:
|
|
"""Set the enabled value."""
|
|
cls._enabled = enabled
|
|
|
|
@classmethod
|
|
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
|