The gramps.gen.lib Module

The core library of Gramps objects

Base objects

BaseObject

Base Object class for Gramps

class gramps.gen.lib.baseobj.BaseObject[source]

Bases: object

The BaseObject is the base class for all data objects in Gramps, whether primary or not.

Its main goal is to provide common capabilites to all objects, such as searching through all available information.

classmethod create(data)[source]
from_struct(struct)[source]

Given a struct data representation, return an object of this type.

These structures may be primitive Python types (string, integer, boolean, etc.) or complex Python types (lists, tuples, or dicts). If the return type is a dict, then the keys of the dict match the fieldname of the object. If the return struct (or value of a dict key) is a list, then it is a list of structs. Otherwise, the struct is just the value of the attribute.

Returns:Returns an object of this type.
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:Returns the list of (classname, handle) tuples for referenced objects.
Return type:list
get_referenced_handles_recursively()[source]

Return the list of (classname, handle) tuples for all referenced primary objects, whether directly or through child objects.

Returns:Returns the list of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
matches_regexp(pattern, case_sensitive=False)[source]

Return True if any text data in the object or any of it’s child objects matches a given regular expression.

Parameters:pattern (str) – The pattern to match.
Returns:Returns whether any text data in the object or any of it’s child objects matches a given regexp.
Return type:bool
matches_string(pattern, case_sensitive=False)[source]

Return True if any text data in the object or any of it’s child objects matches a given pattern.

Parameters:
  • pattern (str) – The pattern to match.
  • case_sensitive (bool) – Whether the match is case-sensitive.
Returns:

Returns whether any text data in the object or any of it’s child objects matches a given pattern.

Return type:

bool

merge(acquisition)[source]

Merge content of this object with that of acquisition.

There are two sides to merger. First, the content of acquisition needs to be incorporated. Second, handles that reference acquisition (if there are any) need to be updated. Only the first part is handled in gen.lib, the second part needs access to the database and should be done in its own routines.

Parameters:acquisition (BaseObject) – The object to incorporate.
serialize()[source]

Convert the object to a serialized tuple of data.

to_struct()[source]

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.
unserialize(data)[source]

Convert a serialized tuple of data to an object.

AddressBase

AddressBase class for Gramps.

class gramps.gen.lib.addressbase.AddressBase(source=None)[source]

Bases: object

Base class for address-aware objects.

add_address(address)[source]

Add the Address instance to the object’s list of addresses.

Parameters:address (list) – Address instance to add to the object’s address list
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_address_list()[source]

Return the list of Address instances associated with the object.

Returns:Returns the list of Address instances
Return type:list
remove_address(address)[source]

Remove the specified Address instance from the address list.

If the instance does not exist in the list, the operation has no effect.

Parameters:address (Address) – Address instance to remove from the list
Returns:True if the address was removed, False if it was not in the list.
Return type:bool
serialize()[source]

Convert the object to a serialized tuple of data.

set_address_list(address_list)[source]

Assign the passed list to the object’s list of Address instances.

Parameters:address_list (list) – List of Address instances to be associated with the object
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

AttributeRootBase

AttributeRootBase class for Gramps.

class gramps.gen.lib.attrbase.AttributeRootBase(source=None)[source]

Bases: object

Base class for attribute-aware objects.

add_attribute(attribute)[source]

Add the Attribute instance to the object’s list of attributes.

Parameters:attribute (Attribute) – Attribute instance to add.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_attribute_list()[source]

Return the list of Attribute instances associated with the object.

Returns:Returns the list of Attribute instances.
Return type:list
remove_attribute(attribute)[source]

Remove the specified Attribute instance from the attribute list.

If the instance does not exist in the list, the operation has no effect.

Parameters:attribute (Attribute) – Attribute instance to remove from the list
Returns:True if the attribute was removed, False if it was not in the list.
Return type:bool
serialize()[source]

Convert the object to a serialized tuple of data.

set_attribute_list(attribute_list)[source]

Assign the passed list to the Person’s list of Attribute instances.

Parameters:attribute_list (list) – List of Attribute instances to ba associated with the Person
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

AttributeBase

class gramps.gen.lib.attrbase.AttributeBase(source=None)[source]

Bases: gramps.gen.lib.attrbase.AttributeRootBase

SrcAttributeBase

class gramps.gen.lib.attrbase.SrcAttributeBase(source=None)[source]

Bases: gramps.gen.lib.attrbase.AttributeRootBase

CitationBase

CitationBase class for Gramps.

class gramps.gen.lib.citationbase.CitationBase(source=None)[source]

Bases: object

Base class for storing citations.

Starting in 3.4, the objects may have multiple citations. Internally, this class maintains a list of Citation handles, as a citation_list attribute of the CitationBase object. This class is analogous to the notebase class. Both these have no attributes of their own; in this respect, they differ from classes like MediaRef, which does have attributes (in that case, privacy, sources, notes and attributes).

This class, together with the Citation class, replaces the old SourceRef class. I.e. SourceRef = CitationBase + Citation

add_citation(handle)[source]

Add the Citation handle to the list of citation handles.

Parameters:handle (str) – Citation handle to add the list of citations
Returns:True if handle was added, False if it already was in the list
Return type:bool
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_all_citation_lists()[source]

Return the list of Citation handles associated with the object or with child objects.

Returns:The list of Citation handles
Return type:list
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

All methods which inherit from CitationBase and have other child objects with citations, should return here a list of child objects which are CitationBase

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_citation_list()[source]

Return the list of Citation handles associated with the object.

Returns:The list of Citation handles
Return type:list
get_referenced_citation_handles()[source]

Return the list of (classname, handle) tuples for all referenced citations.

This method should be used to get the Citation portion of the list by objects that store citation lists.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
has_citation_reference(citation_handle)[source]

Return True if the object or any of its child objects has reference to this citation handle.

Parameters:citation_handle (str) – The citation handle to be checked.
Returns:Returns whether the object or any of its child objects has reference to this citation handle.
Return type:bool
remove_citation_references(citation_handle_list)[source]

Remove the specified handles from the list of citation handles, and all secondary child objects.

Parameters:citation_handle_list – The list of citation handles to be removed
replace_citation_references(old_handle, new_handle)[source]

Replace references to citation handles in the list of this object and all child objects and merge equivalent entries.

Parameters:
  • old_handle (str) – The citation handle to be replaced.
  • new_handle (str) – The citation handle to replace the old one with.
serialize()[source]

Convert the object to a serialized tuple of data.

set_citation_list(citation_list)[source]

Assign the passed list to be object’s list of Citation handles.

Parameters:citation_list (list) – List of Citation handles to be set on the object
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

IndirectCitationBase

class gramps.gen.lib.citationbase.IndirectCitationBase[source]

Bases: object

Citation management logic for objects that don’t have citations for the primary objects, but only for the child (secondary) ones.

The derived class must implement the get_citation_child_list() method to return the list of child secondary objects that may refer citations.

Note

for most objects, this functionality is inherited from CitationBase, which checks both the object and the child objects.

get_citation_list()[source]

Return the list of Citation handles associated with the object. For an IndirectCitationBase this is always the empty list :returns: The list of Citation handles :rtype: list

has_citation_reference(citation_handle)[source]

Return True if any of the child objects has reference to this citation handle.

Parameters:citation_handle (str) – The citation handle to be checked.
Returns:Returns whether any of it’s child objects has reference to this citation handle.
Return type:bool
remove_citation_references(citation_handle_list)[source]

Remove references to all citation handles in the list in all child objects.

Parameters:citation_handle_list (list) – The list of citation handles to be removed.
replace_citation_references(old_handle, new_handle)[source]

Replace references to citation handles in all child objects and merge equivalent entries.

Parameters:
  • old_handle (str) – The citation handle to be replaced.
  • new_handle (str) – The citation handle to replace the old one with.

DateBase

DateBase class for Gramps.

class gramps.gen.lib.datebase.DateBase(source=None)[source]

Bases: object

Base class for storing date information.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_date_object()[source]

Return the Date object associated with the DateBase.

Returns:Returns a DateBase Date instance.
Return type:Date
serialize(no_text_date=False)[source]

Convert the object to a serialized tuple of data.

set_date_object(date)[source]

Set the Date object associated with the DateBase.

Parameters:date (Date) – Date instance to be assigned to the DateBase
to_struct(no_text_date=False)[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

LdsOrdBase

LdsOrdBase class for Gramps.

class gramps.gen.lib.ldsordbase.LdsOrdBase(source=None)[source]

Bases: object

Base class for lds_ord-aware objects.

add_lds_ord(lds_ord)[source]

Add the LdsOrd instance to the object’s list of lds_ords.

Parameters:lds_ord (list) – LdsOrd instance to add to the object’s lds_ord list
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_lds_ord_list()[source]

Return the list of LdsOrd instances associated with the object.

Returns:Returns the list of LdsOrd instances
Return type:list
remove_lds_ord(lds_ord)[source]

Remove the specified LdsOrd instance from the lds_ord list.

If the instance does not exist in the list, the operation has no effect.

Parameters:lds_ord (LdsOrd) – LdsOrd instance to remove from the list
Returns:True if the lds_ord was removed, False if it was not in the list.
Return type:bool
serialize()[source]

Convert the object to a serialized tuple of data.

set_lds_ord_list(lds_ord_list)[source]

Assign the passed list to the object’s list of LdsOrd instances.

Parameters:lds_ord_list (list) – List of LdsOrd instances to be associated with the object
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object

LocationBase

LocationBase class for Gramps.

class gramps.gen.lib.locationbase.LocationBase(source=None)[source]

Bases: object

Base class for all things Address.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_city()[source]

Return the city name of the LocationBase object.

get_country()[source]

Return the country name of the LocationBase object.

get_county()[source]

Return the county name of the LocationBase object.

get_locality()[source]

Return the locality portion of the Location.

get_phone()[source]

Return the phone number of the LocationBase object.

get_postal_code()[source]

Return the postal code of the LocationBase object.

get_state()[source]

Return the state name of the LocationBase object.

get_street()[source]

Return the street portion of the Location.

get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
serialize()[source]

Convert the object to a serialized tuple of data.

set_city(data)[source]

Set the city name of the LocationBase object.

set_country(data)[source]

Set the country name of the LocationBase object.

set_county(data)[source]

Set the county name of the LocationBase object.

set_locality(val)[source]

Set the locality portion of the Location.

set_phone(data)[source]

Set the phone number of the LocationBase object.

set_postal_code(data)[source]

Set the postal code of the LocationBase object.

set_state(data)[source]

Set the state name of the LocationBase object.

set_street(val)[source]

Set the street portion of the Location.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

MediaBase

MediaBase class for Gramps.

class gramps.gen.lib.mediabase.MediaBase(source=None)[source]

Bases: object

Base class for storing media references.

add_media_reference(media_ref)[source]

Add a MediaRef instance to the object’s media list.

Parameters:media_ref (MediaRef) – MediaRef instance to be added to the object’s media list.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_media_list()[source]

Return the list of MediaRef instances associated with the object.

Returns:list of MediaRef instances associated with the object
Return type:list
has_media_reference(obj_handle)[source]

Return True if the object or any of it’s child objects has reference to this media object handle.

Parameters:obj_handle (str) – The media handle to be checked.
Returns:Returns whether the object or any of it’s child objects has reference to this media handle.
Return type:bool
remove_media_references(obj_handle_list)[source]

Remove references to all media handles in the list.

Parameters:obj_handle_list (list) – The list of media handles to be removed.
replace_media_references(old_handle, new_handle)[source]

Replace all references to old media handle with the new handle and merge equivalent entries.

Parameters:
  • old_handle (str) – The media handle to be replaced.
  • new_handle (str) – The media handle to replace the old one with.
serialize()[source]

Convert the object to a serialized tuple of data.

set_media_list(media_ref_list)[source]

Set the list of MediaRef instances associated with the object. It replaces the previous list.

Parameters:media_ref_list (list) – list of MediaRef instances to be assigned to the object.
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

NoteBase

NoteBase class for Gramps.

class gramps.gen.lib.notebase.NoteBase(source=None)[source]

Bases: object

Base class for storing notes.

Starting in 3.0 branch, the objects may have multiple notes. Internally, this class maintains a list of Note handles, as a note_list attribute of the NoteBase object.

add_note(handle)[source]

Add the Note handle to the list of note handles.

Parameters:handle (str) – Note handle to add the list of notes
Returns:True if handle was added, False if it already was in the list
Return type:bool
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

All methods which inherit from NoteBase and have other child objects with notes, should return here a list of child objects which are NoteBase

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_note_list()[source]

Return the list of Note handles associated with the object.

Returns:The list of Note handles
Return type:list
get_referenced_note_handles()[source]

Return the list of (classname, handle) tuples for all referenced notes.

This method should be used to get the Note portion of the list by objects that store note lists.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
has_note_reference(note_handle)[source]

Return True if the object or any of its child objects has reference to this note handle.

Parameters:note_handle (str) – The note handle to be checked.
Returns:Returns whether the object or any of its child objects has reference to this note handle.
Return type:bool
remove_note(handle)[source]

Remove the specified handle from the list of note handles, and all secondary child objects.

Parameters:handle (str) – Note handle to remove from the list of notes
replace_note_references(old_handle, new_handle)[source]

Replace references to note handles in the list of this object and all child objects and merge equivalent entries.

Parameters:
  • old_handle (str) – The note handle to be replaced.
  • new_handle (str) – The note handle to replace the old one with.
serialize()[source]

Convert the object to a serialized tuple of data.

set_note_list(note_list)[source]

Assign the passed list to be object’s list of Note handles.

Parameters:note_list (list) – List of Note handles to be set on the object
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

PlaceBase

PlaceBase class for Gramps.

class gramps.gen.lib.placebase.PlaceBase(source=None)[source]

Bases: object

Base class for place-aware objects.

get_place_handle()[source]

Return the database handle of the Place associated with the Event.

Returns:Place database handle
Return type:str
set_place_handle(place_handle)[source]

Set the database handle for Place associated with the object.

Parameters:place_handle (str) – Place database handle

PrivacyBase

PrivacyBase Object class for Gramps.

class gramps.gen.lib.privacybase.PrivacyBase(source=None)[source]

Bases: object

Base class for privacy-aware objects.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_privacy()[source]

Return the privacy level of the data.

Returns:True indicates that the record is private
Return type:bool
serialize()[source]

Convert the object to a serialized tuple of data.

set_privacy(val)[source]

Set or clears the privacy flag of the data.

Parameters:val (bool) – value to assign to the privacy flag. True indicates that the record is private, False indicates that it is public.
to_struct()[source]

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.
Return type:bool
unserialize(data)[source]

Convert a serialized tuple of data to an object.

RefBase

Base Reference class for Gramps.

class gramps.gen.lib.refbase.RefBase(source=None)[source]

Bases: object

Base reference class to manage references to other objects.

Any Ref classes should derive from this class.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_reference_handle()[source]
get_referenced_handles()[source]

Returns the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:Returns the list of (classname, handle) tuples for referenced objects.
Return type:list
serialize()[source]

Convert the object to a serialized tuple of data.

set_reference_handle(val)[source]
unserialize(data)[source]

Convert a serialized tuple of data to an object.

SurnameBase

SurnameBase class for Gramps.

class gramps.gen.lib.surnamebase.SurnameBase(source=None)[source]

Bases: object

Base class for surname-aware objects.

add_surname(surname)[source]

Add the Surname instance to the object’s list of surnames.

Parameters:surnameSurname instance to add to the object’s address list.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_connectors()[source]

Return a list of surnames (no prefix or connectors)

get_prefixes()[source]

Return a list of prefixes

get_primary_surname()[source]

Return the surname that is the primary surname

Returns:Returns the surname instance that is the primary surname. If primary not set, and there is a surname, the first surname is given, if no surnames, None is returned
Return type:Surname or None
get_surname()[source]

Return a fully formatted surname utilizing the surname_list

get_surname_list()[source]

Return the list of Surname instances associated with the object.

Returns:Returns the list of Surname instances
Return type:list
get_surnames()[source]

Return a list of surnames (no prefix or connectors)

get_upper_surname()[source]

Return a fully formatted surname capitalized

remove_surname(surname)[source]

Remove the specified Surname instance from the surname list.

If the instance does not exist in the list, the operation has no effect.

Parameters:surname (Surname) – Surname instance to remove from the list
Returns:True if the surname was removed, False if it was not in the list.
Return type:bool
serialize()[source]

Convert the object to a serialized tuple of data.

set_primary_surname(surnamenr=0)[source]

Set the surname with surnamenr in the surname list as primary surname Counting starts at 0

set_surname_list(surname_list)[source]

Assign the passed list to the object’s list of Surname instances.

Parameters:surname_list (list) – List of Surname instances to be associated with the object
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

TagBase

TagBase class for Gramps.

class gramps.gen.lib.tagbase.TagBase(source=None)[source]

Bases: object

Base class for tag-aware objects.

add_tag(tag)[source]

Add the tag to the object’s list of tags.

Parameters:tag (unicode) – unicode tag to add.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_referenced_tag_handles()[source]

Return the list of (classname, handle) tuples for all referenced tags.

This method should be used to get the Tag portion of the list by objects that store tag lists.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_tag_list()[source]

Return the list of tags associated with the object.

Returns:Returns the list of tags.
Return type:list
remove_tag(tag)[source]

Remove the specified tag from the tag list.

If the tag does not exist in the list, the operation has no effect.

Parameters:tag (unicode) – tag to remove from the list.
Returns:True if the tag was removed, False if it was not in the list.
Return type:bool
replace_tag_references(old_handle, new_handle)[source]

Replace references to note handles in the list of this object and merge equivalent entries.

Parameters:
  • old_handle (str) – The note handle to be replaced.
  • new_handle (str) – The note handle to replace the old one with.
serialize()[source]

Convert the object to a serialized tuple of data.

set_tag_list(tag_list)[source]

Assign the passed list to the objects’s list of tags.

Parameters:tag_list (list) – List of tags to ba associated with the object.
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

UrlBase

UrlBase class for Gramps.

class gramps.gen.lib.urlbase.UrlBase(source=None)[source]

Bases: object

Base class for url-aware objects.

add_url(url)[source]

Add a Url instance to the object’s list of Url instances.

Parameters:url (Url) – Url instance to be added to the Person’s list of related web sites.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_url_list()[source]

Return the list of Url instances associated with the object.

Returns:List of Url instances
Return type:list
remove_url(url)[source]

Remove the specified Url instance from the url list.

If the instance does not exist in the list, the operation has no effect.

Parameters:url (Url) – Url instance to remove from the list
Returns:True if the url was removed, False if it was not in the list.
Return type:bool
serialize()[source]

Convert the object to a serialized tuple of data

set_url_list(url_list)[source]

Set the list of Url instances to passed the list.

Parameters:url_list (list) – List of Url instances
to_struct()[source]

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.
Return type:list
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Primary objects

BasicPrimaryObject

Basic Primary Object class for Gramps.

class gramps.gen.lib.primaryobj.BasicPrimaryObject(source=None)[source]

Bases: gramps.gen.lib.tableobj.TableObject, gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.tagbase.TagBase

The BasicPrimaryObject is the base class for Note objects.

It is also the base class for the PrimaryObject class.

The PrimaryObject is the base class for all other primary objects in the database. Primary objects are the core objects in the database. Each object has a database handle and a Gramps ID value. The database handle is used as the record number for the database, and the Gramps ID is the user visible version.

get_gramps_id()[source]

Return the Gramps ID for the primary object.

Returns:Gramps ID associated with the object
Return type:str
has_handle_reference(classname, handle)[source]

Return True if the object has reference to a given handle of given primary object type.

Parameters:
  • classname (str) – The name of the primary object class.
  • handle (str) – The handle to be checked.
Returns:

Returns whether the object has reference to this handle of this object type.

Return type:

bool

has_media_reference(handle)[source]

Indicate if the object has a media references.

In the base class, no such references exist. Derived classes should override this if they provide media references.

remove_citation_references(handle_list)[source]

Remove the specified source references from the object.

In the base class no such references exist. Derived classes should override this if they provide source references.

remove_handle_references(classname, handle_list)[source]

Remove all references in this object to object handles in the list.

Parameters:
  • classname (str) – The name of the primary object class.
  • handle_list (str) – The list of handles to be removed.
remove_media_references(handle_list)[source]

Remove the specified media references from the object.

In the base class no such references exist. Derived classes should override this if they provide media references.

replace_citation_references(old_handle, new_handle)[source]
replace_handle_reference(classname, old_handle, new_handle)[source]

Replace all references to old handle with those to the new handle.

Parameters:
  • classname (str) – The name of the primary object class.
  • old_handle (str) – The handle to be replaced.
  • new_handle (str) – The handle to replace the old one with.
replace_media_references(old_handle, new_handle)[source]
set_gramps_id(gramps_id)[source]

Set the Gramps ID for the primary object.

Parameters:gramps_id (str) – Gramps ID

PrimaryObject

class gramps.gen.lib.primaryobj.PrimaryObject(source=None)[source]

Bases: gramps.gen.lib.primaryobj.BasicPrimaryObject

The PrimaryObject is the base class for all primary objects in the database.

Primary objects are the core objects in the database. Each object has a database handle and a Gramps ID value. The database handle is used as the record number for the database, and the Gramps ID is the user visible version.

has_handle_reference(classname, handle)[source]

Return True if the object has reference to a given handle of given primary object type.

Parameters:
  • classname (str) – The name of the primary object class.
  • handle (str) – The handle to be checked.
Returns:

Returns whether the object has reference to this handle of this object type.

Return type:

bool

remove_handle_references(classname, handle_list)[source]

Remove all references in this object to object handles in the list.

Parameters:
  • classname (str) – The name of the primary object class.
  • handle_list (str) – The list of handles to be removed.
replace_handle_reference(classname, old_handle, new_handle)[source]

Replace all references to old handle with those to the new handle.

Parameters:
  • classname (str) – The name of the primary object class.
  • old_handle (str) – The handle to be replaced.
  • new_handle (str) – The handle to replace the old one with.

Person

Person object for Gramps.

class gramps.gen.lib.person.Person(data=None)[source]

Bases: gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.attrbase.AttributeBase, gramps.gen.lib.mediabase.MediaBase, gramps.gen.lib.addressbase.AddressBase, gramps.gen.lib.urlbase.UrlBase, gramps.gen.lib.ldsordbase.LdsOrdBase, gramps.gen.lib.primaryobj.PrimaryObject

The Person record is the Gramps in-memory representation of an individual person. It contains all the information related to an individual.

Person objects are usually created in one of two ways.

  1. Creating a new person object, which is then initialized and added to the database.
  2. Retrieving an object from the database using the records handle.

Once a Person object has been modified, it must be committed to the database using the database object’s commit_person function, or the changes will be lost.

FEMALE = 0
MALE = 1
UNKNOWN = 2
add_alternate_name(name)[source]

Add a Name instance to the list of alternative names.

Parameters:name (Name) – Name to add to the list
add_event_ref(event_ref)[source]

Add the EventRef to the Person instance’s EventRef list.

This is accomplished by assigning the EventRef of a valid Event in the current database.

Parameters:event_ref (EventRef) – the EventRef to be added to the Person’s EventRef list.
add_family_handle(family_handle)[source]

Add the Family handle to the Person instance’s Family list.

This is accomplished by assigning the handle of a valid Family in the current database.

Adding a Family handle to a Person does not automatically update the corresponding Family. The developer is responsible to make sure that when a Family is added to Person, that the Person is assigned to either the father or mother role in the Family.

Parameters:family_handle (str) – handle of the Family to be added to the Person’s Family list.
add_parent_family_handle(family_handle)[source]

Add the Family handle to the Person instance’s list of families in which it is a child.

This is accomplished by assigning the handle of a valid Family in the current database.

Adding a Family handle to a Person does not automatically update the corresponding Family. The developer is responsible to make sure that when a Family is added to Person, that the Person is added to the Family instance’s child list.

Parameters:family_handle (str) – handle of the Family to be added to the Person’s Family list.
add_person_ref(person_ref)[source]

Add the PersonRef to the Person instance’s PersonRef list.

Parameters:person_ref (PersonRef) – the PersonRef to be added to the Person’s PersonRef list.
clear_family_handle_list()[source]

Remove all Family handles from the Family list.

clear_parent_family_handle_list()[source]

Remove all Family handles from the parent Family list.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_alternate_names()[source]

Return the list of alternate Name instances.

Returns:List of Name instances
Return type:list
get_birth_ref()[source]

Return the EventRef for Person’s birth event.

This should correspond to an Event in the database’s Event list.

Returns:Returns the birth EventRef or None if no birth Event has been assigned.
Return type:EventRef
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_death_ref()[source]

Return the EventRef for the Person’s death event.

This should correspond to an Event in the database’s Event list.

Returns:Returns the death EventRef or None if no death Event has been assigned.
Return type:event_ref
get_event_ref_list()[source]

Return the list of EventRef objects associated with Event instances.

Returns:Returns the list of EventRef objects associated with the Person instance.
Return type:list
get_family_handle_list()[source]

Return the list of Family handles in which the person is a parent or spouse.

Returns:Returns the list of handles corresponding to the Family records with which the person is associated.
Return type:list
get_gender()[source]

Return the gender of the Person.

Returns:Returns one of the following constants:
  • Person.MALE
  • Person.FEMALE
  • Person.UNKNOWN
Return type:int
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_main_parents_family_handle()[source]

Return the handle of the Family considered to be the main Family in which the Person is a child.

Returns:Returns the family_handle if a family_handle exists, If no Family is assigned, None is returned
Return type:str
get_nick_name()[source]
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_parent_family_handle_list()[source]

Return the list of Family handles in which the person is a child.

Returns:Returns the list of handles corresponding to the Family records with which the person is a child.
Return type:list
get_person_ref_list()[source]

Return the list of PersonRef objects.

Returns:Returns the list of PersonRef objects.
Return type:list
get_primary_event_ref_list()[source]

Return the list of EventRef objects associated with Event instances that have been marked as primary events.

Returns:Returns generator of EventRef objects associated with the Person instance.
Return type:generator
get_primary_name()[source]

Return the Name instance marked as the Person’s primary name.

Returns:Returns the primary name
Return type:Name
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
classmethod get_schema()[source]
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
merge(acquisition)[source]

Merge the content of acquisition into this person.

Parameters:acquisition (Person) – The person to merge with the present person.
remove_family_handle(family_handle)[source]

Remove the specified Family handle from the list of marriages/partnerships.

If the handle does not exist in the list, the operation has no effect.

Parameters:family_handle (str) – Family handle to remove from the list
Returns:True if the handle was removed, False if it was not in the list.
Return type:bool
remove_parent_family_handle(family_handle)[source]

Remove the specified Family handle from the list of parent families (families in which the parent is a child).

If the handle does not exist in the list, the operation has no effect.

Parameters:family_handle (str) – Family handle to remove from the list
Returns:Returns a tuple of three strings, consisting of the removed handle, relationship to mother, and relationship to father. None is returned if the handle is not in the list.
Return type:tuple
serialize()[source]

Convert the data held in the Person to a Python tuple 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.

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.

Returns:Returns a python tuple containing the data that should be considered persistent.
Return type:tuple
set_alternate_names(alt_name_list)[source]

Change the list of alternate names to the passed list.

Parameters:alt_name_list (list) – List of Name instances
set_birth_ref(event_ref)[source]

Assign the birth event to the Person object.

This is accomplished by assigning the EventRef of the birth event in the current database.

Parameters:event_ref (EventRef) – the EventRef object associated with the Person’s birth.
set_death_ref(event_ref)[source]

Assign the death event to the Person object.

This is accomplished by assigning the EventRef of the death event in the current database.

Parameters:event_ref (EventRef) – the EventRef object associated with the Person’s death.
set_event_ref_list(event_ref_list)[source]

Set the Person instance’s EventRef list to the passed list.

Parameters:event_ref_list (list) – List of valid EventRef objects.
set_family_handle_list(family_list)[source]

Assign the passed list to the Person’s list of families in which it is a parent or spouse.

Parameters:family_list (list) – List of Family handles to be associated with the Person
set_gender(gender)[source]

Set the gender of the Person.

Parameters:gender (int) –

Assigns the Person’s gender to one of the following constants:

  • Person.MALE
  • Person.FEMALE
  • Person.UNKNOWN
set_main_parent_family_handle(family_handle)[source]

Set the main Family in which the Person is a child.

The main Family is the Family typically used for reports and navigation. This is accomplished by moving the Family to the beginning of the list. The family_handle must be in the list for this to have any effect.

Parameters:family_handle (str) – handle of the Family to be marked as the main Family
Returns:Returns True if the assignment has successful
Return type:bool
set_parent_family_handle_list(family_list)[source]

Return the list of Family handles in which the person is a child.

Returns:Returns the list of handles corresponding to the Family records with which the person is a child.
Return type:list
set_person_ref_list(person_ref_list)[source]

Set the Person instance’s PersonRef list to the passed list.

Parameters:person_ref_list (list) – List of valid PersonRef objects
set_preferred_family_handle(family_handle)[source]

Set the family_handle specified to be the preferred Family.

The preferred Family is determined by the first Family in the Family list, and is typically used to indicate the preferred Family for navigation or reporting.

The family_handle must already be in the list, or the function call has no effect.

Parameters:family_handle (str) – Handle of the Family to make the preferred Family.
Returns:True if the call succeeded, False if the family_handle was not already in the Family list.
Return type:bool
set_primary_name(name)[source]

Set the primary name of the Person to the specified Name instance.

Parameters:name (Name) – Name to be assigned to the person
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a Person object.

Parameters:data (tuple) – tuple containing the persistent data associated the Person object

Family

Family object for Gramps.

class gramps.gen.lib.family.Family[source]

Bases: gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.mediabase.MediaBase, gramps.gen.lib.attrbase.AttributeBase, gramps.gen.lib.ldsordbase.LdsOrdBase, gramps.gen.lib.primaryobj.PrimaryObject

The Family record is the Gramps in-memory representation of the relationships between people. It contains all the information related to the relationship.

Family objects are usually created in one of two ways.

  1. Creating a new Family object, which is then initialized and added to the database.
  2. Retrieving an object from the database using the records handle.

Once a Family object has been modified, it must be committed to the database using the database object’s commit_family function, or the changes will be lost.

add_child_ref(child_ref)[source]

Add the database handle for Person to the Family’s list of children.

Parameters:child_ref (ChildRef) – Child Reference instance
add_event_ref(event_ref)[source]

Add the EventRef to the Family instance’s EventRef list.

This is accomplished by assigning the EventRef for the valid Event in the current database.

Parameters:event_ref (EventRef) – the EventRef to be added to the Person’s EventRef list.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_child_ref_list()[source]

Return the list of ChildRef handles identifying the children of the Family.

Returns:Returns the list of ChildRef handles associated with the Family.
Return type:list
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_event_list()[source]
get_event_ref_list()[source]

Return the list of EventRef objects associated with Event instances.

Returns:Returns the list of EventRef objects associated with the Family instance.
Return type:list
get_father_handle()[source]

Return the database handle of the Person identified as the father of the Family.

Returns:Person database handle
Return type:str
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects..

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_mother_handle()[source]

Return the database handle of the Person identified as the mother of the Family.

Returns:Person database handle
Return type:str
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_relationship()[source]

Return the relationship type between the people identified as the father and mother in the relationship.

get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
merge(acquisition)[source]

Merge the content of acquisition into this family.

Lost: handle, id, relation, father, mother of acquisition.

Parameters:acquisition (Family) – The family to merge with the present family.
remove_child_handle(child_handle)[source]

Remove the database handle for Person to the Family’s list of children if the Person is already in the list.

Parameters:child_handle (str) – Person database handle
Returns:True if the handle was removed, False if it was not in the list.
Return type:bool
remove_child_ref(child_ref)[source]

Remove the database handle for Person to the Family’s list of children if the Person is already in the list.

Parameters:child_ref (ChildRef) – Child Reference instance
Returns:True if the handle was removed, False if it was not in the list.
Return type:bool
serialize()[source]

Convert the data held in the event to a Python tuple 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.

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.

Returns:Returns a python tuple containing the data that should be considered persistent.
Return type:tuple
set_child_ref_list(child_ref_list)[source]

Assign the passed list to the Family’s list children.

Parameters:child_ref_list (list of ChildRef instances) – List of Child Reference instances to be associated as the Family’s list of children.
set_event_ref_list(event_ref_list)[source]

Set the Family instance’s EventRef list to the passed list.

Parameters:event_ref_list (list) – List of valid EventRef objects
set_father_handle(person_handle)[source]

Set the database handle for Person that corresponds to male of the relationship.

For a same sex relationship, this can represent either of people involved in the relationship.

Parameters:person_handle (str) – Person database handle
set_mother_handle(person_handle)[source]

Set the database handle for Person that corresponds to male of the relationship.

For a same sex relationship, this can represent either of people involved in the relationship.

Parameters:person_handle (str) – Person database handle
set_relationship(relationship_type)[source]

Set the relationship type between the people identified as the father and mother in the relationship.

The type is a tuple whose first item is an integer constant and whose second item is the string. The valid values are:

Type Description
FamilyRelType.MARRIED indicates a legally recognized married relationship between two individuals. This may be either an opposite or a same sex relationship.
FamilyRelType.UNMARRIED indicates a relationship between two individuals that is not a legally recognized relationship.
FamilyRelType.CIVIL_UNION indicates a legally recongnized, non-married relationship between two individuals of the same sex.
FamilyRelType.UNKNOWN indicates that the type of relationship between the two individuals is not know.
FamilyRelType.CUSTOM indicates that the type of relationship between the two individuals does not match any of the other types.
Parameters:relationship_type (tuple) – (int,str) tuple of the relationship type between the father and mother of the relationship.
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a Family structure.

Event

Event object for Gramps.

class gramps.gen.lib.event.Event(source=None)[source]

Bases: gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.mediabase.MediaBase, gramps.gen.lib.attrbase.AttributeBase, gramps.gen.lib.datebase.DateBase, gramps.gen.lib.placebase.PlaceBase, gramps.gen.lib.primaryobj.PrimaryObject

The Event record is used to store information about some type of action that occurred at a particular place at a particular time, such as a birth, death, or marriage.

A possible definition: Events are things that happen at some point in time (that we may not know precisely, though), at some place, may involve several people (witnesses, officers, notaries, priests, etc.) and may of course have sources, notes, media, etc. Compare this with attribute: Attribute

are_equal(other)[source]

Return True if the passed Event is equivalent to the current Event.

Parameters:other (Event) – Event to compare against
Returns:True if the Events are equal
Return type:bool
description

Returns or sets description of the event

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_description()[source]

Return the description of the Event.

Returns:Returns the description of the Event
Return type:str
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_type()[source]

Return the type of the Event.

Returns:Type of the Event
Return type:tuple
is_empty()[source]

Return True if the Event is an empty object (no values set).

Returns:True if the Event is empty
Return type:bool
merge(acquisition)[source]

Merge the content of acquisition into this event.

Lost: handle, id, marker, type, date, place, description of acquisition.

Parameters:acquisition (Event) – The event to merge with the present event.
serialize(no_text_date=False)[source]

Convert the data held in the event to a Python tuple 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.

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.

Returns:Returns a python tuple containing the data that should be considered persistent.
Return type:tuple
set_description(description)[source]

Set the description of the Event to the passed string.

The string may contain any information.

Parameters:description (str) – Description to assign to the Event
set_type(the_type)[source]

Set the type of the Event to the passed (int,str) tuple.

Parameters:the_type (tuple) – Type to assign to the Event
to_struct()[source]

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.
Return type:dict
type

Returns or sets type of the event

unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in an Event structure.

Parameters:data (tuple) – tuple containing the persistent data associated with the Event object

Place

Place object for Gramps.

class gramps.gen.lib.place.Place(source=None)[source]

Bases: gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.mediabase.MediaBase, gramps.gen.lib.urlbase.UrlBase, gramps.gen.lib.primaryobj.PrimaryObject

Contains information related to a place, including multiple address information (since place names can change with time), longitude, latitude, a collection of images and URLs, a note and a source.

add_alternate_locations(location)[source]

Add a Location object to the alternate location list.

Parameters:location (Location) – Location instance to add
add_alternative_name(name)[source]

Add a name to the alternative names list.

Parameters:name (string) – name to add
add_placeref(placeref)[source]

Add a place reference to the list of place references.

Parameters:code (PlaceRef) – place reference to append to the list
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_all_names()[source]

Return a list of all names of the Place object.

Returns:Returns a list of all names of the Place
Return type:list
get_alternate_locations()[source]

Return a list of alternate Location objects the present alternate information about the current Place.

A Place can have more than one Location, since names and jurisdictions can change over time for the same place.

Returns:Returns the alternate Locations for the Place
Return type:list of Location objects
get_alternative_names()[source]

Return a list of alternative names for the current Place.

Returns:Returns the alternative names for the Place
Return type:list of strings
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:List of child secondary child objects that may refer citations.
Return type:list
get_code()[source]

Return the code of the Place object.

Returns:Returns the code of the Place
Return type:str
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_latitude()[source]

Return the latitude of the Place object.

Returns:Returns the latitude of the Place
Return type:str
get_longitude()[source]

Return the longitude of the Place object.

Returns:Returns the longitude of the Place
Return type:str
get_name()[source]

Return the name of the Place object.

Returns:Returns the name of the Place
Return type:str
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_placeref_list()[source]

Return the place reference list for the Place object.

Returns:Returns the place reference list for the Place
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_title()[source]

Return the descriptive title of the Place object.

Returns:Returns the descriptive title of the Place
Return type:str
get_type()[source]

Return the type of the Place object.

Returns:Returns the type of the Place
Return type:PlaceType
merge(acquisition)[source]

Merge the content of acquisition into this place.

Parameters:acquisition (Place) – The place to merge with the present place.
serialize()[source]

Convert the data held in the Place to a Python tuple 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.

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.

Returns:Returns a python tuple containing the data that should be considered persistent.
Return type:tuple
set_alternate_locations(location_list)[source]

Replace the current alternate Location object list with the new one.

Parameters:location_list (list of Location objects) – The list of Location objects to assign to the Place’s internal list.
set_alternative_names(name_list)[source]

Replace the current alternative names list with the new one.

Parameters:name_list (list of strings) – The list of names to assign to the Place’s internal list.
set_code(code)[source]

Set the code of the Place object.

Parameters:code (str) – code to assign to the Place
set_latitude(latitude)[source]

Set the latitude of the Place object.

Parameters:latitude (str) – latitude to assign to the Place
set_longitude(longitude)[source]

Set the longitude of the Place object.

Parameters:longitude (str) – longitude to assign to the Place
set_name(name)[source]

Set the name of the Place object.

Parameters:title (str) – name to assign to the Place
set_placeref_list(placeref_list)[source]

Set the place reference list for the Place object.

Parameters:code (list) – place reference list to assign to the Place
set_title(title)[source]

Set the descriptive title of the Place object.

Parameters:title (str) – descriptive title to assign to the Place
set_type(place_type)[source]

Set the type of the Place object.

Parameters:type (PlaceType) – type to assign to the Place
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a Place object.

Parameters:data (tuple) – tuple containing the persistent data associated with the Place object

Source

Source object for Gramps.

class gramps.gen.lib.src.Source[source]

Bases: gramps.gen.lib.mediabase.MediaBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.attrbase.SrcAttributeBase, gramps.gen.lib.citationbase.IndirectCitationBase, gramps.gen.lib.primaryobj.PrimaryObject

A record of a source of information.

add_repo_reference(repo_ref)[source]

Add a RepoRef instance to the Source’s reporef list.

Parameters:repo_ref (RepoRef) – RepoRef instance to be added to the object’s reporef list.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_abbreviation()[source]

Return the title abbreviation of the Source.

get_author()[source]

Return the author of the Source.

get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_publication_info()[source]

Return the publication information of the Source.

get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_reporef_list()[source]

Return the list of RepoRef instances associated with the Source.

Returns:list of RepoRef instances associated with the Source
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_title()[source]

Return the descriptive title of the Place object.

Returns:Returns the descriptive title of the Place
Return type:str
has_repo_reference(repo_handle)[source]

Return True if the Source has reference to this Repository handle.

Parameters:repo_handle (str) – The Repository handle to be checked.
Returns:Returns whether the Source has reference to this Repository handle.
Return type:bool
merge(acquisition)[source]

Merge the content of acquisition into this source.

Parameters:acquisition (Source) – The source to merge with the present source.
remove_repo_references(repo_handle_list)[source]

Remove references to all Repository handles in the list.

Parameters:repo_handle_list (list) – The list of Repository handles to be removed.
replace_repo_references(old_handle, new_handle)[source]

Replace all references to old Repository handle with the new handle and merge equivalent entries.

Parameters:
  • old_handle (str) – The Repository handle to be replaced.
  • new_handle (str) – The Repository handle to replace the old one with.
serialize()[source]

Convert the object to a serialized tuple of data.

set_abbreviation(abbrev)[source]

Set the title abbreviation of the Source.

set_author(author)[source]

Set the author of the Source.

set_publication_info(text)[source]

Set the publication information of the Source.

set_reporef_list(reporef_list)[source]

Set the list of RepoRef instances associated with the Source. It replaces the previous list.

Parameters:reporef_list (list) – list of RepoRef instances to be assigned to the Source.
set_title(title)[source]

Set the descriptive title of the Source object.

Parameters:title (str) – descriptive title to assign to the Source
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a Source structure.

Citation

Citation object for Gramps.

class gramps.gen.lib.citation.Citation[source]

Bases: gramps.gen.lib.mediabase.MediaBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.attrbase.SrcAttributeBase, gramps.gen.lib.citationbase.IndirectCitationBase, gramps.gen.lib.datebase.DateBase, gramps.gen.lib.primaryobj.PrimaryObject

A record of a citation of a source of information.

In GEDCOM this is called a SOURCE_CITATION. The data provided in the <<SOURCE_CITATION>> structure is source-related information specific to the data being cited.

CONF_HIGH = 3
CONF_LOW = 1
CONF_NORMAL = 2
CONF_VERY_HIGH = 4
CONF_VERY_LOW = 0
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_confidence_level()[source]

Return the confidence level.

get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_page()[source]

Get the page indicator of the Citation.

get_reference_handle()[source]
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
merge(acquisition)[source]

Merge the content of acquisition into this citation.

Parameters:acquisition (Citation) – The citation to merge with the present citation.
serialize(no_text_date=False)[source]

Convert the object to a serialized tuple of data.

set_confidence_level(val)[source]

Set the confidence level.

set_page(page)[source]

Set the page indicator of the Citation.

set_reference_handle(val)[source]
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a Citation structure.

Media Object

Media object for Gramps.

class gramps.gen.lib.mediaobj.MediaObject(source=None)[source]

Bases: gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.datebase.DateBase, gramps.gen.lib.attrbase.AttributeBase, gramps.gen.lib.primaryobj.PrimaryObject

Container for information about an image file, including location, description and privacy.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_checksum()[source]

Return the checksum of the image.

get_citation_child_list()[source]

Return the list of child secondary objects that may refer to citations.

Returns:Returns the list of child secondary child objects that may refer to citations.
Return type:list
get_description()[source]

Return the description of the image.

get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_mime_type()[source]

Return the MIME type associated with the MediaObject.

Returns:Returns the associated MIME type
Return type:str
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_path()[source]

Return the file path.

get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
merge(acquisition)[source]

Merge the content of acquisition into this media object.

Lost: handle, id, file, date of acquisition.

Parameters:acquisition (MediaObject) – The media object to merge with the present object.
serialize(no_text_date=False)[source]

Convert the data held in the event to a Python tuple 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.

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.

Returns:Returns a python tuple containing the data that should be considered persistent.
Return type:tuple
set_checksum(text)[source]

Set the checksum of the image.

set_description(text)[source]

Set the description of the image.

set_mime_type(mime_type)[source]

Set the MIME type associated with the MediaObject.

Parameters:mime_type (str) – MIME type to be assigned to the object
set_path(path)[source]

Set the file path to the passed path.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a MediaObject structure.

Parameters:data (tuple) – tuple containing the persistent data associated the object

Repository

Repository object for Gramps.

class gramps.gen.lib.repo.Repository[source]

Bases: gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.addressbase.AddressBase, gramps.gen.lib.urlbase.UrlBase, gramps.gen.lib.citationbase.IndirectCitationBase, gramps.gen.lib.primaryobj.PrimaryObject

A location where collections of Sources are found.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_name()[source]
Returns:the descriptive name of the Repository
Return type:str
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_type()[source]
Returns:the descriptive type of the Repository
Return type:str
merge(acquisition)[source]

Merge the content of acquisition into this repository.

Parameters:acquisition (Repository) – The repository to merge with the present repository.
serialize()[source]

Convert the object to a serialized tuple of data.

set_name(name)[source]
Parameters:name (str) – descriptive name of the Repository
set_type(the_type)[source]
Parameters:the_type (str) – descriptive type of the Repository
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a Repository structure.

Note

Note class for Gramps.

class gramps.gen.lib.note.Note(text='')[source]

Bases: gramps.gen.lib.primaryobj.BasicPrimaryObject

Define a text note.

Starting from Gramps 3.1 Note object stores the text in StyledText instance, thus it can have text formatting information.

To get and set only the clear text of the note use the get() and set() methods.

To get and set the formatted version of the Note’s text use the get_styledtext() and set_styledtext() methods.

The note may be ‘preformatted’ or ‘flowed’, which indicates that the text string is considered to be in paragraphs, separated by newlines.

Variables:
  • FLOWED – indicates flowed format
  • FORMATTED – indicates formatted format (respecting whitespace needed)
  • POS_<x> – (int) Position of <x> attribute in the serialized format of an instance.

Warning

The POS_<x> class variables reflect the serialized object, they have to be updated in case the data structure or the serialize() method changes!

FLOWED = 0
FORMATTED = 1
POS_CHANGE = 5
POS_FORMAT = 3
POS_HANDLE = 0
POS_ID = 1
POS_PRIVATE = 7
POS_TAGS = 6
POS_TEXT = 2
POS_TYPE = 4
append(text)[source]

Append the specified text to the text associated with the note.

Parameters:text (str or StyledText) – Text string to be appended to the note.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get()[source]

Return the text string associated with the note.

Returns:The clear text of the note contents.
Return type:unicode
get_format()[source]

Return the format of the note.

The value can either indicate Flowed or Preformatted.

Returns:0 indicates Flowed, 1 indicates Preformated
Return type:int

Get the jump links from this note. Links can be external, to urls, or can be internal to gramps objects.

Return examples:

[("gramps", "Person", "handle", "7657626365362536"),
 ("external", "www", "url", "http://example.com")]
Returns:list of [(domain, type, propery, value), ...]
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_styledtext()[source]

Return the text string associated with the note.

Returns:The formatted text of the note contents.
Return type:StyledText
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:The list of all textual attributes of the object.
Return type:list
get_type()[source]

Get descriptive type of the Note.

Returns:the descriptive type of the Note
Return type:str
merge(acquisition)[source]

Merge the content of acquisition into this note.

Lost: handle, id, type, format, text and styles of acquisition.

Parameters:acquisition (Note) – The note to merge with the present note.
serialize()[source]

Convert the object to a serialized tuple of data.

Returns:The serialized format of the instance.
Return type:tuple
set(text)[source]

Set the text associated with the note to the passed string.

Parameters:text (str) – The clear text defining the note contents.
set_format(format)[source]

Set the format of the note to the passed value.

Parameters:format (int) – The value can either indicate Flowed or Preformatted.
set_styledtext(text)[source]

Set the text associated with the note to the passed string.

Parameters:text (StyledText) – The formatted text defining the note contents.
set_type(the_type)[source]

Set descriptive type of the Note.

Parameters:the_type (str) – descriptive type of the Note
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Parameters:data – The serialized format of a Note.
Type:data: tuple

Secondary objects

Secondary Object

Secondary Object class for Gramps.

class gramps.gen.lib.secondaryobj.SecondaryObject[source]

Bases: gramps.gen.lib.baseobj.BaseObject

The SecondaryObject is the base class for all secondary objects in the database.

is_equal(source)[source]
is_equivalent(other)[source]

Return if this object is equivalent to other.

Should be overwritten by objects that inherit from this class.

Address

Address class for Gramps.

class gramps.gen.lib.address.Address(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.datebase.DateBase, gramps.gen.lib.locationbase.LocationBase

Provide address information.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_equivalent(other)[source]

Return if this address is equivalent, that is agrees in location and date, to other.

Parameters:other (Address) – The address to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this address.

Lost: date, street, city, county, state, country, postal and phone of acquisition.

Parameters:acquisition (Address) – The address to merge with the present address.
serialize()[source]

Convert the object to a serialized tuple of data.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Attribute

Attribute class for Gramps.

class gramps.gen.lib.attribute.Attribute(source=None)[source]

Bases: gramps.gen.lib.attribute.AttributeRoot, gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
merge(acquisition)[source]

Merge the content of acquisition into this attribute.

Lost: type and value of acquisition.

Parameters:acquisition (Attribute) – the attribute to merge with the present attribute.
serialize()[source]

Convert the object to a serialized tuple of data.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

AttributeRoot

class gramps.gen.lib.attribute.AttributeRoot(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase

Provide a simple key/value pair for describing properties. Used to store descriptive information.

In GEDCOM only used for Persons: Individual attributes should describe situations that may be permanent or temporary (start at some date, end at some date, etc.), may be associated to a place (a position held, residence, etc.) or may not (eye colour, height, caste, profession, etc.). They may have sources and notes and media. Compare with Event

Gramps at the moment does not support this GEDCOM Attribute structure.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_type()[source]

Return the type (or key) or the Attribute instance.

get_value()[source]

Return the value of the Attribute instance.

is_equivalent(other)[source]

Return if this attribute is equivalent, that is agrees in type and value, to other.

Parameters:other (Attribute) – The attribute to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this attribute.

Lost: type and value of acquisition.

Parameters:acquisition (Attribute) – the attribute to merge with the present attribute.
serialize()[source]

Convert the object to a serialized tuple of data.

set_type(val)[source]

Set the type (or key) of the Attribute instance.

set_value(val)[source]

Set the value of the Attribute instance.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

LdsOrd

LDS Ordinance class for Gramps.

class gramps.gen.lib.ldsord.LdsOrd(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.datebase.DateBase, gramps.gen.lib.placebase.PlaceBase, gramps.gen.lib.privacybase.PrivacyBase

Class that contains information about LDS Ordinances.

LDS ordinances are similar to events, but have very specific additional information related to data collected by the Church of Jesus Christ of Latter Day Saints (Mormon church). The LDS church is the largest source of genealogical information in the United States.

BAPTISM = 0
CONFIRMATION = 4
DEFAULT_STATUS = 0
DEFAULT_TYPE = 0
ENDOWMENT = 1
SEAL_TO_PARENTS = 2
SEAL_TO_SPOUSE = 3
STATUS_BIC = 1
STATUS_CANCELED = 2
STATUS_CHILD = 3
STATUS_CLEARED = 4
STATUS_COMPLETED = 5
STATUS_DNS = 6
STATUS_DNS_CAN = 10
STATUS_INFANT = 7
STATUS_NONE = 0
STATUS_PRE_1970 = 8
STATUS_QUALIFIED = 9
STATUS_STILLBORN = 11
STATUS_SUBMITTED = 12
STATUS_UNCLEARED = 13
are_equal(other)[source]

Return 1 if the specified ordinance is the same as the instance.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_family_handle()[source]

Get the Family database handle associated with the LDS ordinance.

get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_status()[source]

Get the status of the LDS ordinance.

get_temple()[source]

Get the temple associated with the ordinance.

get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_type()[source]

Return the type of the Event.

Returns:Type of the Event
Return type:tuple
is_empty()[source]

Return 1 if the ordinance is actually empty.

is_equivalent(other)[source]

Return if this ldsord is equivalent, that is agrees in date, temple, place, status, sealed_to, to other.

Parameters:other (LdsOrd) – The ldsord to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this ldsord.

Lost: type, date, temple, place, status, sealed_to of acquistion.

Parameters:acquisition (LdsOrd) – The ldsord to merge with the present ldsord.
serialize()[source]

Convert the object to a serialized tuple of data.

set_family_handle(family)[source]

Set the Family database handle associated with the LDS ordinance.

set_status(val)[source]

Set the status of the LDS ordinance.

The status is a text string that matches a predefined set of strings.

set_status_from_xml(xml_str)[source]

Set status based on a given string from XML.

Return boolean on success.

set_temple(temple)[source]

Set the temple associated with the ordinance.

set_type(ord_type)[source]

Set the type of the LdsOrd to the passed (int,str) tuple.

Parameters:ord_type (tuple) – Type to assign to the LdsOrd
set_type_from_xml(xml_str)[source]

Set type based on a given string from XML.

Return boolean on success.

status2str()[source]

Return status-representing string suitable for UI (translated).

status2xml()[source]

Return status-representing string suitable for XML.

to_struct()[source]

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.
Return type:dict
type2str()[source]

Return type-representing string suitable for UI (translated).

type2xml()[source]

Return type-representing string suitable for XML.

unserialize(data)[source]

Convert a serialized tuple of data to an object.

Location

Location class for Gramps.

class gramps.gen.lib.location.Location(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.locationbase.LocationBase

Provide information about a place.

The data including street, locality, city, county, state, and country. Multiple Location objects can represent the same place, since names of cities, counties, states, and even countries can change with time.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_parish()[source]

Get the religious parish name.

get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_empty()[source]
is_equivalent(other)[source]

Return if this location is equivalent to other.

Parameters:other (Location) – The location to compare this one to.
Returns:Constant inidicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this location.

Lost: everything of acquisition.

Parameters:acquisition (Location) – The location to merge with the present location.
serialize()[source]

Convert the object to a serialized tuple of data.

set_parish(data)[source]

Set the religious parish name.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Name

Name class for Gramps.

class gramps.gen.lib.name.Name(source=None, data=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.surnamebase.SurnameBase, gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.datebase.DateBase

Provide name information about a person.

A person may have more that one name throughout his or her life. The Name object stores one of them

DEF = 0
FN = 4
FNLN = 2
LNFN = 1
LNFNP = 5
NAMEFORMATS = (0, 1, 2, 4, 5)
PTFN = 3
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_call_name()[source]

Return the call name.

The call name’s exact definition is not predetermined, and may be locale specific.

get_display_as()[source]

Return the selected display format for the name.

The options are LNFN (last name, first name), FNLN (first name, last name), etc.

get_family_nick_name()[source]

Return the family nick name.

The family nick name of the family of the person, a not official name use to denote the entire family.

get_first_name()[source]

Return the given name for the Name instance.

get_gedcom_name()[source]

Returns a GEDCOM-formatted name.

get_gedcom_parts()[source]

Returns a GEDCOM-formatted name dictionary.

Note

Fields patronymic and prefix are deprecated, prefix_list and surname list, added.

get_group_as()[source]

Return the grouping name, which is used to group equivalent surnames.

get_group_name()[source]

Return the grouping name, which is used to group equivalent surnames.

get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_name()[source]

Return a name string built from the components of the Name instance, in the form of: surname, Firstname.

get_nick_name()[source]

Return the nick name.

The nick name of the person, a not official name the person is known with.

get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_regular_name()[source]

Return a name string built from the components of the Name instance, in the form of Firstname surname.

get_sort_as()[source]

Return the selected sorting method for the name.

The options are LNFN (last name, first name), FNLN (first name, last name), etc.

get_suffix()[source]

Return the suffix for the Name instance.

get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_title()[source]

Return the title for the Name instance.

get_type()[source]

Return the type of the Name instance.

get_upper_name()[source]

Return a name string built from the components of the Name instance, in the form of SURNAME, Firstname.

is_empty()[source]

Indicate if the name is empty.

is_equivalent(other)[source]

Return if this name is equivalent, that is agrees in type, first, call, surname_list, suffix, title and date, to other.

Parameters:other (Name) – The name to compare this name to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this name. Normally the person merge code should opt for adding an alternate name if names are actually different (like not equal surname list)

Lost: type, first, call, suffix, title, nick, famnick and date of acquisition.

Parameters:acquisition (Name) – The name to merge with the present name.
serialize()[source]

Convert the object to a serialized tuple of data.

set_call_name(val)[source]

Set the call name.

The call name’s exact definition is not predetermined, and may be locale specific.

set_display_as(value)[source]

Specifies the display format for the specified name.

Typically the locale’s default should be used. However, there may be names where a specific display format is desired for a name.

set_family_nick_name(val)[source]

Set the family nick name.

The family nick name of the family of the person, a not official name use to denote the entire family.

set_first_name(name)[source]

Set the given name for the Name instance.

set_group_as(name)[source]

Set the grouping name for a person.

Normally, this is the person’s surname. However, some locales group equivalent names (e.g. Ivanova and Ivanov in Russian are usually considered equivalent.

Note

There is also a database wide grouping set_name_group_mapping So one might map a name Smith to SmithNew, and have one person still grouped with name Smith. Hence, group_as can be equal to surname!

set_nick_name(val)[source]

Set the nick name.

The nick name of the person, a not official name the person is known with.

set_sort_as(value)[source]

Specifies the sorting method for the specified name.

Typically the locale’s default should be used. However, there may be names where a specific sorting structure is desired for a name.

set_suffix(name)[source]

Set the suffix (such as Jr., III, etc.) for the Name instance.

set_title(title)[source]

Set the title (Dr., Reverand, Captain) for the Name instance.

set_type(the_type)[source]

Set the type of the Name instance.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Surname

Surname class for Gramps.

class gramps.gen.lib.surname.Surname(source=None, data=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject

Provide surname information of a name.

A person may have more that one surname in his name

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_connector()[source]

Get the connector for the Surname instance. This defines how a surname connects to the next surname (eg in Spanish names).

get_origintype()[source]

Return the origin type of the Surname instance.

get_prefix()[source]

Return the prefix (or article) of the surname.

The prefix is not used for sorting or grouping.

get_primary()[source]

Return if this surname is the primary surname

get_surname()[source]

Return the surname.

The surname is one of the not given names coming from the parents

get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_empty()[source]

Indicate if the surname is empty.

is_equivalent(other)[source]

Return if this surname is equivalent, that is agrees in type, surname, ..., to other.

Parameters:other (Surname) – The surname to compare this name to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this surname.

Lost: primary, surname, prefix, connector, origintype

Parameters:acquisition (Surname) – The surname to merge with the present surname.
serialize()[source]

Convert the object to a serialized tuple of data.

set_connector(connector)[source]

Set the connector for the Surname instance. This defines how a surname connects to the next surname (eg in Spanish names).

set_origintype(the_type)[source]

Set the origin type of the Surname instance.

set_prefix(val)[source]

Set the prefix (or article) of the surname.

Examples of articles would be ‘de’ or ‘van’.

set_primary(primary=True)[source]

Set if this surname is the primary surname.replace Use SurnameBase to set the primary surname via set_primary_surname()

Parameters:primary (bool) – primay surname or not
set_surname(val)[source]

Set the surname.

The surname is one of the not given names coming from the parents

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Url

Url class for Gramps.

class gramps.gen.lib.url.Url(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase

Contains information related to internet Uniform Resource Locators, allowing gramps to store information about internet resources.

are_equal(other)[source]

Deprecated - use is_equal() instead.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_description()[source]

Return the description of the URL.

get_full_path()[source]

Returns a full url, complete with scheme, even if missing from path.

get_path()[source]

Return the URL path.

get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
get_type()[source]
Returns:the descriptive type of the Url
Return type:str
is_equivalent(other)[source]

Return if this url is equivalent, that is agrees in type, full path name and description, to other.

Parameters:other (Url) – The url to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this url.

Parameters:acquisition (Url) – The url to merge with the present url.
parse_path()[source]

Returns a 6 tuple-based object with the following items:

Property Pos Meaning
scheme 0 URL scheme specifier
netloc 1 Network location part
path 2 Hierarchical path
params 3 Parameters for last path element
query 4 Query component
fragment 5 Fragment identifier
serialize()[source]
set_description(description)[source]

Set the description of the URL.

set_path(path)[source]

Set the URL path.

set_type(the_type)[source]
Parameters:the_type (str) – descriptive type of the Url
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Reference objects

ChildRef

Child Reference class for Gramps.

class gramps.gen.lib.childref.ChildRef(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.refbase.RefBase

Person reference class.

This class is for keeping information about how the person relates to another person from the database, if not through family. Examples would be: godparent, friend, etc.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_father_relation()[source]

Return the relation between the person and father.

get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects..

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_mother_relation()[source]

Return the relation between the person and mother.

get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_equivalent(other)[source]

Return if this child reference is equivalent, that is agrees in hlink, to other.

Parameters:other (ChildRef) – The childref to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this child reference.

Lost: hlink, mrel and frel of acquisition.

Parameters:acquisition (ChildRef) – The childref to merge with the present childref.
serialize()[source]

Convert the object to a serialized tuple of data.

set_father_relation(frel)[source]

Set relation between the person and father.

set_mother_relation(rel)[source]

Set relation between the person and mother.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

EventRef

Event Reference class for Gramps

class gramps.gen.lib.eventref.EventRef(source=None)[source]

Bases: gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.attrbase.AttributeBase, gramps.gen.lib.refbase.RefBase, gramps.gen.lib.citationbase.IndirectCitationBase, gramps.gen.lib.secondaryobj.SecondaryObject

Event reference class.

This class is for keeping information about how the person relates to the referenced event.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects..

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:Returns the list of (classname, handle) tuples for referenced objects.
Return type:list
get_role()[source]

Return the tuple corresponding to the preset role.

get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_equivalent(other)[source]

Return if this eventref is equivalent, that is agrees in handle and role, to other.

Parameters:other (EventRef) – The eventref to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this eventref.

Lost: hlink and role of acquisition.

Parameters:acquisition (EventRef) – The eventref to merge with the present eventref.
role

Returns or sets role property

serialize()[source]

Convert the object to a serialized tuple of data.

set_role(role)[source]

Set the role according to the given argument.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

MediaRef

Media Reference class for Gramps.

class gramps.gen.lib.mediaref.MediaRef(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.refbase.RefBase, gramps.gen.lib.attrbase.AttributeBase

Media reference class.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_citation_child_list()[source]

Return the list of child secondary objects that may refer Citations.

Returns:Returns the list of child secondary child objects that may refer Citations.
Return type:list
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects.

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_rectangle()[source]

Return the subsection of an image.

get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
is_equivalent(other)[source]

Return if this object reference is equivalent, that is agrees in reference and region, to other.

Parameters:other (MediaRef) – The object reference to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this object reference.

Lost: hlink and region or acquisition.

Parameters:acquisition (MediaRef) – The object reference to merge with the present one.
serialize()[source]

Convert the object to a serialized tuple of data.

set_rectangle(coord)[source]

Set subsection of an image.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

PersonRef

Person Reference class for Gramps.

class gramps.gen.lib.personref.PersonRef(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.citationbase.CitationBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.refbase.RefBase

Person reference class.

This class is for keeping information about how the person relates to another person from the database, if not through family. Examples would be: godparent, friend, etc.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects..

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_relation()[source]

Return the relation to a person.

get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_equivalent(other)[source]

Return if this person reference is equivalent, that is agrees in handle and relation, to other.

Parameters:other (PersonRef) – The personref to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this person reference.

Lost: hlink and relation of acquisition.

Parameters:acquisition (PersonRef) – The personref to merge with the present personref.
serialize()[source]

Convert the object to a serialized tuple of data.

set_relation(rel)[source]

Set relation to a person.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

PlaceRef

Place Reference class for Gramps

class gramps.gen.lib.placeref.PlaceRef(source=None)[source]

Bases: gramps.gen.lib.refbase.RefBase, gramps.gen.lib.datebase.DateBase, gramps.gen.lib.secondaryobj.SecondaryObject

Place reference class.

This class is for keeping information about how places link to other places in the place hierarchy.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_citation_child_list()[source]

Return the list of child secondary objects that may refer citations.

Returns:Returns the list of child secondary child objects that may refer citations.
Return type:list
get_handle_referents()[source]

Return the list of child objects which may, directly or through their children, reference primary objects..

Returns:Returns the list of objects referencing primary objects.
Return type:list
get_note_child_list()[source]

Return the list of child secondary objects that may refer notes.

Returns:Returns the list of child secondary child objects that may refer notes.
Return type:list
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:Returns the list of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_child_list()[source]

Return the list of child objects that may carry textual data.

Returns:Returns the list of child objects that may carry textual data.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_equivalent(other)[source]

Return if this eventref is equivalent, that is agrees in handle and role, to other.

Parameters:other (PlaceRef) – The eventref to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
serialize()[source]

Convert the object to a serialized tuple of data.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

RepoRef

Repository Reference class for Gramps

class gramps.gen.lib.reporef.RepoRef(source=None)[source]

Bases: gramps.gen.lib.secondaryobj.SecondaryObject, gramps.gen.lib.privacybase.PrivacyBase, gramps.gen.lib.notebase.NoteBase, gramps.gen.lib.refbase.RefBase

Repository reference class.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_call_number()[source]
get_media_type()[source]
get_referenced_handles()[source]

Return the list of (classname, handle) tuples for all directly referenced primary objects.

Returns:List of (classname, handle) tuples for referenced objects.
Return type:list
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_equivalent(other)[source]

Return if this repository reference is equivalent, that is agrees in reference, call number and medium, to other.

Parameters:other (RepoRef) – The repository reference to compare this one to.
Returns:Constant indicating degree of equivalence.
Return type:int
merge(acquisition)[source]

Merge the content of acquisition into this repository reference.

Parameters:acquisition (RepoRef) – The repository reference to merge with the present repository reference.
serialize()[source]

Convert the object to a serialized tuple of data.

set_call_number(number)[source]
set_media_type(media_type)[source]
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Table objects

Table object

Table Object class for Gramps.

class gramps.gen.lib.tableobj.TableObject(source=None)[source]

Bases: gramps.gen.lib.baseobj.BaseObject

The TableObject is the base class for all objects that are stored in a seperate database table. Each object has a database handle and a last changed time. The database handle is used as the unique key for a record in the database. This is not the same as the Gramps ID, which is a user visible identifier for a record.

It is the base class for the BasicPrimaryObject class and Tag class.

get_change_display()[source]

Return the string representation of the last change time.

Returns:string representation of the last change time.
Return type:str
get_change_time()[source]

Return the time that the data was last changed.

The value in the format returned by the time.time() command.

Returns:Time that the data was last changed. The value in the format returned by the time.time() command.
Return type:int
get_handle()[source]

Return the database handle for the primary object.

Returns:database handle associated with the object
Return type:str
set_change_time(change)[source]

Modify the time that the data was last changed.

The value must be in the format returned by the time.time() command.

Parameters:change (int in format as time.time() command) – new time
set_handle(handle)[source]

Set the database handle for the primary object.

Parameters:handle (str) – object database handle

Tag

Tag object for Gramps.

class gramps.gen.lib.tag.Tag(source=None)[source]

Bases: gramps.gen.lib.tableobj.TableObject

The Tag record is used to store information about a tag that can be attached to a primary object.

are_equal(other)[source]

Return True if the passed Tag is equivalent to the current Tag.

Parameters:other (Tag) – Tag to compare against
Returns:True if the Tags are equal
Return type:bool
color

Returns or sets color of the tag

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_color()[source]

Return the color of the Tag.

Returns:Returns the color of the Tag
Return type:str
get_name()[source]

Return the name of the Tag.

Returns:Name of the Tag
Return type:str
get_priority()[source]

Return the priority of the Tag.

Returns:Returns the priority of the Tag
Return type:int
get_text_data_list()[source]

Return the list of all textual attributes of the object.

Returns:Returns the list of all textual attributes of the object.
Return type:list
is_empty()[source]

Return True if the Tag is an empty object (no values set).

Returns:True if the Tag is empty
Return type:bool
name

Returns or sets name of the tag

priority

Returns or sets priority of the tag

serialize()[source]

Convert the data held in the event to a Python tuple 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.

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.

Returns:Returns a python tuple containing the data that should be considered persistent.
Return type:tuple
set_color(color)[source]

Set the color of the Tag to the passed string.

The string is of the format #rrrrggggbbbb.

Parameters:color (str) – Color to assign to the Tag
set_name(name)[source]

Set the name of the Tag to the passed string.

Parameters:name (str) – Name to assign to the Tag
set_priority(priority)[source]

Set the priority of the Tag to the passed integer.

The lower the value the higher the priority.

Parameters:priority (int) – Priority to assign to the Tag
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert the data held in a tuple created by the serialize method back into the data in a Tag structure.

Parameters:data (tuple) – tuple containing the persistent data associated with the object

Date objects

Support for dates.

Date

class gramps.gen.lib.date.Date(*source)[source]

Bases: object

The core date handling class for Gramps.

Supports partial dates, compound dates and alternate calendars.

CALENDARS = [0, 1, 2, 3, 4, 5, 6]
CAL_FRENCH = 3
CAL_GREGORIAN = 0
CAL_HEBREW = 2
CAL_ISLAMIC = 5
CAL_JULIAN = 1
CAL_PERSIAN = 4
CAL_SWEDISH = 6
EMPTY = (0, 0, 0, False)
MOD_ABOUT = 3
MOD_AFTER = 2
MOD_BEFORE = 1
MOD_NONE = 0
MOD_RANGE = 4
MOD_SPAN = 5
MOD_TEXTONLY = 6
NEWYEAR_JAN1 = 0
NEWYEAR_MAR1 = 1
NEWYEAR_MAR25 = 2
NEWYEAR_SEP1 = 3
QUAL_CALCULATED = 2
QUAL_ESTIMATED = 1
QUAL_NONE = 0
calendar_names = [u'Gregorian', u'Julian', u'Hebrew', u'French Republican', u'Persian', u'Islamic', u'Swedish']
convert_calendar(calendar, known_valid=True)[source]

Convert the date from the current calendar to the specified calendar.

copy(source)[source]

Copy all the attributes of the given Date instance to the present instance, without creating a new object.

copy_offset_ymd(year=0, month=0, day=0)[source]

Return a Date copy based on year, month, and day offset.

copy_ymd(year=0, month=0, day=0, remove_stop_date=None)[source]

Return a Date copy with year, month, and day set.

Parameters:remove_stop_date – Same as in set_yr_mon_day.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_calendar()[source]

Return an integer indicating the calendar selected.

The valid values are:

CAL_GREGORIAN Gregorian calendar
CAL_JULIAN Julian calendar
CAL_HEBREW Hebrew (Jewish) calendar
CAL_FRENCH French Republican calendar
CAL_PERSIAN Persian calendar
CAL_ISLAMIC Islamic calendar
CAL_SWEDISH Swedish calendar 1700-03-01 -> 1712-02-30!
get_day()[source]

Return the day of the month associated with the date.

If the day is not defined, a zero is returned. If the date is a compound date, the lower date day is returned.

get_day_valid()[source]

Return true if the day is valid.

get_dmy(get_slash=False)[source]

Return (day, month, year, [slash]).

get_dow()[source]

Return an integer representing the day of the week associated with the date (Monday=0).

If the day is not defined, a None is returned. If the date is a compound date, the lower date day is returned.

get_high_year()[source]

Return the high year estimate.

For compound dates with non-zero stop year, the stop year is returned. Otherwise, the start year is returned.

get_modifier()[source]

Return an integer indicating the calendar selected.

The valid values are:

MOD_NONE no modifier (default)
MOD_BEFORE before
MOD_AFTER after
MOD_ABOUT about
MOD_RANGE date range
MOD_SPAN date span
MOD_TEXTONLY text only
get_month()[source]

Return the month associated with the date.

If the month is not defined, a zero is returned. If the date is a compound date, the lower date month is returned.

get_month_valid()[source]

Return true if the month is valid

get_new_year()[source]

Return the new year code associated with the date.

get_quality()[source]

Return an integer indicating the calendar selected.

The valid values are:

QUAL_NONE normal (default)
QUAL_ESTIMATED estimated
QUAL_CALCULATED calculated
get_slash()[source]

Return true if the date is a slash-date (dual dated).

get_slash2()[source]

Return true if the ending date is a slash-date (dual dated).

get_sort_value()[source]

Return the sort value of Date object.

If the value is a text string, 0 is returned. Otherwise, the calculated sort date is returned. The sort date is rebuilt on every assignment.

The sort value is an integer representing the value. The sortval is the integer number of days that have elapsed since Monday, January 1, 4713 BC in the proleptic Julian calendar.

get_start_date()[source]

Return a tuple representing the start date.

If the date is a compound date (range or a span), it is the first part of the compound date. If the date is a text string, a tuple of (0, 0, 0, False) is returned. Otherwise, a date of (DD, MM, YY, slash) is returned. If slash is True, then the date is in the form of 1530/1.

get_start_stop_range()[source]

Return the minimal start_date, and a maximal stop_date corresponding to this date, given in Gregorian calendar.

Useful in doing range overlap comparisons between different dates.

Note that we stay in (YR,MON,DAY)

get_stop_date()[source]

Return a tuple representing the second half of a compound date.

If the date is not a compound date, (including text strings) a tuple of (0, 0, 0, False) is returned. Otherwise, a date of (DD, MM, YY, slash) is returned. If slash is True, then the date is in the form of 1530/1.

get_stop_day()[source]

Return the day of the month associated with the second part of a compound date.

If the day is not defined, a zero is returned.

get_stop_month()[source]

Return the month of the month associated with the second part of a compound date.

If the month is not defined, a zero is returned.

get_stop_year()[source]

Return the day of the year associated with the second part of a compound date.

If the year is not defined, a zero is returned.

get_stop_ymd()[source]

Return (year, month, day) of the stop date, or all-zeros if it’s not defined.

get_text()[source]

Return the text value associated with an invalid date.

get_valid()[source]

Return true if any part of the date is valid.

get_year()[source]

Return the year associated with the date.

If the year is not defined, a zero is returned. If the date is a compound date, the lower date year is returned.

get_year_calendar(calendar_name=None)[source]

Return the year of this date in the calendar name given.

Defaults to self’s calendar if one is not given.

>>> Date(2009, 12, 8).to_calendar("hebrew").get_year_calendar()
5770
get_year_valid()[source]

Return true if the year is valid.

get_ymd()[source]

Return (year, month, day).

is_compound()[source]

Return True if the date is a date range or a date span.

is_empty()[source]

Return True if the date contains no information (empty text).

is_equal(other)[source]

Return 1 if the given Date instance is the same as the present instance IN ALL REGARDS.

Needed, because the __cmp__ only looks at the sorting value, and ignores the modifiers/comments.

is_full()[source]

Return True if the date is fully specified.

is_regular()[source]

Return True if the date is a regular date.

The regular date is a single exact date, i.e. not text-only, not a range or a span, not estimated/calculated, not about/before/after date, and having year, month, and day all non-zero.

is_valid()[source]

Return true if any part of the date is valid.

lookup_calendar(calendar)[source]

Lookup calendar name in the list of known calendars, even if translated.

lookup_modifier(modifier)[source]

Lookup date modifier keyword, even if translated.

lookup_quality(quality)[source]

Lookup date quality keyword, even if translated.

make_vague()[source]

Remove month and day details to make the date approximate.

match(other_date, comparison=u'=')[source]

Compare two dates using sophisticated techniques looking for any match between two possible dates, date spans and qualities.

The other comparisons for Date (is_equal() and __cmp() don’t actually look for anything other than a straight match, or a simple comparison of the sortval.

Comparison Returns
=,== True if any part of other_date matches any part of self
< True if any part of other_date < any part of self
<< True if all parts of other_date < all parts of self
> True if any part of other_date > any part of self
>> True if all parts of other_date > all parts of self
static newyear_to_code(string)[source]
Return newyear code of string, where string is:
‘’, ‘Jan1’, ‘Mar1’, ‘3-25’, ‘9-1’, etc.
newyear_to_str()[source]

Return the string representation of the newyear.

offset(value)[source]

Return (year, month, day) of this date +- value.

offset_date(value)[source]

Return (year, month, day) of this date +- value.

recalc_sort_value()[source]

Recalculates the numerical sort value associated with the date and returns it. Public method.

serialize(no_text_date=False)[source]

Convert to a series of tuples for data storage.

set(quality=None, modifier=None, calendar=None, value=None, text=None, newyear=0)[source]

Set the date to the specified value.

Parameters:
  • quality – The date quality for the date (see get_quality() for more information). Defaults to the previous value for the date.
  • modified – The date modifier for the date (see get_modifier() for more information) Defaults to the previous value for the date.
  • calendar – The calendar associated with the date (see get_calendar() for more information). Defaults to the previous value for the date.
  • value – A tuple representing the date information. For a non-compound date, the format is (DD, MM, YY, slash) and for a compound date the tuple stores data as (DD, MM, YY, slash1, DD, MM, YY, slash2) Defaults to the previous value for the date.
  • text – A text string holding either the verbatim user input or a comment relating to the date. Defaults to the previous value for the date.
  • newyear – The newyear code, or tuple representing (month, day) of newyear day. Defaults to 0.

The sort value is recalculated.

set2_yr_mon_day(year, month, day)[source]

Set the year, month, and day values in the 2nd part of a compound date (range or span).

set2_yr_mon_day_offset(year=0, month=0, day=0)[source]

Set the year, month, and day values by offset in the 2nd part of a compound date (range or span).

set_as_text(text)[source]

Set the day to a text string, and assign the sort value to zero.

set_calendar(val)[source]

Set the calendar selected for the date.

set_modifier(val)[source]

Set the modifier for the date.

set_new_year(value)[source]

Set the new year code associated with the date.

set_quality(val)[source]

Set the quality selected for the date.

set_slash(value)[source]

Set to 1 if the date is a slash-date (dual dated).

set_slash2(value)[source]

Set to 1 if the ending date is a slash-date (dual dated).

set_text_value(text)[source]

Set the text string to a given text.

set_year(year)[source]

Set the year value.

set_yr_mon_day(year, month, day, remove_stop_date=None)[source]

Set the year, month, and day values.

Parameters:remove_stop_date – Required parameter for a compound date. When True, the stop date is changed to the same date as well. When False, the stop date is not changed.
set_yr_mon_day_offset(year=0, month=0, day=0)[source]

Offset the date by the given year, month, and day values.

to_calendar(calendar_name)[source]

Return a new Date object in the calendar calendar_name.

>>> Date(1591, 1, 1).to_calendar("julian")
1590-12-22 (Julian)
to_struct()[source]

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.
Return type:dict
ui_calendar_names = [u'Gregorian', u'Julian', u'Hebrew', u'French Republican', u'Persian', u'Islamic', u'Swedish']
unserialize(data)[source]

Load from the format created by serialize.

Span

class gramps.gen.lib.date.Span(date1, date2)[source]

Bases: object

Span is used to represent the difference between two dates for three main purposes: sorting, ranking, and describing.

sort = (base day count, offset) minmax = (min days, max days)

ABOUT = 50
AFTER = 50
ALIVE = 110
BEFORE = 50
as_age()[source]

Get Span as an age (will not return more than Span.ALIVE).

as_time()[source]

Get Span as a time (can be greater than Span.ALIVE).

format(precision=2, as_age=True)[source]

Force a string representation at a level of precision.

1 only most significant level (year, month, day)
2 only most two significant levels (year, month, day)
3 at most three items of signifance (year, month, day)
get_repr(as_age=False, dlocale=<gramps.gen.utils.grampslocale.GrampsLocale object at 0x2b07d2b06f10>)[source]

Get the representation as a time or age.

If dlocale is passed in (a GrampsLocale) then the translated value will be returned instead.

Parameters:dlocale (a GrampsLocale instance) – allow deferred translation of strings
is_valid()[source]
tuple()[source]

DateError

exception gramps.gen.lib.date.DateError(value='')

Error used to report Date errors

Might have a .date attribute holding an invalid Date object that triggered the error.

Text objects

StyledTextTag

Provide formatting tag definition for StyledText.

class gramps.gen.lib.styledtexttag.StyledTextTag(name=None, value=None, ranges=None)[source]

Bases: object

Hold formatting information for StyledText.

StyledTextTag is a container class, it’s attributes are directly accessed.

Variables:
  • name – Type (or name) of the tag instance. E.g. ‘bold’, etc.
  • value – Value of the tag. E.g. color hex string for font color, etc.
  • ranges – Pointer pairs into the string, where the tag applies.
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
serialize()[source]

Convert the object to a serialized tuple of data.

Returns:Serialized format of the instance.
Return type:tuple
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Parameters:data (tuple) – Serialized format of instance variables.

StyledText

Handling formatted (‘rich text’) strings

class gramps.gen.lib.styledtext.StyledText(text='', tags=None)[source]

Bases: object

Helper class to enable character based text formatting.

StyledText is a wrapper class binding the clear text string and it’s formatting tags together.

StyledText provides several string methods in order to manipulate formatted strings, such as join(), replace(), split(), and also supports the ‘+’ operation (__add__()).

To get the clear text of the StyledText use the built-in str() function. To get the list of formatting tags use the get_tags() method.

StyledText supports the creation of formatted texts too. This feature is intended to replace (or extend) the current report interface. To be continued... FIXME

Variables:
  • string – (str) The clear text part.
  • tags – (list of StyledTextTag) Text tags holding formatting information for the string.
  • POS_TEXT – Position of string attribute in the serialized format of an instance.
  • POS_TAGS – (int) Position of tags attribute in the serialized format of an instance.

Warning

The POS_<x> class variables reflect the serialized object, they have to be updated in case the data structure or the serialize() method changes!

Note

  1. There is no sanity check of tags in __init__(), because when a StyledText is displayed it is passed to a StyledTextBuffer, which in turn will ‘eat’ all invalid tags (including out-of-range tags too).
  2. After string methods the tags can become fragmented. That means the same tag may appear more than once in the tag list with different ranges. There could be a ‘merge_tags’ functionality in __init__(), however StyledTextBuffer will merge them automatically if the text is displayed.
POS_TAGS = 1
POS_TEXT = 0
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_string()[source]

Accessor for the associated string.

get_tags()[source]

Return the list of formatting tags.

Returns:The formatting tags applied on the text.
Return type:list of 0 or more StyledTextTag instances.
join(seq)[source]

Emulate __builtin__.str.join() method.

Parameters:seq (basestring or StyledText) – list of strings to join
Returns:joined strings
Return type:StyledText
replace(old, new, count=-1)[source]

Emulate __builtin__.str.replace() method.

Parameters:
  • old (basestring or StyledText) – substring to be replaced
  • new (StyledText) – substring to replace by
  • count (int) – if given, only the first count occurrences are replaced
Returns:

copy of the string with replaced substring(s)

Return type:

StyledText

Warning

by the correct implementation parameter new should be StyledText or basestring, however only StyledText is currently supported.

serialize()[source]

Convert the object to a serialized tuple of data.

Returns:Serialized format of the instance.
Return type:tuple
split(sep=None, maxsplit=-1)[source]

Emulate __builtin__.str.split() method.

Parameters:
  • sep – the delimiter string
  • maxsplit (int) – if given, at most maxsplit splits are done
Returns:

a list of the words in the string

Return type:

list of StyledText

string

Accessor for the associated string.

tags

Return the list of formatting tags.

Returns:The formatting tags applied on the text.
Return type:list of 0 or more StyledTextTag instances.
to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Parameters:data (tuple) – Serialized format of instance variables.

Meta data

GenderStats

Gender statistics kept in Gramps database.

class gramps.gen.lib.genderstats.GenderStats(stats={})[source]

Bases: object

Class for keeping track of statistics related to Given Name vs. Gender.

This allows the tracking of the liklihood of a person’s given name indicating the gender of the person.

clear_stats()[source]
count_name(name, gender)[source]

Count a given name under gender in the gender stats.

count_person(person, undo=0)[source]
guess_gender(name)[source]
name_stats(name)[source]
save_stats()[source]
uncount_person(person)[source]

Researcher

Researcher information for Gramps.

class gramps.gen.lib.researcher.Researcher(source=None)[source]

Bases: gramps.gen.lib.locationbase.LocationBase

Contains the information about the owner of the database.

classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get()[source]
get_address()[source]

Return the database owner’s address.

get_email()[source]

Return the database owner’s email.

get_name()[source]

Return the database owner’s name.

serialize()[source]

Convert the object to a serialized tuple of data.

set_address(data)[source]

Set the database owner’s address.

set_email(data)[source]

Set the database owner’s email.

set_from(other_researcher)[source]

Set all attributes from another instance.

set_name(data)[source]

Set the database owner’s name.

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

Type classes

Base type for all gramps types.

class gramps.gen.lib.grampstype.GrampsTypeMeta(name, bases, namespace)[source]

Bases: type

Metaclass for GrampsType.

Create the class-specific integer/string maps.

GrampsType

class gramps.gen.lib.grampstype.GrampsType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsTypeC

Base class for all Gramps object types.

Variables:
  • _DATAMAP – (list) 3-tuple like (index, localized_string, english_string).
  • _BLACKLIST – List of indices to ignore (obsolete/retired entries). (gramps policy is never to delete type values, or reuse the name (TOKEN) of any specific type value)
  • POS_<x> – (int) Position of <x> attribute in the serialized format of an instance.

Warning

The POS_<x> class variables reflect the serialized object, they have to be updated in case the data structure or the serialize() method changes!

Variables:
  • _CUSTOM – (int) a custom type object
  • _DEFAULT – (int) the default type, used on creation
Attribute value:
 

(int) Returns or sets integer value

Attribute string:
 

(str) Returns or sets string value

POS_STRING = 1
POS_VALUE = 0
classmethod from_struct(struct)[source]

Given a struct data representation, return a serialized object.

Returns:Returns a serialized object
get_custom()[source]
get_map()[source]
get_menu()[source]
get_standard_names()[source]

Return the list of localized names for all standard types.

get_standard_xml()[source]

Return the list of XML (english) names for all standard types.

is_custom()[source]
is_default()[source]
serialize()[source]

Convert the object to a serialized tuple of data.

set(value)[source]

Set the value/string properties from the passed in value.

set_from_xml_str(value)[source]

This method sets the type instance based on the untranslated string (obtained e.g. from XML).

string

Returns or sets string value

to_struct()[source]

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.
Return type:dict
unserialize(data)[source]

Convert a serialized tuple of data to an object.

value

Returns or sets integer value

xml_str()[source]

Return the untranslated string (e.g. suitable for XML) corresponding to the type.

AttributeType

Provide the different Attribute Types for Gramps.

class gramps.gen.lib.attrtype.AttributeType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

AGE = 10
AGENCY = 9
CASTE = 1
CAUSE = 8
CUSTOM = 0
DESCRIPTION = 2
FATHER_AGE = 11
ID = 3
MOTHER_AGE = 12
NATIONAL = 4
NICKNAME = 7
NUM_CHILD = 5
SSN = 6
TIME = 14
UNKNOWN = -1
WITNESS = 13
get_ignore_list(exception=None)[source]

Return a list of the types to ignore and not include in default lists.

Exception is a sublist of types that may not be ignored

Parameters:exception (list) – list of integer values corresponding with types that have to be excluded from the ignore list
Returns:list of integers corresponding with the types to ignore when showing a list of different types
Return type:list

ChildRefType

Provide the different child reference types.

class gramps.gen.lib.childreftype.ChildRefType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

Provide the different ChildRef types.

ADOPTED = 2
BIRTH = 1
CUSTOM = 7
FOSTER = 5
NONE = 0
SPONSORED = 4
STEPCHILD = 3
UNKNOWN = 6

EventType

Provide the different event types

class gramps.gen.lib.eventtype.EventType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

Event types.

ADOPT = 11
ADULT_CHRISTEN = 14
ANNULMENT = 9
BAPTISM = 15
BAR_MITZVAH = 16
BAS_MITZVAH = 17
BIRTH = 12
BLESS = 18
BURIAL = 19
CAUSE_DEATH = 20
CENSUS = 21
CHRISTEN = 22
CONFIRMATION = 23
CREMATION = 24
CUSTOM = 0
DEATH = 13
DEGREE = 25
DIVORCE = 7
DIV_FILING = 8
EDUCATION = 26
ELECTED = 27
EMIGRATION = 28
ENGAGEMENT = 6
FIRST_COMMUN = 29
GRADUATION = 31
IMMIGRATION = 30
MARRIAGE = 1
MARR_ALT = 10
MARR_BANNS = 5
MARR_CONTR = 4
MARR_LIC = 3
MARR_SETTL = 2
MED_INFO = 32
MILITARY_SERV = 33
NATURALIZATION = 34
NOB_TITLE = 35
NUM_MARRIAGES = 36
OCCUPATION = 37
ORDINATION = 38
PROBATE = 39
PROPERTY = 40
RELIGION = 41
RESIDENCE = 42
RETIREMENT = 43
UNKNOWN = -1
WILL = 44
get_abbreviation(trans_text=<bound method GrampsNullTranslations.sgettext of <gramps.gen.utils.grampslocale.GrampsNullTranslations instance at 0x2b07d2b60518>>)[source]

Returns the abbreviation for this event. Uses the explicitly given abbreviations, or first letter of each word, or the first three letters. Appends a period after the abbreviation, but not if string is in _ABBREVIATIONS.

If trans_text is passed in (a GrampsLocale sgettext instance) then the translated abbreviation will be returned instead.

is_baptism()[source]

Returns True if EventType is BAPTISM, False otherwise.

is_birth()[source]

Returns True if EventType is BIRTH, False otherwise.

is_birth_fallback()[source]

Returns True if EventType is a birth fallback, False otherwise.

is_burial()[source]

Returns True if EventType is BURIAL, False otherwise.

is_death()[source]

Returns True if EventType is DEATH, False otherwise.

is_death_fallback()[source]

Returns True if EventType is a death fallback, False otherwise.

is_divorce()[source]

Returns True if EventType is DIVORCE, False otherwise.

is_divorce_fallback()[source]

Returns True if EventType is a divorce fallback, False otherwise.

is_marriage()[source]

Returns True if EventType is MARRIAGE, False otherwise.

is_marriage_fallback()[source]

Returns True if EventType is a marriage fallback, False otherwise.

is_relationship_event()[source]

Returns True is EventType is a relationship type event.

is_type(event_name)[source]

Returns True if EventType has name EVENT_NAME, False otherwise.

EventRoleType

Provide the different event roles.

class gramps.gen.lib.eventroletype.EventRoleType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

AIDE = 4
BRIDE = 5
CELEBRANT = 3
CLERGY = 2
CUSTOM = 0
FAMILY = 8
GROOM = 6
INFORMANT = 9
PRIMARY = 1
UNKNOWN = -1
WITNESS = 7
is_family()[source]

Returns True if EventRoleType is FAMILY, False otherwise.

is_primary()[source]

Returns True if EventRoleType is PRIMARY, False otherwise.

FamilyRelType

Provide the different family reference types.

class gramps.gen.lib.familyreltype.FamilyRelType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

CIVIL_UNION = 2
CUSTOM = 4
MARRIED = 0
UNKNOWN = 3
UNMARRIED = 1

MarkerType

Marker types.

From version 3.3 onwards, this is only kept to convert markers into tags when loading old database files.

class gramps.gen.lib.markertype.MarkerType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

Class for handling data markers.

COMPLETE = 1
CUSTOM = 0
NONE = -1
TODO_TYPE = 2

NameType

Name types.

class gramps.gen.lib.nametype.NameType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

AKA = 1
BIRTH = 2
CUSTOM = 0
MARRIED = 3
UNKNOWN = -1

NameOriginType

Name types.

class gramps.gen.lib.nameorigintype.NameOriginType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

Name Origin Types

CUSTOM = 0
FEUDAL = 7
GIVEN = 3
INHERITED = 2
LOCATION = 12
MATRILINEAL = 10
MATRONYMIC = 6
NONE = 1
OCCUPATION = 11
PATRILINEAL = 9
PATRONYMIC = 5
PSEUDONYM = 8
TAKEN = 4
UNKNOWN = -1

NoteType

Note types.

class gramps.gen.lib.notetype.NoteType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

ADDRESS = 6
ASSOCIATION = 7
ATTRIBUTE = 5
CHILDREF = 19
CITATION = 22
CUSTOM = 0
EVENT = 10
EVENTREF = 11
FAMILY = 9
GENERAL = 1
HTML_CODE = 24
LDS = 8
MEDIA = 17
MEDIAREF = 18
PERSON = 4
PERSONNAME = 20
PLACE = 14
REPO = 15
REPOREF = 16
REPORT_TEXT = 23
RESEARCH = 2
SOURCE = 12
SOURCEREF = 13
SOURCE_TEXT = 21
TODO = 25
TRANSCRIPT = 3
UNKNOWN = -1
get_ignore_list(exception)[source]

Return a list of the types to ignore and not include in default lists.

Exception is a sublist of types that may not be ignored

Parameters:exception (list) – list of integer values corresponding with types that have to be excluded from the ignore list
Returns:list of integers corresponding with the types to ignore when showing a list of different types
Return type:list

PlaceType

Provide the different place types.

class gramps.gen.lib.placetype.PlaceType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

BOROUGH = 13
BUILDING = 19
CITY = 4
COUNTRY = 1
COUNTY = 3
CUSTOM = 0
DEPARTMENT = 10
DISTRICT = 12
FARM = 18
HAMLET = 17
LOCALITY = 6
MUNICIPALITY = 14
NEIGHBORHOOD = 11
PARISH = 5
PROVINCE = 8
REGION = 9
STATE = 2
STREET = 7
TOWN = 15
UNKNOWN = -1
VILLAGE = 16

RepositoryType

Repository types.

class gramps.gen.lib.repotype.RepositoryType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

ALBUM = 5
ARCHIVE = 4
BOOKSTORE = 7
CEMETERY = 2
CHURCH = 3
COLLECTION = 8
CUSTOM = 0
LIBRARY = 1
SAFE = 9
UNKNOWN = -1
WEBSITE = 6

SourceMediaType

SourceMedia types.

class gramps.gen.lib.srcmediatype.SourceMediaType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

AUDIO = 1
BOOK = 2
CARD = 3
CUSTOM = 0
ELECTRONIC = 4
FICHE = 5
FILM = 6
MAGAZINE = 7
MANUSCRIPT = 8
MAP = 9
NEWSPAPER = 10
PHOTO = 11
TOMBSTONE = 12
UNKNOWN = -1
VIDEO = 13

StyledTextTagType

Define text formatting tag types.

class gramps.gen.lib.styledtexttagtype.StyledTextTagType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

Text formatting tag type definition.

Here we only define new class variables. For details see GrampsType.

BOLD = 0
FONTCOLOR = 5
FONTFACE = 3
FONTSIZE = 4
HIGHLIGHT = 6
ITALIC = 1
NONE_TYPE = -1
STYLE_DEFAULT = {0: False, 1: False, 2: False, 3: 'Sans', 4: 10, 5: '#000000', 6: '#FFFFFF', 7: False, 8: ''}
STYLE_TYPE = {0: <type 'bool'>, 1: <type 'bool'>, 2: <type 'bool'>, 3: <type 'str'>, 4: <type 'int'>, 5: <type 'str'>, 6: <type 'str'>, 7: <type 'bool'>, 8: <type 'str'>}
SUPERSCRIPT = 7
UNDERLINE = 2

UrlType

URL types

class gramps.gen.lib.urltype.UrlType(value=None)[source]

Bases: gramps.gen.lib.grampstype.GrampsType

CUSTOM = 0
EMAIL = 1
UNKNOWN = -1
WEB_FTP = 4
WEB_HOME = 2

Privacy

PrivateSourceNote

PrivateSourceNote class for GRAMPS.

class gramps.gen.lib.privsrcnote.PrivateSourceNote[source]

Bases: gramps.gen.lib.srcnote.SourceNote, gramps.gen.lib.privacybase.PrivacyBase