mirror of
https://github.com/Andre0512/pyhOn.git
synced 2025-05-13 22:54:26 -04:00
Split up parameters
This commit is contained in:
parent
461a247ad3
commit
03187745bf
9 changed files with 168 additions and 158 deletions
33
pyhon/parameter/program.py
Normal file
33
pyhon/parameter/program.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from typing import List, TYPE_CHECKING
|
||||
|
||||
from pyhon.parameter.enum import HonParameterEnum
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pyhon.commands import HonCommand
|
||||
|
||||
|
||||
class HonParameterProgram(HonParameterEnum):
|
||||
_FILTER = ["iot_recipe", "iot_guided"]
|
||||
|
||||
def __init__(self, key: str, command: "HonCommand") -> None:
|
||||
super().__init__(key, {})
|
||||
self._command = command
|
||||
self._value: str = command.program
|
||||
self._values: List[str] = list(command.programs)
|
||||
self._typology: str = "enum"
|
||||
|
||||
@property
|
||||
def value(self) -> str | float:
|
||||
return self._value
|
||||
|
||||
@value.setter
|
||||
def value(self, value: str) -> None:
|
||||
if value in self.values:
|
||||
self._command.program = value
|
||||
else:
|
||||
raise ValueError(f"Allowed values {self._values}")
|
||||
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
values = [v for v in self._values if all(f not in v for f in self._FILTER)]
|
||||
return sorted(values)
|
Loading…
Add table
Add a link
Reference in a new issue