Refined docstrings
svn: r20211
This commit is contained in:
parent
22867c8090
commit
ea5dcfd4ae
@ -70,7 +70,23 @@ class Address(SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase,
|
||||
|
||||
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),
|
||||
"citation_list": CitationBase.to_struct(self),
|
||||
|
@ -63,7 +63,23 @@ class AddressBase(object):
|
||||
|
||||
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]
|
||||
|
||||
|
@ -67,7 +67,23 @@ class AttributeBase(object):
|
||||
|
||||
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]
|
||||
|
||||
|
@ -85,7 +85,23 @@ class Attribute(SecondaryObject, PrivacyBase, CitationBase, NoteBase):
|
||||
|
||||
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),
|
||||
"citation_list": CitationBase.to_struct(self),
|
||||
|
@ -53,7 +53,22 @@ class BaseObject(object):
|
||||
|
||||
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"
|
||||
|
||||
|
@ -77,7 +77,23 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
|
||||
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),
|
||||
"citation_list": CitationBase.to_struct(self),
|
||||
|
@ -91,21 +91,37 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
|
||||
self.change, # 9
|
||||
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
|
||||
"gramps_id": self.gramps_id, # 1
|
||||
"gramps_id": self.gramps_id, # 1
|
||||
"date": DateBase.to_struct(self), # 2
|
||||
"page": unicode(self.page), # 3
|
||||
"confidence": self.confidence, # 4
|
||||
"source_handle": self.source_handle, # 5
|
||||
"note_list": NoteBase.to_struct(self), # 6
|
||||
"media_list": MediaBase.to_struct(self), # 7
|
||||
"datamap": self.datamap, # 8
|
||||
"page": unicode(self.page), # 3
|
||||
"confidence": self.confidence, # 4
|
||||
"source_handle": self.source_handle, # 5
|
||||
"note_list": NoteBase.to_struct(self), # 6
|
||||
"media_list": MediaBase.to_struct(self), # 7
|
||||
"datamap": self.datamap, # 8
|
||||
"change": self.change, # 9
|
||||
"private": self.private} # 10
|
||||
"private": self.private} # 10
|
||||
|
||||
def unserialize(self, data):
|
||||
"""
|
||||
|
@ -71,7 +71,23 @@ class CitationBase(object):
|
||||
|
||||
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
|
||||
|
||||
|
@ -639,7 +639,23 @@ class Date(object):
|
||||
|
||||
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,
|
||||
"modifier": self.modifier,
|
||||
|
@ -65,7 +65,23 @@ class DateBase(object):
|
||||
|
||||
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:
|
||||
date = Date().to_struct()
|
||||
|
@ -119,21 +119,23 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
|
||||
def to_struct(self):
|
||||
"""
|
||||
Convert the data held in the event to a Python tuple that
|
||||
represents all the data elements.
|
||||
Convert the data held in this object to a structure (eg,
|
||||
struct) that represents all the data elements.
|
||||
|
||||
This method is used to convert the object into a form that can easily
|
||||
be saved to a database.
|
||||
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 elements may be primitive Python types (string, integers),
|
||||
complex Python types (lists or tuples, or Python objects. If the
|
||||
target database cannot handle complex types (such as objects or
|
||||
lists), the database is responsible for converting the data into
|
||||
a form that it can use.
|
||||
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 python tuple containing the data that should
|
||||
be considered persistent.
|
||||
:rtype: tuple
|
||||
:returns: Returns a struct containing the data of the object.
|
||||
:rtype: dict
|
||||
"""
|
||||
return {"handle": self.handle,
|
||||
"gramps_id": self.gramps_id,
|
||||
|
@ -79,7 +79,23 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
|
||||
|
||||
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),
|
||||
|
@ -130,21 +130,23 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
|
||||
def to_struct(self):
|
||||
"""
|
||||
Convert the data held in the event to a Python tuple that
|
||||
represents all the data elements.
|
||||
Convert the data held in this object to a structure (eg,
|
||||
struct) that represents all the data elements.
|
||||
|
||||
This method is used to convert the object into a form that can easily
|
||||
be saved to a database.
|
||||
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 elements may be primitive Python types (string, integers),
|
||||
complex Python types (lists or tuples, or Python objects. If the
|
||||
target database cannot handle complex types (such as objects or
|
||||
lists), the database is responsible for converting the data into
|
||||
a form that it can use.
|
||||
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 python tuple containing the data that should
|
||||
be considered persistent.
|
||||
:rtype: tuple
|
||||
:returns: Returns a struct containing the data of the object.
|
||||
:rtype: dict
|
||||
"""
|
||||
return {"handle": self.handle,
|
||||
"gramps_id": self.gramps_id,
|
||||
|
@ -199,7 +199,25 @@ class GrampsType(object):
|
||||
return (self.__value, self.__string)
|
||||
|
||||
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,
|
||||
"string": str(self)}
|
||||
|
||||
|
@ -146,7 +146,23 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase,
|
||||
|
||||
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),
|
||||
"note_list": NoteBase.to_struct(self),
|
||||
|
@ -68,7 +68,23 @@ class LdsOrdBase(object):
|
||||
|
||||
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]
|
||||
|
||||
|
@ -66,7 +66,23 @@ class Location(SecondaryObject, LocationBase):
|
||||
|
||||
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,
|
||||
"locality": self.locality,
|
||||
|
@ -66,19 +66,6 @@ class LocationBase(object):
|
||||
return (self.street, self.locality, self.city, self.county, self.state,
|
||||
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):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
|
@ -60,7 +60,23 @@ class MediaBase(object):
|
||||
|
||||
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]
|
||||
|
||||
|
@ -118,21 +118,23 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
|
||||
def to_struct(self):
|
||||
"""
|
||||
Convert the data held in the event to a Python tuple that
|
||||
represents all the data elements.
|
||||
Convert the data held in this object to a structure (eg,
|
||||
struct) that represents all the data elements.
|
||||
|
||||
This method is used to convert the object into a form that can easily
|
||||
be saved to a database.
|
||||
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 elements may be primitive Python types (string, integers),
|
||||
complex Python types (lists or tuples, or Python objects. If the
|
||||
target database cannot handle complex types (such as objects or
|
||||
lists), the database is responsible for converting the data into
|
||||
a form that it can use.
|
||||
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 python tuple containing the data that should
|
||||
be considered persistent.
|
||||
:rtype: tuple
|
||||
:returns: Returns a struct containing the data of the object.
|
||||
:rtype: dict
|
||||
"""
|
||||
return {"handle": self.handle,
|
||||
"gramps_id": self.gramps_id,
|
||||
|
@ -72,7 +72,23 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase,
|
||||
|
||||
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),
|
||||
"citation_list": CitationBase.to_struct(self),
|
||||
|
@ -128,7 +128,23 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
|
||||
|
||||
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),
|
||||
"citation_list": CitationBase.to_struct(self),
|
||||
|
@ -98,11 +98,24 @@ class Note(BasicPrimaryObject, TagBase):
|
||||
self.private)
|
||||
|
||||
def to_struct(self):
|
||||
"""Convert the object to a serialized tuple of data.
|
||||
|
||||
:returns: The serialized format of the instance.
|
||||
:rtype: tuple
|
||||
"""
|
||||
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,
|
||||
"gramps_id": self.gramps_id,
|
||||
|
@ -55,7 +55,23 @@ class NoteBase(object):
|
||||
|
||||
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
|
||||
|
||||
|
@ -78,28 +78,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
||||
MALE = 1
|
||||
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):
|
||||
"""
|
||||
Create a new Person instance.
|
||||
@ -182,63 +160,51 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
||||
)
|
||||
|
||||
def to_struct(self):
|
||||
return {
|
||||
"handle": 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": 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
|
||||
}
|
||||
"""
|
||||
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.
|
||||
|
||||
def from_struct(self, to_struct):
|
||||
self.handle = to_struct["handle"] # 0
|
||||
self.gramps_id = to_struct["gramps_id"] # 1
|
||||
self.gender = to_struct["gender"] # 2
|
||||
self.primary_name = Name.from_struct(to_struct["primary_name"]) # 3
|
||||
self.alternate_names = [Name.from_struct(name)
|
||||
for name in to_struct["alternate_names"]] # 4
|
||||
self.death_ref_index = to_struct["death_ref_index"] # 5
|
||||
self.birth_ref_index = to_struct["birth_ref_index"] # 6
|
||||
self.event_ref_list = [EventRef.from_struct(er)
|
||||
for er in to_struct["event_ref_list"]] # 7
|
||||
self.family_list = to_struct["family_list"] # 8
|
||||
self.parent_family_list = to_struct["parent_family_list"] # 9
|
||||
self.media_list = [MediaBase.from_struct(m)
|
||||
for m in to_struct["media_list"]] # 10
|
||||
self.address_list = [AddressBase.from_struct(a)
|
||||
for a in to_struct["address_list"]] # 11
|
||||
self.attribute_list = [AttributeBase.from_struct(attr)
|
||||
for attr in to_struct["attribute_list"]] # 12
|
||||
self.urls = [UrlBase.from_struct(url)
|
||||
for url in to_struct["urls"]] # 13
|
||||
self.lds_ord_list = [LdsOrdBase.from_struct(lref)
|
||||
for lref in to_struct["lds_ord_list"]] # 14
|
||||
self.citation_list = [CitationBase.from_struct(cref)
|
||||
for cref in to_struct["citation_list"]] # 15
|
||||
self.note_list = [NoteBase.from_struct(noteref)
|
||||
for noteref in to_struct["note_list"]] # 16
|
||||
self.change = to_struct["change"] # 17
|
||||
self.tag_list = [TagBase.from_struct(tag)
|
||||
for tag in to_struct["tag_list"]] # 18
|
||||
self.private = to_struct["private"] # 19
|
||||
self.person_ref_list = [PersonRef.from_struct(pr)
|
||||
for pr in to_struct["person_ref_list"]] # 20
|
||||
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
|
||||
"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": 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 unserialize(self, data):
|
||||
"""
|
||||
|
@ -74,7 +74,23 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
|
||||
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),
|
||||
"citation_list": CitationBase.to_struct(self),
|
||||
|
@ -111,23 +111,24 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
|
||||
def to_struct(self):
|
||||
"""
|
||||
Convert the data held in the Place to a Python tuple that
|
||||
represents all the data elements.
|
||||
Convert the data held in this object to a structure (eg,
|
||||
struct) that represents all the data elements.
|
||||
|
||||
This method is used to convert the object into a form that can easily
|
||||
be saved to a database.
|
||||
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 elements may be primitive Python types (string, integers),
|
||||
complex Python types (lists or tuples, or Python objects. If the
|
||||
target database cannot handle complex types (such as objects or
|
||||
lists), the database is responsible for converting the data into
|
||||
a form that it can use.
|
||||
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 python tuple containing the data that should
|
||||
be considered persistent.
|
||||
:rtype: tuple
|
||||
:returns: Returns a struct containing the data of the object.
|
||||
:rtype: dict
|
||||
"""
|
||||
|
||||
if self.main_loc is None or self.main_loc.serialize() == _EMPTY_LOC:
|
||||
main_loc = None
|
||||
else:
|
||||
|
@ -164,14 +164,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase):
|
||||
def replace_media_references(self, old_handle, new_handle):
|
||||
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
|
||||
|
@ -59,7 +59,23 @@ class PrivacyBase(object):
|
||||
|
||||
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
|
||||
|
||||
|
@ -50,7 +50,23 @@ class RefBase(object):
|
||||
|
||||
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
|
||||
|
||||
|
@ -69,7 +69,23 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject):
|
||||
|
||||
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,
|
||||
"gramps_id": self.gramps_id,
|
||||
|
@ -71,7 +71,23 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase):
|
||||
|
||||
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 {
|
||||
"note_list": NoteBase.to_struct(self),
|
||||
|
@ -63,9 +63,32 @@ class Researcher(LocationBase):
|
||||
|
||||
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,
|
||||
"address": self.addr,
|
||||
"email": self.email}
|
||||
|
@ -71,7 +71,23 @@ class Source(MediaBase, NoteBase, PrimaryObject):
|
||||
|
||||
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,
|
||||
"gramps_id": self.gramps_id,
|
||||
|
@ -273,11 +273,24 @@ class StyledText(object):
|
||||
return (self._string, the_tags)
|
||||
|
||||
def to_struct(self):
|
||||
"""Convert the object to a serialized tuple of data.
|
||||
|
||||
:returns: Serialized format of the instance.
|
||||
:returnstype: tuple
|
||||
"""
|
||||
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._tags:
|
||||
the_tags = [tag.to_struct() for tag in self._tags]
|
||||
|
@ -74,11 +74,24 @@ class StyledTextTag(object):
|
||||
return (self.name.serialize(), self.value, self.ranges)
|
||||
|
||||
def to_struct(self):
|
||||
"""Convert the object to a serialized tuple of data.
|
||||
|
||||
:returns: Serialized format of the instance.
|
||||
:returnstype: tuple
|
||||
"""
|
||||
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 {"name": self.name.to_struct(),
|
||||
"value": self.value,
|
||||
|
@ -73,7 +73,23 @@ class Surname(SecondaryObject):
|
||||
|
||||
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,
|
||||
"prefix": self.prefix,
|
||||
|
@ -64,7 +64,23 @@ class SurnameBase(object):
|
||||
|
||||
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]
|
||||
|
||||
|
@ -201,21 +201,23 @@ class Tag(TableObject):
|
||||
|
||||
def to_struct(self):
|
||||
"""
|
||||
Convert the data held in the event to a Python tuple that
|
||||
represents all the data elements.
|
||||
Convert the data held in this object to a structure (eg,
|
||||
struct) that represents all the data elements.
|
||||
|
||||
This method is used to convert the object into a form that can easily
|
||||
be saved to a database.
|
||||
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 elements may be primitive Python types (string, integers),
|
||||
complex Python types (lists or tuples, or Python objects. If the
|
||||
target database cannot handle complex types (such as objects or
|
||||
lists), the database is responsible for converting the data into
|
||||
a form that it can use.
|
||||
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 python tuple containing the data that should
|
||||
be considered persistent.
|
||||
:rtype: tuple
|
||||
:returns: Returns a struct containing the data of the object.
|
||||
:rtype: dict
|
||||
"""
|
||||
return {"handle": self.handle,
|
||||
"name": self.__name,
|
||||
@ -223,7 +225,5 @@ class Tag(TableObject):
|
||||
"priority": self.__priority,
|
||||
"change": self.change}
|
||||
|
||||
FIELDS = ["handle", "name", "color", "priority", "change"]
|
||||
|
||||
priority = property(get_priority, set_priority, None,
|
||||
'Returns or sets priority of the tag')
|
||||
|
@ -56,7 +56,23 @@ class TagBase(object):
|
||||
|
||||
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
|
||||
|
||||
|
@ -70,6 +70,25 @@ class Url(SecondaryObject, PrivacyBase):
|
||||
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 {"private": self.private,
|
||||
"path": self.path,
|
||||
"desc": self.desc,
|
||||
|
@ -62,7 +62,23 @@ class UrlBase(object):
|
||||
|
||||
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]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user