mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-12-22 18:55:32 +00:00
Fix for fridge program names
This commit is contained in:
parent
ecbf438889
commit
eea79e28b9
|
@ -71,7 +71,7 @@ class HonCommand:
|
|||
def parameter_groups(self) -> Dict[str, Dict[str, Union[str, float]]]:
|
||||
result: Dict[str, Dict[str, Union[str, float]]] = {}
|
||||
for name, parameter in self._parameters.items():
|
||||
result.setdefault(parameter.group, {})[name] = parameter.value
|
||||
result.setdefault(parameter.group, {})[name] = parameter.intern_value
|
||||
return result
|
||||
|
||||
@property
|
||||
|
|
|
@ -22,6 +22,10 @@ class HonParameter:
|
|||
def value(self) -> str | float:
|
||||
return self._value if self._value is not None else "0"
|
||||
|
||||
@property
|
||||
def intern_value(self) -> str | float:
|
||||
return str(self._value) if self._value is not None else ""
|
||||
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
return [str(self.value)]
|
||||
|
|
|
@ -3,13 +3,17 @@ from typing import Dict, Any, List
|
|||
from pyhon.parameter.base import HonParameter
|
||||
|
||||
|
||||
def clean_value(value):
|
||||
return str(value).strip("[]").replace("|", "_").lower()
|
||||
|
||||
|
||||
class HonParameterEnum(HonParameter):
|
||||
def __init__(self, key: str, attributes: Dict[str, Any], group: str) -> None:
|
||||
super().__init__(key, attributes, group)
|
||||
self._default = attributes.get("defaultValue")
|
||||
self._value = self._default or "0"
|
||||
self._values: List[str] = attributes.get("enumValues", [])
|
||||
if self._default and str(self._default.strip("[]")) not in self.values:
|
||||
if self._default and clean_value(self._default.strip("[]")) not in self.values:
|
||||
self._values.append(self._default)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
@ -17,7 +21,7 @@ class HonParameterEnum(HonParameter):
|
|||
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
return [str(value) for value in self._values]
|
||||
return [clean_value(value) for value in self._values]
|
||||
|
||||
@values.setter
|
||||
def values(self, values) -> None:
|
||||
|
@ -25,7 +29,7 @@ class HonParameterEnum(HonParameter):
|
|||
|
||||
@property
|
||||
def value(self) -> str | float:
|
||||
return self._value if self._value is not None else self.values[0]
|
||||
return clean_value(self._value) if self._value is not None else self.values[0]
|
||||
|
||||
@value.setter
|
||||
def value(self, value: str) -> None:
|
||||
|
|
Loading…
Reference in a new issue