diff --git a/gramps/gen/lib/address.py b/gramps/gen/lib/address.py index c684667cc..89a02ed53 100644 --- a/gramps/gen/lib/address.py +++ b/gramps/gen/lib/address.py @@ -67,49 +67,6 @@ class Address(SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase, DateBase.serialize(self), LocationBase.serialize(self)) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Address", - "private": PrivacyBase.serialize(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "date": DateBase.to_struct(self), - "location": LocationBase.to_struct(self) - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Address() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - DateBase.from_struct(struct.get("date", {})), - LocationBase.from_struct(struct.get("location", {})) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/addressbase.py b/gramps/gen/lib/addressbase.py index 713a56075..ad9c3ac93 100644 --- a/gramps/gen/lib/addressbase.py +++ b/gramps/gen/lib/addressbase.py @@ -59,37 +59,6 @@ class AddressBase: """ return [addr.serialize() for addr in self.address_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [addr.to_struct() for addr in self.address_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Address.from_struct(addr) for addr in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/attrbase.py b/gramps/gen/lib/attrbase.py index 2f356b949..1e88269d7 100644 --- a/gramps/gen/lib/attrbase.py +++ b/gramps/gen/lib/attrbase.py @@ -65,37 +65,6 @@ class AttributeRootBase: """ return [attr.serialize() for attr in self.attribute_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [attr.to_struct() for attr in self.attribute_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [cls._CLASS.from_struct(attr) for attr in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/attribute.py b/gramps/gen/lib/attribute.py index d97024f43..39fcd47d1 100644 --- a/gramps/gen/lib/attribute.py +++ b/gramps/gen/lib/attribute.py @@ -77,43 +77,6 @@ class AttributeRoot(SecondaryObject, PrivacyBase): return (PrivacyBase.serialize(self), self.type.serialize(), self.value) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": self.__class__.__name__, - "private": PrivacyBase.serialize(self), - "type": self.type.to_struct(), - "value": self.value} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Attribute() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - AttributeType.from_struct(struct.get("type", {})), - struct.get("value", default.value)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. @@ -246,46 +209,6 @@ class Attribute(AttributeRoot, CitationBase, NoteBase): NoteBase.serialize(self), self.type.serialize(), self.value) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Attribute", - "private": PrivacyBase.serialize(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "type": self.type.to_struct(), - "value": self.value} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return (PrivacyBase.from_struct(struct["private"]), - CitationBase.from_struct(struct["citation_list"]), - NoteBase.from_struct(struct["note_list"]), - AttributeType.from_struct(struct["type"]), - struct["value"]) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/baseobj.py b/gramps/gen/lib/baseobj.py index acfe81e86..631b777c2 100644 --- a/gramps/gen/lib/baseobj.py +++ b/gramps/gen/lib/baseobj.py @@ -56,43 +56,6 @@ class BaseObject(metaclass=ABCMeta): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def matches_string(self, pattern, case_sensitive=False): """ Return True if any text data in the object or any of it's child diff --git a/gramps/gen/lib/childref.py b/gramps/gen/lib/childref.py index 35261474b..822f9dbfe 100644 --- a/gramps/gen/lib/childref.py +++ b/gramps/gen/lib/childref.py @@ -75,49 +75,6 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase): self.frel.serialize(), self.mrel.serialize()) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "ChildRef", - "private": PrivacyBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "ref": Handle("Person", self.ref), - "frel": self.frel.to_struct(), - "mrel": self.mrel.to_struct()} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = ChildRef() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - ChildRefType.from_struct(struct.get("frel", {})), - ChildRefType.from_struct(struct.get("mrel", {}))) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/citation.py b/gramps/gen/lib/citation.py index 75a587a65..cf48c304a 100644 --- a/gramps/gen/lib/citation.py +++ b/gramps/gen/lib/citation.py @@ -136,61 +136,6 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, TagBase.serialize(self), # 10 self.private) # 11 - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Citation", - "handle": Handle("Citation", self.handle), # 0 - "gramps_id": self.gramps_id, # 1 - "date": DateBase.to_struct(self), # 2 - "page": str(self.page), # 3 - "confidence": self.confidence, # 4 - "source_handle": Handle("Source", self.source_handle), # 5 - "note_list": NoteBase.to_struct(self), # 6 - "media_list": MediaBase.to_struct(self), # 7 - "srcattr_list": SrcAttributeBase.to_struct(self),# 8 - "change": self.change, # 9 - "tag_list": TagBase.to_struct(self), # 10 - "private": self.private} # 11 - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Citation() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - DateBase.from_struct(struct.get("date", {})), - struct.get("page", default.page), - struct.get("confidence", default.confidence), - Handle.from_struct(struct.get("source_handle", default.source_handle)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - MediaBase.from_struct(struct.get("media_list", default.media_list)), - SrcAttributeBase.from_struct(struct.get("srcattr_list", [])), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/citationbase.py b/gramps/gen/lib/citationbase.py index 59e5b60a3..7521ba5ac 100644 --- a/gramps/gen/lib/citationbase.py +++ b/gramps/gen/lib/citationbase.py @@ -75,37 +75,6 @@ class CitationBase: """ return self.citation_list - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [Handle("Citation", c) for c in self.citation_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Handle.from_struct(handle) for handle in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/date.py b/gramps/gen/lib/date.py index abcb93107..713fb5946 100644 --- a/gramps/gen/lib/date.py +++ b/gramps/gen/lib/date.py @@ -671,55 +671,6 @@ class Date: return (self.calendar, self.modifier, self.quality, self.dateval, text, self.sortval, self.newyear) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Date", - "calendar": self.calendar, - "modifier": self.modifier, - "quality": self.quality, - "dateval": self.dateval, - "text": self.text, - "sortval": self.sortval, - "newyear": self.newyear} - - @classmethod - def from_struct(cls, struct, full=False): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Date() - retval = (struct.get("calendar", default.calendar), - struct.get("modifier", default.modifier), - struct.get("quality", default.quality), - struct.get("dateval", default.dateval), - struct.get("text", default.text), - struct.get("sortval", default.sortval), - struct.get("newyear", default.newyear)) - if not full and retval == (0, 0, 0, (0, 0, 0, False), '', 0, 0): - return None - else: - return retval - def unserialize(self, data): """ Load from the format created by serialize. diff --git a/gramps/gen/lib/datebase.py b/gramps/gen/lib/datebase.py index 0ffd26c97..da3fe242c 100644 --- a/gramps/gen/lib/datebase.py +++ b/gramps/gen/lib/datebase.py @@ -61,41 +61,6 @@ class DateBase: date = self.date.serialize(no_text_date) return date - def to_struct(self, no_text_date=False): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - if self.date is None: - date = Date().to_struct() - else: - date = self.date.to_struct() - return date - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return Date.from_struct(struct) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/event.py b/gramps/gen/lib/event.py index 5047d0f53..5cf4f4295 100644 --- a/gramps/gen/lib/event.py +++ b/gramps/gen/lib/event.py @@ -118,41 +118,6 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase, AttributeBase.serialize(self), self.change, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Event", - "handle": Handle("Event", self.handle), - "gramps_id": self.gramps_id, - "type": self.__type.to_struct(), - "date": DateBase.to_struct(self), - "description": self.__description, - "place": Handle("Place", self.place), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "media_list": MediaBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - @classmethod def get_schema(cls): """ @@ -199,28 +164,6 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase, "private": _("Private"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Event() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - EventType.from_struct(struct.get("type", {})), - DateBase.from_struct(struct.get("date", {})), - struct.get("description", default.description), - Handle.from_struct(struct.get("place", default.place)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - MediaBase.from_struct(struct.get("media_list", default.media_list)), - AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/eventref.py b/gramps/gen/lib/eventref.py index c06686e2f..49af525fb 100644 --- a/gramps/gen/lib/eventref.py +++ b/gramps/gen/lib/eventref.py @@ -79,35 +79,6 @@ class EventRef(PrivacyBase, NoteBase, AttributeBase, RefBase, self.__role.serialize() ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "EventRef", - "private": PrivacyBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "ref": Handle("Event", self.ref), - "role": self.__role.to_struct() - } - @classmethod def get_schema(cls): """ @@ -142,22 +113,6 @@ class EventRef(PrivacyBase, NoteBase, AttributeBase, RefBase, "role": _("Role"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = EventRef() - return ( - PrivacyBase.from_struct(struct.get("private", default.private)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - EventRoleType.from_struct(struct.get("role", {})) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/family.py b/gramps/gen/lib/family.py index 2ee59a0fd..d6236b584 100644 --- a/gramps/gen/lib/family.py +++ b/gramps/gen/lib/family.py @@ -127,78 +127,6 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase, NoteBase.serialize(self), self.change, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Family", - "handle": Handle("Family", self.handle), - "gramps_id": self.gramps_id, - "father_handle": Handle("Person", self.father_handle), - "mother_handle": Handle("Person", self.mother_handle), - "child_ref_list": [cr.to_struct() for cr in self.child_ref_list], - "type": self.type.to_struct(), - "event_ref_list": [er.to_struct() for er in self.event_ref_list], - "media_list": MediaBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "lds_ord_list": LdsOrdBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Family() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - Handle.from_struct(struct.get("father_handle", - default.father_handle)), - Handle.from_struct(struct.get("mother_handle", - default.mother_handle)), - [ChildRef.from_struct(cr) - for cr in struct.get("child_ref_list", - default.child_ref_list)], - FamilyRelType.from_struct(struct.get("type", {})), - [EventRef.from_struct(er) - for er in struct.get("event_ref_list", - default.event_ref_list)], - MediaBase.from_struct(struct.get("media_list", - default.media_list)), - AttributeBase.from_struct(struct.get("attribute_list", - default.attribute_list)), - LdsOrdBase.from_struct(struct.get("lds_ord_list", - default.lds_ord_list)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - @classmethod def get_schema(cls): from .mediaref import MediaRef diff --git a/gramps/gen/lib/grampstype.py b/gramps/gen/lib/grampstype.py index e55de59ad..3042affea 100644 --- a/gramps/gen/lib/grampstype.py +++ b/gramps/gen/lib/grampstype.py @@ -215,44 +215,6 @@ class GrampsType(object, metaclass=GrampsTypeMeta): "string": _("Family Relationship"), } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": self.__class__.__name__, - "value": self.__value, - "string": str(self)} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = cls() - if struct.get("value", cls._CUSTOM) == cls._CUSTOM: - return (struct.get("value", default.value), - struct.get("string", "")) - else: - return (struct.get("value", default.value), '') - def unserialize(self, data): """Convert a serialized tuple of data to an object.""" self.__value, self.__string = data diff --git a/gramps/gen/lib/handle.py b/gramps/gen/lib/handle.py index 565c47008..e8fbb14b6 100644 --- a/gramps/gen/lib/handle.py +++ b/gramps/gen/lib/handle.py @@ -53,7 +53,3 @@ def Handle(_classname, handle): classname = _classname h = MyHandleClass(handle) return h - -def __from_struct(struct): - return struct -Handle.from_struct = __from_struct diff --git a/gramps/gen/lib/ldsord.py b/gramps/gen/lib/ldsord.py index d44f21109..c9cef5efe 100644 --- a/gramps/gen/lib/ldsord.py +++ b/gramps/gen/lib/ldsord.py @@ -144,57 +144,6 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase, self.type, self.place, self.famc, self.temple, self.status, self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "LdsOrd", - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "date": DateBase.to_struct(self), - "type": self.type, - "place": self.place, - "famc": self.famc, - "temple": self.temple, - "status": self.status, - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = LdsOrd() - return (CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - DateBase.from_struct(struct.get("date", {})), - struct.get("type", {}), - struct.get("place", default.place), - struct.get("famc", default.famc), - struct.get("temple", default.temple), - struct.get("status", default.status), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/ldsordbase.py b/gramps/gen/lib/ldsordbase.py index 4b22560ef..b24abac0f 100644 --- a/gramps/gen/lib/ldsordbase.py +++ b/gramps/gen/lib/ldsordbase.py @@ -64,37 +64,6 @@ class LdsOrdBase: """ return [lds_ord.serialize() for lds_ord in self.lds_ord_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [lds_ord.to_struct() for lds_ord in self.lds_ord_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [LdsOrd.from_struct(lds_ord) for lds_ord in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object diff --git a/gramps/gen/lib/location.py b/gramps/gen/lib/location.py index 15b9d10a9..dd5d7f6a8 100644 --- a/gramps/gen/lib/location.py +++ b/gramps/gen/lib/location.py @@ -63,55 +63,6 @@ class Location(SecondaryObject, LocationBase): """ return (LocationBase.serialize(self), self.parish) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Location", - "street": self.street, - "locality": self.locality, - "city": self.city, - "county": self.county, - "state": self.state, - "country": self.country, - "postal": self.postal, - "phone": self.phone, - "parish": self.parish} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Location() - return ((struct.get("street", default.street), - struct.get("locality", default.locality), - struct.get("city", default.city), - struct.get("country", default.country), - struct.get("state", default.state), - struct.get("country", default.country), - struct.get("postal", default.postal), - struct.get("phone", default.phone)), - struct.get("parish", default.parish)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/locationbase.py b/gramps/gen/lib/locationbase.py index dc7373e12..304e24df0 100644 --- a/gramps/gen/lib/locationbase.py +++ b/gramps/gen/lib/locationbase.py @@ -64,55 +64,6 @@ class LocationBase: return (self.street, self.locality, self.city, self.county, self.state, self.country, self.postal, self.phone) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "LocationBase", - "street": self.street, - "locality": self.locality, - "city": self.city, - "county": self.county, - "state": self.state, - "country": self.country, - "postal": self.postal, - "phone": self.phone - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = LocationBase() - return (struct.get("street", default.street), - struct.get("locality", default.locality), - struct.get("city", default.city), - struct.get("county", default.county), - struct.get("state", default.state), - struct.get("country", default.country), - struct.get("postal", default.postal), - struct.get("phone", default.phone)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/media.py b/gramps/gen/lib/media.py index a439f8d48..4c15e57c2 100644 --- a/gramps/gen/lib/media.py +++ b/gramps/gen/lib/media.py @@ -118,41 +118,6 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Media", - "handle": Handle("Media", self.handle), - "gramps_id": self.gramps_id, - "path": self.path, - "mime": self.mime, - "desc": self.desc, - "checksum": self.checksum, - "attribute_list": AttributeBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "change": self.change, - "date": DateBase.to_struct(self), - "tag_list": TagBase.to_struct(self), - "private": self.private} - @classmethod def get_schema(cls): """ @@ -205,28 +170,6 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, "private": _("Private"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Media() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("path", default.path), - struct.get("mime", default.mime), - struct.get("desc", default.desc), - struct.get("checksum", default.checksum), - AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - struct.get("change", default.change), - DateBase.from_struct(struct.get("date", {})), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/mediabase.py b/gramps/gen/lib/mediabase.py index 76a252173..5205e84b2 100644 --- a/gramps/gen/lib/mediabase.py +++ b/gramps/gen/lib/mediabase.py @@ -56,37 +56,6 @@ class MediaBase: """ return [mref.serialize() for mref in self.media_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [mref.to_struct() for mref in self.media_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [MediaRef.from_struct(mref) for mref in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/mediaref.py b/gramps/gen/lib/mediaref.py index 034369fad..b87df5e2e 100644 --- a/gramps/gen/lib/mediaref.py +++ b/gramps/gen/lib/mediaref.py @@ -70,34 +70,6 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase, RefBase.serialize(self), self.rect) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "MediaRef", - "private": PrivacyBase.serialize(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "ref": Handle("Media", self.ref), - "rect": self.rect if self.rect != (0, 0, 0, 0) else None} - @classmethod def get_schema(cls): """ @@ -118,24 +90,6 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase, "rect": tuple, # or None if (0,0,0,0) } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = MediaRef() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - AttributeBase.from_struct(struct.get("attribute_list", - default.attribute_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - struct.get("rect", default.rect)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/name.py b/gramps/gen/lib/name.py index 571a99cdf..91de6c856 100644 --- a/gramps/gen/lib/name.py +++ b/gramps/gen/lib/name.py @@ -129,70 +129,6 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, self.group_as, self.sort_as, self.display_as, self.call, self.nick, self.famnick) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Name", - "private": PrivacyBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "date": DateBase.to_struct(self), - "first_name": self.first_name, - "surname_list": SurnameBase.to_struct(self), - "suffix": self.suffix, - "title": self.title, - "type": self.type.to_struct(), - "group_as": self.group_as, - "sort_as": self.sort_as, - "display_as": self.display_as, - "call": self.call, - "nick": self.nick, - "famnick": self.famnick} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Name() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - DateBase.from_struct(struct.get("date", {})), - struct.get("first_name", default.first_name), - SurnameBase.from_struct(struct.get("surname_list", - default.surname_list)), - struct.get("suffix", default.suffix), - struct.get("title", default.title), - NameType.from_struct(struct.get("type", {})), - struct.get("group_as", default.group_as), - struct.get("sort_as", default.sort_as), - struct.get("display_as", default.display_as), - struct.get("call", default.call), - struct.get("nick", default.nick), - struct.get("famnick", default.famnick)) - @classmethod def get_labels(cls, _): return { diff --git a/gramps/gen/lib/note.py b/gramps/gen/lib/note.py index 372da06f6..c7e02334c 100644 --- a/gramps/gen/lib/note.py +++ b/gramps/gen/lib/note.py @@ -95,36 +95,6 @@ class Note(BasicPrimaryObject): self.type.serialize(), self.change, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Note", - "handle": Handle("Note", self.handle), - "gramps_id": self.gramps_id, - "text": self.text.to_struct(), - "format": self.format, - "type": self.type.to_struct(), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - @classmethod def get_schema(cls): """ @@ -154,23 +124,6 @@ class Note(BasicPrimaryObject): "private": _("Private"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Note() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - StyledText.from_struct(struct.get("text", {})), - struct.get("format", default.format), - NoteType.from_struct(struct.get("type", {})), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/notebase.py b/gramps/gen/lib/notebase.py index 2859a1886..6d20224a1 100644 --- a/gramps/gen/lib/notebase.py +++ b/gramps/gen/lib/notebase.py @@ -53,37 +53,6 @@ class NoteBase: """ return self.note_list - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [Handle("Note", n) for n in self.note_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Handle.from_struct(n) for n in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/person.py b/gramps/gen/lib/person.py index 3eec1e30d..c79227e91 100644 --- a/gramps/gen/lib/person.py +++ b/gramps/gen/lib/person.py @@ -157,56 +157,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, [pr.serialize() for pr in self.person_ref_list] # 20 ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "Person", - "handle": Handle("Person", self.handle), # 0 - "gramps_id": self.gramps_id, # 1 - "gender": self.__gender, # 2 - "primary_name": self.primary_name.to_struct(), # 3 - "alternate_names": [name.to_struct() - for name in self.alternate_names], # 4 - "death_ref_index": self.death_ref_index, # 5 - "birth_ref_index": self.birth_ref_index, # 6 - "event_ref_list": [er.to_struct() - for er in self.event_ref_list], # 7 - "family_list": [Handle("Family", f) for f in - self.family_list], # 8 - "parent_family_list": [Handle("Family", f) for f in - self.parent_family_list], # 9 - "media_list": MediaBase.to_struct(self), # 10 - "address_list": AddressBase.to_struct(self), # 11 - "attribute_list": AttributeBase.to_struct(self), # 12 - "urls": UrlBase.to_struct(self), # 13 - "lds_ord_list": LdsOrdBase.to_struct(self), # 14 - "citation_list": CitationBase.to_struct(self), # 15 - "note_list": NoteBase.to_struct(self), # 16 - "change": self.change, # 17 - "tag_list": TagBase.to_struct(self), # 18 - "private": self.private, # 19 - "person_ref_list": [pr.to_struct() - for pr in self.person_ref_list] # 20 - } - @classmethod def get_labels(cls, _): return { @@ -234,49 +184,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, "probably_alive": _("Probably alive"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Person() - return ( - Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("gender", default.gender), - Name.from_struct(struct.get("primary_name", {})), - [Name.from_struct(name) - for name in struct.get("alternate_names", - default.alternate_names)], - struct.get("death_ref_index", default.death_ref_index), - struct.get("birth_ref_index", default.birth_ref_index), - [EventRef.from_struct(er) - for er in struct.get("event_ref_list", default.event_ref_list)], - [Handle.from_struct(handle) - for handle in struct.get("family_list", default.family_list)], - [Handle.from_struct(handle) - for handle in struct.get("parent_family_list", - default.parent_family_list)], - MediaBase.from_struct(struct.get("media_list", default.media_list)), - AddressBase.from_struct(struct.get("address_list", - default.address_list)), - AttributeBase.from_struct(struct.get("attribute_list", - default.attribute_list)), - UrlBase.from_struct(struct.get("urls", default.urls)), - LdsOrdBase.from_struct(struct.get("lds_ord_list", - default.lds_ord_list)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private), - [PersonRef.from_struct(p) - for p in struct.get("person_ref_list", default.person_ref_list)] - ) - @classmethod def get_schema(cls): """ diff --git a/gramps/gen/lib/personref.py b/gramps/gen/lib/personref.py index aa12c2b42..78506585c 100644 --- a/gramps/gen/lib/personref.py +++ b/gramps/gen/lib/personref.py @@ -72,47 +72,6 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase): RefBase.serialize(self), self.rel) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "PersonRef", - "private": PrivacyBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "ref": Handle("Person", self.ref), - "rel": self.rel} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = PersonRef() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - struct.get("rel", default.rel)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/place.py b/gramps/gen/lib/place.py index 6c24cf0fd..6ce434ad7 100644 --- a/gramps/gen/lib/place.py +++ b/gramps/gen/lib/place.py @@ -166,78 +166,6 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject): "private": bool } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Place", - "handle": Handle("Place", self.handle), - "gramps_id": self.gramps_id, - "title": self.title, - "long": self.long, - "lat": self.lat, - "placeref_list": [pr.to_struct() for pr in self.placeref_list], - "name": self.name.to_struct(), - "alt_names": [an.to_struct() for an in self.alt_names], - "place_type": self.place_type.to_struct(), - "code": self.code, - "alt_loc": [al.to_struct() for al in self.alt_loc], - "urls": UrlBase.to_struct(self), - "media_list": MediaBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Place() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("title", default.title), - struct.get("long", default.long), - struct.get("lat", default.lat), - [PlaceRef.from_struct(pr) - for pr in struct.get("placeref_list", default.placeref_list)], - PlaceName.from_struct(struct.get("name", {})), - [PlaceName.from_struct(an) - for an in struct.get("alt_names", default.alt_names)], - PlaceType.from_struct(struct.get("place_type", {})), - struct.get("code", default.code), - [Location.from_struct(al) - for al in struct.get("alt_loc", default.alt_loc)], - UrlBase.from_struct(struct.get("urls", default.urls)), - MediaBase.from_struct(struct.get("media_list", - default.media_list)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/placename.py b/gramps/gen/lib/placename.py index 93dd48d17..80d6fb731 100644 --- a/gramps/gen/lib/placename.py +++ b/gramps/gen/lib/placename.py @@ -71,47 +71,6 @@ class PlaceName(SecondaryObject, DateBase): self.lang ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "PlaceName", - "value": self.value, - "date": DateBase.to_struct(self), - "lang": self.lang - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = PlaceName() - return ( - struct.get("value", default.value), - DateBase.from_struct(struct.get("date", {})), - struct.get("lang", default.lang) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/placeref.py b/gramps/gen/lib/placeref.py index 75ed7a3d7..c5f1b0970 100644 --- a/gramps/gen/lib/placeref.py +++ b/gramps/gen/lib/placeref.py @@ -63,45 +63,6 @@ class PlaceRef(RefBase, DateBase, SecondaryObject): DateBase.serialize(self) ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "PlaceRef", - "ref": Handle("Place", self.ref), - "date": DateBase.to_struct(self) - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = PlaceRef() - return ( - RefBase.from_struct(struct.get("ref", default.ref)), - DateBase.from_struct(struct.get("date", {})) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/primaryobj.py b/gramps/gen/lib/primaryobj.py index 3992aff31..59a1a1342 100644 --- a/gramps/gen/lib/primaryobj.py +++ b/gramps/gen/lib/primaryobj.py @@ -90,43 +90,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase, TagBase): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def set_gramps_id(self, gramps_id): """ Set the Gramps ID for the primary object. @@ -278,43 +241,6 @@ class PrimaryObject(BasicPrimaryObject): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def has_handle_reference(self, classname, handle): """ Return True if the object has reference to a given handle of given diff --git a/gramps/gen/lib/privacybase.py b/gramps/gen/lib/privacybase.py index c4b2d3923..872531c4a 100644 --- a/gramps/gen/lib/privacybase.py +++ b/gramps/gen/lib/privacybase.py @@ -55,37 +55,6 @@ class PrivacyBase: """ return self.private - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: bool - """ - return self.private - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return struct - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/refbase.py b/gramps/gen/lib/refbase.py index 0a0013705..8ca742bf4 100644 --- a/gramps/gen/lib/refbase.py +++ b/gramps/gen/lib/refbase.py @@ -53,15 +53,6 @@ class RefBase(metaclass=ABCMeta): """ return self.ref - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return str(struct) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/repo.py b/gramps/gen/lib/repo.py index e0a3edcd2..bd94a8436 100644 --- a/gramps/gen/lib/repo.py +++ b/gramps/gen/lib/repo.py @@ -104,57 +104,6 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, "private": bool } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Repository", - "handle": Handle("Repository", self.handle), - "gramps_id": self.gramps_id, - "type": self.type.to_struct(), - "name": str(self.name), - "note_list": NoteBase.to_struct(self), - "address_list": AddressBase.to_struct(self), - "urls": UrlBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Repository() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - RepositoryType.from_struct(struct.get("type", {})), - struct.get("name", default.name), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - AddressBase.from_struct(struct.get("address_list", default.address_list)), - UrlBase.from_struct(struct.get("urls", default.urls)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/reporef.py b/gramps/gen/lib/reporef.py index 53e79603c..fe9717c4f 100644 --- a/gramps/gen/lib/reporef.py +++ b/gramps/gen/lib/reporef.py @@ -69,51 +69,6 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase): PrivacyBase.serialize(self), ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "RepositoryRef", - "note_list": NoteBase.to_struct(self), - "ref": Handle("Repository", self.ref), - "call_number": self.call_number, - "media_type": self.media_type.to_struct(), - "private": PrivacyBase.serialize(self), - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = RepoRef() - return ( - NoteBase.from_struct(struct.get("note_list", default.note_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - struct.get("call_number", default.call_number), - SourceMediaType.from_struct(struct.get("media_type", {})), - struct.get("private", default.private), - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/researcher.py b/gramps/gen/lib/researcher.py index 309138c62..5a8caf270 100644 --- a/gramps/gen/lib/researcher.py +++ b/gramps/gen/lib/researcher.py @@ -60,59 +60,6 @@ class Researcher(LocationBase): return (LocationBase.serialize(self), self.name, self.addr, self.email) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Researcher", - "street": self.street, - "locality": self.locality, - "city": self.city, - "county": self.county, - "state": self.state, - "country": self.country, - "postal": self.postal, - "phone": self.phone, - "name": self.name, - "address": self.addr, - "email": self.email} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Researcher() - return (struct.get("street", default.street), - struct.get("locality", default.locality), - struct.get("city", default.city), - struct.get("country", default.country), - struct.get("state", default.state), - struct.get("country", default.country), - struct.get("postal", default.postal), - struct.get("phone", default.phone), - struct.get("name", default.name), - struct.get("address", default.addr), - struct.get("email", default.email)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/secondaryobj.py b/gramps/gen/lib/secondaryobj.py index 36165e312..4222f60ec 100644 --- a/gramps/gen/lib/secondaryobj.py +++ b/gramps/gen/lib/secondaryobj.py @@ -59,43 +59,6 @@ class SecondaryObject(BaseObject): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def is_equal(self, source): return self.serialize() == source.serialize() diff --git a/gramps/gen/lib/src.py b/gramps/gen/lib/src.py index b6dc9417b..6cb988a62 100644 --- a/gramps/gen/lib/src.py +++ b/gramps/gen/lib/src.py @@ -121,67 +121,6 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, "private": bool } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Source", - "handle": Handle("Source", self.handle), - "gramps_id": self.gramps_id, - "title": str(self.title), - "author": str(self.author), - "pubinfo": str(self.pubinfo), - "note_list": NoteBase.to_struct(self), - "media_list": MediaBase.to_struct(self), - "abbrev": str(self.abbrev), - "change": self.change, - "srcattr_list": SrcAttributeBase.to_struct(self), - "reporef_list": [rr.to_struct() for rr in self.reporef_list], - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - from .srcattribute import SrcAttribute - default = Source() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("title", default.title), - struct.get("author", default.author), - struct.get("pubinfo", default.pubinfo), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - MediaBase.from_struct(struct.get("media_list", - default.media_list)), - struct.get("abbrev", default.abbrev), - struct.get("change", default.change), - SrcAttributeBase.from_struct(struct.get("srcattr_list", {})), - [RepoRef.from_struct(rr) - for rr in struct.get("reporef_list", default.reporef_list)], - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/styledtext.py b/gramps/gen/lib/styledtext.py index fe48d7e20..fed0a5474 100644 --- a/gramps/gen/lib/styledtext.py +++ b/gramps/gen/lib/styledtext.py @@ -288,47 +288,6 @@ class StyledText: return (self._string, the_tags) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :return: Returns a struct containing the data of the object. - :rtype: dict - """ - if self._tags: - the_tags = [tag.to_struct() for tag in self._tags] - else: - the_tags = [] - - return {"_class": "StyledText", - "string": self._string, - "tags": the_tags} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :return: Returns a serialized object - """ - default = StyledText() - return (struct.get("string", default.string), - [StyledTextTag.from_struct(t) - for t in struct.get("tags", default.tags)]) - @classmethod def get_schema(cls): """ diff --git a/gramps/gen/lib/styledtexttag.py b/gramps/gen/lib/styledtexttag.py index 61603c3a1..f6dfc73d7 100644 --- a/gramps/gen/lib/styledtexttag.py +++ b/gramps/gen/lib/styledtexttag.py @@ -72,43 +72,6 @@ class StyledTextTag: """ return (self.name.serialize(), self.value, self.ranges) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :return: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "StyledTextTag", - "name": self.name.to_struct(), - "value": self.value, - "ranges": self.ranges} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :return: Returns a serialized object - """ - default = StyledTextTag() - return (StyledTextTagType.from_struct(struct.get("name", {})), - struct.get("value", default.value), - struct.get("ranges", default.ranges)) - def unserialize(self, data): """Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/surname.py b/gramps/gen/lib/surname.py index f92236290..22ddeda26 100644 --- a/gramps/gen/lib/surname.py +++ b/gramps/gen/lib/surname.py @@ -71,33 +71,6 @@ class Surname(SecondaryObject): return (self.surname, self.prefix, self.primary, self.origintype.serialize(), self.connector) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Surname", - "surname": self.surname, - "prefix": self.prefix, - "primary": self.primary, - "origintype": self.origintype.to_struct(), - "connector": self.connector} - @classmethod def get_schema(cls): return { @@ -119,20 +92,6 @@ class Surname(SecondaryObject): "connector": _("Connector") } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Surname() - return (struct.get("surname", default.surname), - struct.get("prefix", default.prefix), - struct.get("primary", default.primary), - NameOriginType.from_struct(struct.get("origintype", {})), - struct.get("connector", default.connector)) - def is_empty(self): """ Indicate if the surname is empty. diff --git a/gramps/gen/lib/surnamebase.py b/gramps/gen/lib/surnamebase.py index 4aae88fb3..13ec123cb 100644 --- a/gramps/gen/lib/surnamebase.py +++ b/gramps/gen/lib/surnamebase.py @@ -60,37 +60,6 @@ class SurnameBase: """ return [surname.serialize() for surname in self.surname_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [surname.to_struct() for surname in self.surname_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Surname.from_struct(surname) for surname in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/tableobj.py b/gramps/gen/lib/tableobj.py index 0bf5973e9..9332fc0f1 100644 --- a/gramps/gen/lib/tableobj.py +++ b/gramps/gen/lib/tableobj.py @@ -92,43 +92,6 @@ class TableObject(BaseObject): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def get_change_time(self): """ Return the time that the data was last changed. diff --git a/gramps/gen/lib/tag.py b/gramps/gen/lib/tag.py index 2b0f992fe..44dc3c75d 100644 --- a/gramps/gen/lib/tag.py +++ b/gramps/gen/lib/tag.py @@ -225,46 +225,5 @@ class Tag(TableObject): """ return self.__priority - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Tag", - "handle": Handle("Tag", self.handle), - "name": self.__name, - "color": self.__color, - "priority": self.__priority, - "change": self.change} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Tag() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("name", default.name), - struct.get("color", default.color), - struct.get("priority", default.priority), - struct.get("change", default.change)) - priority = property(get_priority, set_priority, None, 'Returns or sets priority of the tag') diff --git a/gramps/gen/lib/tagbase.py b/gramps/gen/lib/tagbase.py index e8e9e32c0..05f85c2c2 100644 --- a/gramps/gen/lib/tagbase.py +++ b/gramps/gen/lib/tagbase.py @@ -55,37 +55,6 @@ class TagBase: """ return self.tag_list - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [Handle('Tag', t) for t in self.tag_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Handle.from_struct(t) for t in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/url.py b/gramps/gen/lib/url.py index e773f32f5..9bc837e72 100644 --- a/gramps/gen/lib/url.py +++ b/gramps/gen/lib/url.py @@ -67,45 +67,6 @@ class Url(SecondaryObject, PrivacyBase): def serialize(self): return (self.private, self.path, self.desc, self.type.serialize()) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Url", - "private": self.private, - "path": self.path, - "desc": self.desc, - "type": self.type.to_struct()} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Url() - return (struct.get("private", default.private), - struct.get("path", default.path), - struct.get("desc", default.desc), - UrlType.from_struct(struct.get("type", {}))) - def unserialize(self, data): (self.private, self.path, self.desc, type_value) = data self.type.unserialize(type_value) diff --git a/gramps/gen/lib/urlbase.py b/gramps/gen/lib/urlbase.py index f7f6f6a61..3bc59fad6 100644 --- a/gramps/gen/lib/urlbase.py +++ b/gramps/gen/lib/urlbase.py @@ -58,37 +58,6 @@ class UrlBase: """ return [url.serialize() for url in self.urls] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [url.to_struct() for url in self.urls] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Url.from_struct(url) for url in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object.