The gramps.gen.lib Module

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]

Create a new instance from serialized data.

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_object_state()[source]

Get the current object state as a dictionary.

By default this returns the public attributes of the instance. This method can be overridden if the class requires other attributes or properties to be saved.

This method is called to provide the information required to serialize the object.

Returns:

Returns a dictionary of attributes that represent the state of the object.

Return type:

dict

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.

abstractmethod serialize()[source]

Convert the object to a serialized tuple of data.

set_object_state(attr_dict)[source]

Set the current object state using information provided in the given dictionary.

By default this sets the state of the object assuming that all items in the dictionary map to public attributes. This method can be overridden to set the state using custom functionality. For performance reasons it is useful to set a property without calling its setter function. As JSON provides no distinction between tuples and lists, this method can also be use to convert lists into tuples where required.

Parameters:

attr_dict (dict) – A dictionary of attributes that represent the state of the object.

abstractmethod unserialize(data)[source]

Convert a serialized tuple of data to an object.

AddressBase

AttributeRootBase

AttributeBase

SrcAttributeBase

CitationBase

IndirectCitationBase

DateBase

LdsOrdBase

LocationBase

MediaBase

NoteBase

PlaceBase

PrivacyBase

RefBase

SurnameBase

TagBase

UrlBase

Primary objects

BasicPrimaryObject

PrimaryObject

Person

Family

Event

Place

Source

Citation

Media

Repository

Note

Secondary objects

Secondary Object

Address

Attribute

AttributeRoot

LdsOrd

Location

Name

Surname

Url

Reference objects

ChildRef

EventRef

MediaRef

PersonRef

PlaceRef

RepoRef

Table objects

Table object

Tag

Date objects

Date

Span

DateError

Text objects

StyledTextTag

StyledText

Meta data

GenderStats

Researcher

Type classes

GrampsType

AttributeType

ChildRefType

EventType

EventRoleType

FamilyRelType

MarkerType

NameType

NameOriginType

NoteType

PlaceType

RepositoryType

SourceMediaType

StyledTextTagType

UrlType