From 2ac632d1171b15b86cafa104b1bbdb050d2c7bcf Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Fri, 25 Oct 2024 22:46:37 +0100 Subject: [PATCH] Simplify a few set_object_state methods --- gramps/gen/lib/event.py | 8 ++------ gramps/gen/lib/eventref.py | 3 +-- gramps/gen/lib/person.py | 4 +--- gramps/gen/lib/tag.py | 12 +++--------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/gramps/gen/lib/event.py b/gramps/gen/lib/event.py index 3ffe428e40..464b3a297b 100644 --- a/gramps/gen/lib/event.py +++ b/gramps/gen/lib/event.py @@ -154,12 +154,8 @@ def set_object_state(self, attr_dict): We override this method to handle the `type` and `description` properties. """ - if "type" in attr_dict: - self.__type = attr_dict["type"] - del attr_dict["type"] - if "description" in attr_dict: - self.__description = attr_dict["description"] - del attr_dict["description"] + self.__type = attr_dict.pop("type") + self.__description = attr_dict.pop("description") super().set_object_state(attr_dict) @classmethod diff --git a/gramps/gen/lib/eventref.py b/gramps/gen/lib/eventref.py index 94e025522f..8898d0f9a8 100644 --- a/gramps/gen/lib/eventref.py +++ b/gramps/gen/lib/eventref.py @@ -103,8 +103,7 @@ def set_object_state(self, attr_dict): We override this method to handle the `role` property. """ - self.__role = attr_dict["role"] - del attr_dict["role"] + self.__role = attr_dict.pop("role") super().set_object_state(attr_dict) @classmethod diff --git a/gramps/gen/lib/person.py b/gramps/gen/lib/person.py index 13858c1cbd..dc45567ace 100644 --- a/gramps/gen/lib/person.py +++ b/gramps/gen/lib/person.py @@ -339,9 +339,7 @@ def set_object_state(self, attr_dict): We override this method to handle the `gender` property. """ - if "gender" in attr_dict: - self.__gender = attr_dict["gender"] - del attr_dict["gender"] + self.__gender = attr_dict.pop("gender") super().set_object_state(attr_dict) def _has_handle_reference(self, classname, handle): diff --git a/gramps/gen/lib/tag.py b/gramps/gen/lib/tag.py index ebe701ed1e..e47cd6ff71 100644 --- a/gramps/gen/lib/tag.py +++ b/gramps/gen/lib/tag.py @@ -129,15 +129,9 @@ def set_object_state(self, attr_dict): We override this method to handle the `name`, `color` and `priority` properties. """ - if "name" in attr_dict: - self.__name = attr_dict["name"] - del attr_dict["name"] - if "color" in attr_dict: - self.__color = attr_dict["color"] - del attr_dict["color"] - if "priority" in attr_dict: - self.__priority = attr_dict["priority"] - del attr_dict["priority"] + self.__name = attr_dict.pop("name") + self.__color = attr_dict.pop("color") + self.__priority = attr_dict.pop("priority") super().set_object_state(attr_dict) @classmethod