mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-06 13:30:41 +02:00
fixes loading enum from json file
Loading from json file happens by name. The sio client will send the whole enumeration and thus we have to handle both strings and enumerations.
This commit is contained in:
parent
e56a6e0653
commit
3f096bda96
@ -253,7 +253,9 @@ class StateManager:
|
||||
enum_attr = get_object_attr_from_path_list(target_obj, [attr_name])
|
||||
# take the value of the existing enum class
|
||||
# TODO: this might break when you set a value from a different enum
|
||||
setattr(target_obj, attr_name, enum_attr.__class__[value.name])
|
||||
if isinstance(value, enum.Enum):
|
||||
value = value.name
|
||||
setattr(target_obj, attr_name, enum_attr.__class__[value])
|
||||
elif attr_cache_type == "list":
|
||||
list_obj = get_object_attr_from_path_list(target_obj, [attr_name])
|
||||
list_obj[index] = value
|
||||
|
Loading…
x
Reference in New Issue
Block a user