mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Allow enabling experimental devices from environment variable (#1194)
This commit is contained in:
@@ -1 +1,28 @@
|
||||
"""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):
|
||||
"""Set the enabled value."""
|
||||
cls._enabled = enabled
|
||||
|
||||
@classmethod
|
||||
def enabled(cls):
|
||||
"""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
|
||||
|
Reference in New Issue
Block a user