Skip to content

Commit

Permalink
Simplify a few set_object_state methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Hall committed Oct 25, 2024
1 parent 829c90e commit 2ac632d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
8 changes: 2 additions & 6 deletions gramps/gen/lib/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions gramps/gen/lib/eventref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions gramps/gen/lib/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 3 additions & 9 deletions gramps/gen/lib/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2ac632d

Please sign in to comment.