From bd6220cb9ea3e5dcfb7a7c5b7a3928e86b2b0938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Tue, 30 Jul 2024 10:17:43 +0200 Subject: [PATCH] chore: refactoring state_manager --- src/pydase/data_service/state_manager.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/pydase/data_service/state_manager.py b/src/pydase/data_service/state_manager.py index 8a9be12..b5f7a89 100644 --- a/src/pydase/data_service/state_manager.py +++ b/src/pydase/data_service/state_manager.py @@ -248,17 +248,7 @@ class StateManager: path_parts = parse_full_access_path(path) target_obj = get_object_by_path_parts(self.service, path_parts[:-1]) - def cached_value_is_enum(path: str) -> bool: - try: - attr_cache_type = self.cache_manager.get_value_dict_from_cache(path)[ - "type" - ] - - return attr_cache_type in ("ColouredEnum", "Enum") - except Exception: - return False - - if cached_value_is_enum(path): + if self.__cached_value_is_enum(path): enum_attr = get_object_by_path_parts(target_obj, [path_parts[-1]]) # take the value of the existing enum class if serialized_value["type"] in ("ColouredEnum", "Enum"): @@ -327,6 +317,14 @@ class StateManager: ) return False + def __cached_value_is_enum(self, path: str) -> bool: + try: + attr_cache_type = self.cache_manager.get_value_dict_from_cache(path)["type"] + + return attr_cache_type in ("ColouredEnum", "Enum") + except Exception: + return False + def __attr_exists_on_target_obj(self, target_obj: Any, name: str) -> bool: return not is_property_attribute(target_obj, name) and not hasattr( target_obj, name