-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docstrings and remove some duplicate code
- Loading branch information
Showing
9 changed files
with
124 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# Copyright (C) 2010 Michiel D. Nauta | ||
# Copyright (C) 2011 Tim G L Lyons | ||
# Copyright (C) 2013 Doug Blank <[email protected]> | ||
# Copyright (C) 2017 Nick Hall | ||
# Copyright (C) 2017,2024 Nick Hall | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -87,11 +87,22 @@ def serialize(self): | |
) | ||
|
||
def get_object_state(self): | ||
""" | ||
Get the current object state as a dictionary. | ||
We override this method to handle the `role` property. | ||
""" | ||
attr_dict = super().get_object_state() | ||
attr_dict["role"] = self.__role | ||
return attr_dict | ||
|
||
def set_object_state(self, attr_dict): | ||
""" | ||
Set the current object state using information provided in the given | ||
dictionary. | ||
We override this method to handle the `role` property. | ||
""" | ||
self.__role = attr_dict["role"] | ||
del attr_dict["role"] | ||
super().set_object_state(attr_dict) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# Copyright (C) 2010 Michiel D. Nauta | ||
# Copyright (C) 2011 Tim G L Lyons | ||
# Copyright (C) 2013 Doug Blank <[email protected]> | ||
# Copyright (C) 2017 Nick Hall | ||
# Copyright (C) 2017,2024 Nick Hall | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -152,6 +152,12 @@ def unserialize(self, data): | |
return self | ||
|
||
def set_object_state(self, attr_dict): | ||
""" | ||
Set the current object state using information provided in the given | ||
dictionary. | ||
We override this method to convert `rect` into a tuple. | ||
""" | ||
rect = attr_dict["rect"] | ||
if rect is not None: | ||
attr_dict["rect"] = tuple(rect) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# | ||
# Copyright (C) 2008 Zsolt Foldvari | ||
# Copyright (C) 2013 Doug Blank <[email protected]> | ||
# Copyright (C) 2017 Nick Hall | ||
# Copyright (C) 2017,2024 Nick Hall | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -103,12 +103,23 @@ def __init__(self, text="", tags=None): | |
self._tags = [] | ||
|
||
def get_object_state(self): | ||
""" | ||
Get the current object state as a dictionary. | ||
We override this method to handle the `tags` and `string` properties. | ||
""" | ||
attr_dict = {"_class": self.__class__.__name__} | ||
attr_dict["tags"] = self._tags | ||
attr_dict["string"] = self._string | ||
return attr_dict | ||
|
||
def set_object_state(self, attr_dict): | ||
""" | ||
Set the current object state using information provided in the given | ||
dictionary. | ||
We override this method to handle the `tags` and `string` properties. | ||
""" | ||
self._tags = attr_dict["tags"] | ||
self._string = attr_dict["string"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# | ||
# Gramps - a GTK+/GNOME based genealogy program | ||
# | ||
# Copyright (C) 2008 Zsolt Foldvari | ||
# Copyright (C) 2013 Doug Blank <[email protected]> | ||
# Copyright (C) 2017 Nick Hall | ||
# Copyright (C) 2008 Zsolt Foldvari | ||
# Copyright (C) 2013 Doug Blank <[email protected]> | ||
# Copyright (C) 2017,2024 Nick Hall | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -70,17 +70,15 @@ def __init__(self, name=None, value=None, ranges=None): | |
# Current use of StyledTextTag is such that a shallow copy suffices. | ||
self.ranges = ranges | ||
|
||
def get_object_state(self): | ||
attr_dict = {"_class": self.__class__.__name__} | ||
attr_dict["name"] = self.name | ||
attr_dict["value"] = self.value | ||
attr_dict["ranges"] = self.ranges | ||
return attr_dict | ||
|
||
def set_object_state(self, attr_dict): | ||
self.name = attr_dict["name"] | ||
self.value = attr_dict["value"] | ||
self.ranges = [tuple(item) for item in attr_dict["ranges"]] | ||
""" | ||
Set the current object state using information provided in the given | ||
dictionary. | ||
We override this method to convert the elements of `ranges` into tuples. | ||
""" | ||
attr_dict["ranges"] = [tuple(item) for item in attr_dict["ranges"]] | ||
super().set_object_state(attr_dict) | ||
|
||
def serialize(self): | ||
"""Convert the object to a serialized tuple of data. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# | ||
# Gramps - a GTK+/GNOME based genealogy program | ||
# | ||
# Copyright (C) 2010,2017 Nick Hall | ||
# Copyright (C) 2013 Doug Blank <[email protected]> | ||
# Copyright (C) 2010,2017,2024 Nick Hall | ||
# Copyright (C) 2013 Doug Blank <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -109,13 +109,26 @@ def unserialize(self, data): | |
return self | ||
|
||
def get_object_state(self): | ||
""" | ||
Get the current object state as a dictionary. | ||
We override this method to handle the `name`, `color` and `priority` | ||
properties. | ||
""" | ||
attr_dict = super().get_object_state() | ||
attr_dict["name"] = self.__name | ||
attr_dict["color"] = self.__color | ||
attr_dict["priority"] = self.__priority | ||
return attr_dict | ||
|
||
def set_object_state(self, attr_dict): | ||
""" | ||
Set the current object state using information provided in the given | ||
dictionary. | ||
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"] | ||
|