diff --git a/Tools/_CP14/LocalizationHelper/LocalizationHelper/localization_helper.py b/Tools/_CP14/LocalizationHelper/LocalizationHelper/localization_helper.py index bc2e21feeb..b1779f29cc 100644 --- a/Tools/_CP14/LocalizationHelper/LocalizationHelper/localization_helper.py +++ b/Tools/_CP14/LocalizationHelper/LocalizationHelper/localization_helper.py @@ -61,8 +61,9 @@ class LocalizationHelper: if yaml_prototype_obj.attrs_dict != last_launch_prototype_obj.attrs_dict: log_text = f"Has been updated from: {final_prototype_obj.attrs_dict}, to: " - final_prototype_obj.attrs_dict.update(yaml_prototype_obj.attrs_dict) - final_prototype_obj.reinitialize_with_attrs_dict() + for key, value in yaml_prototype_obj.attrs_dict.items(): + if final_prototype_obj.attrs_dict[key] != value: + final_prototype_obj.set_attrs_dict_value(key, value) log_text += f"{final_prototype_obj.attrs_dict}" logger.debug(log_text) @@ -75,7 +76,6 @@ class LocalizationHelper: general_prototypes_dict = {} last_launch_result = self._read_prototypes_from_last_launch_result() - for prototype_id, yaml_prototype_obj in yaml_parser_prototypes.items(): final_prototype_obj = yaml_prototype_obj if prototype_id in ftl_parser_prototypes: @@ -87,7 +87,6 @@ class LocalizationHelper: last_launch_prototype_obj, final_prototype_obj) general_prototypes_dict[prototype_id] = final_prototype_obj - return general_prototypes_dict @staticmethod @@ -130,10 +129,12 @@ class LocalizationHelper: def _create_general_prototypes_dict(self, yaml_parser_prototypes: dict[str, Prototype], ftl_parser_prototypes: dict[str, Prototype]) -> dict[str, Prototype]: + general_prototypes_dict = self._merge_yaml_parser_prototypes_and_ftl_parser_prototypes(yaml_parser_prototypes, ftl_parser_prototypes) - general_prototypes_dict = self._parent_checks(general_prototypes_dict) + self._save_yaml_parser_last_launch_result(yaml_parser_prototypes) + general_prototypes_dict = self._parent_checks(general_prototypes_dict) return general_prototypes_dict @staticmethod @@ -169,7 +170,6 @@ class LocalizationHelper: general_prototypes_dict = self._create_general_prototypes_dict(prototypes_list_parsed_from_yaml, prototypes_list_parsed_from_ftl) - self._save_yaml_parser_last_launch_result(prototypes_list_parsed_from_yaml) self._save_result(general_prototypes_dict) self._print_info(general_prototypes_dict) except ErrorWhileWritingToFile as e: diff --git a/Tools/_CP14/LocalizationHelper/LocalizationHelper/prototype.py b/Tools/_CP14/LocalizationHelper/LocalizationHelper/prototype.py index ffdb17d75f..82ce9660b4 100644 --- a/Tools/_CP14/LocalizationHelper/LocalizationHelper/prototype.py +++ b/Tools/_CP14/LocalizationHelper/LocalizationHelper/prototype.py @@ -1,33 +1,93 @@ class Prototype: def __init__(self, prototype: dict): - self._initialize_attrs(prototype) - - def _initialize_attrs(self, prototype: dict): - self.name = prototype.get("name") - self.description = prototype.get("description") - self.parent = prototype.get("parent") - self.id = prototype.get("id") - self.suffix = prototype.get("suffix") - self.attrs_dict = { - "id": self.id, - "name": self.name, - "description": self.description, - "parent": self.parent, - "suffix": self.suffix + self._name = prototype.get("name") + self._description = prototype.get("description") + self._parent = prototype.get("parent") + self._id = prototype.get("id") + self._suffix = prototype.get("suffix") + self._attrs_dict = { + "id": self._id, + "name": self._name, + "description": self._description, + "parent": self._parent, + "suffix": self._suffix } - def reinitialize_with_attrs_dict(self): - self._initialize_attrs(self.attrs_dict) + @property + def name(self): + return self._name + + @name.setter + def name(self, new_name: str): + self._name = new_name + self._attrs_dict["name"] = new_name + + @property + def description(self): + return self._description + + @description.setter + def description(self, new_description: str): + self._description = new_description + self._attrs_dict["description"] = new_description + + @property + def parent(self): + return self._parent + + @parent.setter + def parent(self, new_parent: str): + self._parent = new_parent + self._attrs_dict["parent"] = new_parent + + @property + def id(self): + return self._id + + @id.setter + def id(self, new_id: str): + self._id = new_id + self._attrs_dict["id"] = new_id + + @property + def suffix(self): + return self._suffix + + @suffix.setter + def suffix(self, new_suffix: str): + self._suffix = new_suffix + self._attrs_dict["suffix"] = new_suffix + + @property + def attrs_dict(self): + return self._attrs_dict + + def set_attrs_dict_value(self, key, value): + self._attrs_dict[key] = value + if key == "name": + self._name = value + elif key == "description": + self._description = value + elif key == "id": + self._id = value + elif key == "parent": + self._parent = value + elif key == "suffix": + self._suffix = value def __repr__(self): - return str(self.attrs_dict) + return str(self._attrs_dict) def check_prototype_attrs(prototype: Prototype, with_parent_check: bool = True) -> bool: if prototype.name: + # if prototype.id == "CP14BaseWooden": + # print(prototype.name) return True elif prototype.description: + # if prototype.id == "CP14BaseWooden": + # print(prototype.description) return True elif prototype.suffix: return True