mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-12-29 17:11:19 +01: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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user