Refined docstrings

svn: r20211
This commit is contained in:
Doug Blank
2012-08-14 12:59:19 +00:00
parent 22867c8090
commit ea5dcfd4ae
42 changed files with 712 additions and 214 deletions

View File

@@ -70,7 +70,23 @@ class Address(SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase,
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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 {"private": PrivacyBase.serialize(self), return {"private": PrivacyBase.serialize(self),
"citation_list": CitationBase.to_struct(self), "citation_list": CitationBase.to_struct(self),

View File

@@ -63,7 +63,23 @@ class AddressBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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] return [addr.to_struct() for addr in self.address_list]

View File

@@ -67,7 +67,23 @@ class AttributeBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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] return [attr.to_struct() for attr in self.attribute_list]

View File

@@ -85,7 +85,23 @@ class Attribute(SecondaryObject, PrivacyBase, CitationBase, NoteBase):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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 {"private": PrivacyBase.serialize(self), return {"private": PrivacyBase.serialize(self),
"citation_list": CitationBase.to_struct(self), "citation_list": CitationBase.to_struct(self),

View File

@@ -53,7 +53,22 @@ class BaseObject(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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.
""" """
assert False, "Needs to be overridden in the derived class" assert False, "Needs to be overridden in the derived class"

View File

@@ -77,7 +77,23 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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 {"private": PrivacyBase.to_struct(self), return {"private": PrivacyBase.to_struct(self),
"citation_list": CitationBase.to_struct(self), "citation_list": CitationBase.to_struct(self),

View File

@@ -91,21 +91,37 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
self.change, # 9 self.change, # 9
self.private) # 10 self.private) # 10
def to_struct(self, no_text_date = False): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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 {"handle": self.handle, # 0 return {"handle": self.handle, # 0
"gramps_id": self.gramps_id, # 1 "gramps_id": self.gramps_id, # 1
"date": DateBase.to_struct(self), # 2 "date": DateBase.to_struct(self), # 2
"page": unicode(self.page), # 3 "page": unicode(self.page), # 3
"confidence": self.confidence, # 4 "confidence": self.confidence, # 4
"source_handle": self.source_handle, # 5 "source_handle": self.source_handle, # 5
"note_list": NoteBase.to_struct(self), # 6 "note_list": NoteBase.to_struct(self), # 6
"media_list": MediaBase.to_struct(self), # 7 "media_list": MediaBase.to_struct(self), # 7
"datamap": self.datamap, # 8 "datamap": self.datamap, # 8
"change": self.change, # 9 "change": self.change, # 9
"private": self.private} # 10 "private": self.private} # 10
def unserialize(self, data): def unserialize(self, data):
""" """

View File

@@ -71,7 +71,23 @@ class CitationBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 self.citation_list return self.citation_list

View File

@@ -639,7 +639,23 @@ class Date(object):
def to_struct(self): def to_struct(self):
""" """
Convert to struct for data storage. 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 {"calendar": self.calendar, return {"calendar": self.calendar,
"modifier": self.modifier, "modifier": self.modifier,

View File

@@ -65,7 +65,23 @@ class DateBase(object):
def to_struct(self, no_text_date=False): def to_struct(self, no_text_date=False):
""" """
Convert the object to a serialized tuple of data. 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: if self.date is None:
date = Date().to_struct() date = Date().to_struct()

View File

@@ -119,21 +119,23 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
def to_struct(self): def to_struct(self):
""" """
Convert the data held in the event to a Python tuple that Convert the data held in this object to a structure (eg,
represents all the data elements. struct) that represents all the data elements.
This method is used to convert the object into a form that can easily This method is used to recursively convert the object into a
be saved to a database. self-documenting form that can easily be used for various
purposes, including diffs and queries.
These elements may be primitive Python types (string, integers), These structures may be primitive Python types (string,
complex Python types (lists or tuples, or Python objects. If the integer, boolean, etc.) or complex Python types (lists,
target database cannot handle complex types (such as objects or tuples, or dicts). If the return type is a dict, then the keys
lists), the database is responsible for converting the data into of the dict match the fieldname of the object. If the return
a form that it can use. 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 python tuple containing the data that should :returns: Returns a struct containing the data of the object.
be considered persistent. :rtype: dict
:rtype: tuple
""" """
return {"handle": self.handle, return {"handle": self.handle,
"gramps_id": self.gramps_id, "gramps_id": self.gramps_id,

View File

@@ -79,7 +79,23 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 { return {
"private": PrivacyBase.to_struct(self), "private": PrivacyBase.to_struct(self),

View File

@@ -130,21 +130,23 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
def to_struct(self): def to_struct(self):
""" """
Convert the data held in the event to a Python tuple that Convert the data held in this object to a structure (eg,
represents all the data elements. struct) that represents all the data elements.
This method is used to convert the object into a form that can easily This method is used to recursively convert the object into a
be saved to a database. self-documenting form that can easily be used for various
purposes, including diffs and queries.
These elements may be primitive Python types (string, integers), These structures may be primitive Python types (string,
complex Python types (lists or tuples, or Python objects. If the integer, boolean, etc.) or complex Python types (lists,
target database cannot handle complex types (such as objects or tuples, or dicts). If the return type is a dict, then the keys
lists), the database is responsible for converting the data into of the dict match the fieldname of the object. If the return
a form that it can use. 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 python tuple containing the data that should :returns: Returns a struct containing the data of the object.
be considered persistent. :rtype: dict
:rtype: tuple
""" """
return {"handle": self.handle, return {"handle": self.handle,
"gramps_id": self.gramps_id, "gramps_id": self.gramps_id,

View File

@@ -199,7 +199,25 @@ class GrampsType(object):
return (self.__value, self.__string) return (self.__value, self.__string)
def to_struct(self): def to_struct(self):
"""Convert the object to a serialized tuple of data. """ """
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 {"value": self.__value, return {"value": self.__value,
"string": str(self)} "string": str(self)}

View File

@@ -146,7 +146,23 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase,
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"citation_list": CitationBase.to_struct(self), return {"citation_list": CitationBase.to_struct(self),
"note_list": NoteBase.to_struct(self), "note_list": NoteBase.to_struct(self),

View File

@@ -68,7 +68,23 @@ class LdsOrdBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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] return [lds_ord.to_struct() for lds_ord in self.lds_ord_list]

View File

@@ -66,7 +66,23 @@ class Location(SecondaryObject, LocationBase):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"street": self.street, return {"street": self.street,
"locality": self.locality, "locality": self.locality,

View File

@@ -66,19 +66,6 @@ class LocationBase(object):
return (self.street, self.locality, self.city, self.county, self.state, return (self.street, self.locality, self.city, self.county, self.state,
self.country, self.postal, self.phone) self.country, self.postal, self.phone)
def to_struct(self):
"""
Convert the object to a serialized tuple of data.
"""
return {"street": self.street,
"locality": self.locality,
"city": self.city,
"country": self.county,
"state": self.state,
"country": self.country,
"postal": self.postal,
"phone": self.phone}
def unserialize(self, data): def unserialize(self, data):
""" """
Convert a serialized tuple of data to an object. Convert a serialized tuple of data to an object.

View File

@@ -60,7 +60,23 @@ class MediaBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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] return [mref.to_struct() for mref in self.media_list]

View File

@@ -118,21 +118,23 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
def to_struct(self): def to_struct(self):
""" """
Convert the data held in the event to a Python tuple that Convert the data held in this object to a structure (eg,
represents all the data elements. struct) that represents all the data elements.
This method is used to convert the object into a form that can easily This method is used to recursively convert the object into a
be saved to a database. self-documenting form that can easily be used for various
purposes, including diffs and queries.
These elements may be primitive Python types (string, integers), These structures may be primitive Python types (string,
complex Python types (lists or tuples, or Python objects. If the integer, boolean, etc.) or complex Python types (lists,
target database cannot handle complex types (such as objects or tuples, or dicts). If the return type is a dict, then the keys
lists), the database is responsible for converting the data into of the dict match the fieldname of the object. If the return
a form that it can use. 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 python tuple containing the data that should :returns: Returns a struct containing the data of the object.
be considered persistent. :rtype: dict
:rtype: tuple
""" """
return {"handle": self.handle, return {"handle": self.handle,
"gramps_id": self.gramps_id, "gramps_id": self.gramps_id,

View File

@@ -72,7 +72,23 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase,
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"private": PrivacyBase.serialize(self), return {"private": PrivacyBase.serialize(self),
"citation_list": CitationBase.to_struct(self), "citation_list": CitationBase.to_struct(self),

View File

@@ -128,7 +128,23 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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 {"private": PrivacyBase.to_struct(self), return {"private": PrivacyBase.to_struct(self),
"citation_list": CitationBase.to_struct(self), "citation_list": CitationBase.to_struct(self),

View File

@@ -98,11 +98,24 @@ class Note(BasicPrimaryObject, TagBase):
self.private) self.private)
def to_struct(self): def to_struct(self):
"""Convert the object to a serialized tuple of data. """
Convert the data held in this object to a structure (eg,
:returns: The serialized format of the instance. struct) that represents all the data elements.
:rtype: tuple
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 {"handle": self.handle, return {"handle": self.handle,
"gramps_id": self.gramps_id, "gramps_id": self.gramps_id,

View File

@@ -55,7 +55,23 @@ class NoteBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 self.note_list return self.note_list

View File

@@ -78,28 +78,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
MALE = 1 MALE = 1
FEMALE = 0 FEMALE = 0
FIELDS = ["handle", # 0
"gramps_id", # 1
"gender", # 2
"primary_name", # 3
"alternate_names", # 4
"death_ref_index", # 5
"birth_ref_index", # 6
"event_ref_list", # 7
"family_list", # 8
"parent_family_list", # 9
"media_list", # 10
"address_list", # 11
"attribute_list", # 12
"urls", # 13
"lds_ord_list", # 14
"citation_list", # 15
"note_list", # 16
"change", # 17
"tag_list", # 18
"private", # 19
"person_ref_list"] # 20
def __init__(self, data=None): def __init__(self, data=None):
""" """
Create a new Person instance. Create a new Person instance.
@@ -182,63 +160,51 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
) )
def to_struct(self): def to_struct(self):
return { """
"handle": self.handle, # 0 Convert the data held in this object to a structure (eg,
"gramps_id": self.gramps_id, # 1 struct) that represents all the data elements.
"gender": self.gender, # 2
"primary_name": self.primary_name.to_struct(), # 3 This method is used to recursively convert the object into a
"alternate_names": [name.to_struct() for name in self.alternate_names], # 4 self-documenting form that can easily be used for various
"death_ref_index": self.death_ref_index, # 5 purposes, including diffs and queries.
"birth_ref_index": self.birth_ref_index, # 6
"event_ref_list": [er.to_struct() for er in self.event_ref_list], # 7
"family_list": self.family_list, # 8
"parent_family_list": 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
}
def from_struct(self, to_struct): These structures may be primitive Python types (string,
self.handle = to_struct["handle"] # 0 integer, boolean, etc.) or complex Python types (lists,
self.gramps_id = to_struct["gramps_id"] # 1 tuples, or dicts). If the return type is a dict, then the keys
self.gender = to_struct["gender"] # 2 of the dict match the fieldname of the object. If the return
self.primary_name = Name.from_struct(to_struct["primary_name"]) # 3 struct (or value of a dict key) is a list, then it is a list
self.alternate_names = [Name.from_struct(name) of structs. Otherwise, the struct is just the value of the
for name in to_struct["alternate_names"]] # 4 attribute.
self.death_ref_index = to_struct["death_ref_index"] # 5
self.birth_ref_index = to_struct["birth_ref_index"] # 6 :returns: Returns a struct containing the data of the object.
self.event_ref_list = [EventRef.from_struct(er) :rtype: dict
for er in to_struct["event_ref_list"]] # 7 """
self.family_list = to_struct["family_list"] # 8 return {
self.parent_family_list = to_struct["parent_family_list"] # 9 "handle": self.handle, # 0
self.media_list = [MediaBase.from_struct(m) "gramps_id": self.gramps_id, # 1
for m in to_struct["media_list"]] # 10 "gender": self.gender, # 2
self.address_list = [AddressBase.from_struct(a) "primary_name": self.primary_name.to_struct(), # 3
for a in to_struct["address_list"]] # 11 "alternate_names": [name.to_struct()
self.attribute_list = [AttributeBase.from_struct(attr) for name in self.alternate_names], # 4
for attr in to_struct["attribute_list"]] # 12 "death_ref_index": self.death_ref_index, # 5
self.urls = [UrlBase.from_struct(url) "birth_ref_index": self.birth_ref_index, # 6
for url in to_struct["urls"]] # 13 "event_ref_list": [er.to_struct()
self.lds_ord_list = [LdsOrdBase.from_struct(lref) for er in self.event_ref_list], # 7
for lref in to_struct["lds_ord_list"]] # 14 "family_list": self.family_list, # 8
self.citation_list = [CitationBase.from_struct(cref) "parent_family_list": self.parent_family_list, # 9
for cref in to_struct["citation_list"]] # 15 "media_list": MediaBase.to_struct(self), # 10
self.note_list = [NoteBase.from_struct(noteref) "address_list": AddressBase.to_struct(self), # 11
for noteref in to_struct["note_list"]] # 16 "attribute_list": AttributeBase.to_struct(self), # 12
self.change = to_struct["change"] # 17 "urls": UrlBase.to_struct(self), # 13
self.tag_list = [TagBase.from_struct(tag) "lds_ord_list": LdsOrdBase.to_struct(self), # 14
for tag in to_struct["tag_list"]] # 18 "citation_list": CitationBase.to_struct(self), # 15
self.private = to_struct["private"] # 19 "note_list": NoteBase.to_struct(self), # 16
self.person_ref_list = [PersonRef.from_struct(pr) "change": self.change, # 17
for pr in to_struct["person_ref_list"]] # 20 "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
}
def unserialize(self, data): def unserialize(self, data):
""" """

View File

@@ -74,7 +74,23 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"private": PrivacyBase.to_struct(self), return {"private": PrivacyBase.to_struct(self),
"citation_list": CitationBase.to_struct(self), "citation_list": CitationBase.to_struct(self),

View File

@@ -111,23 +111,24 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
def to_struct(self): def to_struct(self):
""" """
Convert the data held in the Place to a Python tuple that Convert the data held in this object to a structure (eg,
represents all the data elements. struct) that represents all the data elements.
This method is used to convert the object into a form that can easily This method is used to recursively convert the object into a
be saved to a database. self-documenting form that can easily be used for various
purposes, including diffs and queries.
These elements may be primitive Python types (string, integers), These structures may be primitive Python types (string,
complex Python types (lists or tuples, or Python objects. If the integer, boolean, etc.) or complex Python types (lists,
target database cannot handle complex types (such as objects or tuples, or dicts). If the return type is a dict, then the keys
lists), the database is responsible for converting the data into of the dict match the fieldname of the object. If the return
a form that it can use. 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 python tuple containing the data that should :returns: Returns a struct containing the data of the object.
be considered persistent. :rtype: dict
:rtype: tuple
""" """
if self.main_loc is None or self.main_loc.serialize() == _EMPTY_LOC: if self.main_loc is None or self.main_loc.serialize() == _EMPTY_LOC:
main_loc = None main_loc = None
else: else:

View File

@@ -164,14 +164,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase):
def replace_media_references(self, old_handle, new_handle): def replace_media_references(self, old_handle, new_handle):
pass pass
def get_fields(self):
"""
Return a list of fields of the struct.
"""
return self.to_struct().keys()
FIELDS = property(get_fields)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Primary Object class # Primary Object class

View File

@@ -59,7 +59,23 @@ class PrivacyBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 return self.private

View File

@@ -50,7 +50,23 @@ class RefBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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: str
""" """
return self.ref return self.ref

View File

@@ -69,7 +69,23 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"handle": self.handle, return {"handle": self.handle,
"gramps_id": self.gramps_id, "gramps_id": self.gramps_id,

View File

@@ -71,7 +71,23 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 { return {
"note_list": NoteBase.to_struct(self), "note_list": NoteBase.to_struct(self),

View File

@@ -63,9 +63,32 @@ class Researcher(LocationBase):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"location": LocationBase.to_struct(self), return {"street": self.street,
"locality": self.locality,
"city": self.city,
"country": self.county,
"state": self.state,
"country": self.country,
"postal": self.postal,
"phone": self.phone,
"name": self.name, "name": self.name,
"address": self.addr, "address": self.addr,
"email": self.email} "email": self.email}

View File

@@ -71,7 +71,23 @@ class Source(MediaBase, NoteBase, PrimaryObject):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"handle": self.handle, return {"handle": self.handle,
"gramps_id": self.gramps_id, "gramps_id": self.gramps_id,

View File

@@ -273,11 +273,24 @@ class StyledText(object):
return (self._string, the_tags) return (self._string, the_tags)
def to_struct(self): def to_struct(self):
"""Convert the object to a serialized tuple of data. """
Convert the data held in this object to a structure (eg,
:returns: Serialized format of the instance. struct) that represents all the data elements.
:returnstype: tuple
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._tags: if self._tags:
the_tags = [tag.to_struct() for tag in self._tags] the_tags = [tag.to_struct() for tag in self._tags]

View File

@@ -74,11 +74,24 @@ class StyledTextTag(object):
return (self.name.serialize(), self.value, self.ranges) return (self.name.serialize(), self.value, self.ranges)
def to_struct(self): def to_struct(self):
"""Convert the object to a serialized tuple of data. """
Convert the data held in this object to a structure (eg,
:returns: Serialized format of the instance. struct) that represents all the data elements.
:returnstype: tuple
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 {"name": self.name.to_struct(), return {"name": self.name.to_struct(),
"value": self.value, "value": self.value,

View File

@@ -73,7 +73,23 @@ class Surname(SecondaryObject):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 {"surname": self.surname, return {"surname": self.surname,
"prefix": self.prefix, "prefix": self.prefix,

View File

@@ -64,7 +64,23 @@ class SurnameBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized struct of data. 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] return [surname.to_struct() for surname in self.surname_list]

View File

@@ -201,21 +201,23 @@ class Tag(TableObject):
def to_struct(self): def to_struct(self):
""" """
Convert the data held in the event to a Python tuple that Convert the data held in this object to a structure (eg,
represents all the data elements. struct) that represents all the data elements.
This method is used to convert the object into a form that can easily This method is used to recursively convert the object into a
be saved to a database. self-documenting form that can easily be used for various
purposes, including diffs and queries.
These elements may be primitive Python types (string, integers), These structures may be primitive Python types (string,
complex Python types (lists or tuples, or Python objects. If the integer, boolean, etc.) or complex Python types (lists,
target database cannot handle complex types (such as objects or tuples, or dicts). If the return type is a dict, then the keys
lists), the database is responsible for converting the data into of the dict match the fieldname of the object. If the return
a form that it can use. 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 python tuple containing the data that should :returns: Returns a struct containing the data of the object.
be considered persistent. :rtype: dict
:rtype: tuple
""" """
return {"handle": self.handle, return {"handle": self.handle,
"name": self.__name, "name": self.__name,
@@ -223,7 +225,5 @@ class Tag(TableObject):
"priority": self.__priority, "priority": self.__priority,
"change": self.change} "change": self.change}
FIELDS = ["handle", "name", "color", "priority", "change"]
priority = property(get_priority, set_priority, None, priority = property(get_priority, set_priority, None,
'Returns or sets priority of the tag') 'Returns or sets priority of the tag')

View File

@@ -56,7 +56,23 @@ class TagBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data. 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 self.tag_list return self.tag_list

View File

@@ -70,6 +70,25 @@ class Url(SecondaryObject, PrivacyBase):
return (self.private, self.path, self.desc, self.type.serialize()) return (self.private, self.path, self.desc, self.type.serialize())
def to_struct(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 {"private": self.private, return {"private": self.private,
"path": self.path, "path": self.path,
"desc": self.desc, "desc": self.desc,

View File

@@ -62,7 +62,23 @@ class UrlBase(object):
def to_struct(self): def to_struct(self):
""" """
Convert the object to a serialized tuple of data 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] return [url.to_struct() for url in self.urls]