The Simple Classes

Simple access routines

Simple Access

Provide a simplified database access interface to the Gramps database.

class gramps.gen.simple._simpleaccess.SimpleAccess(dbase)[source]

Bases: object

Provide a simplified database access system. This system has been designed to ease the development of reports.

The user needs to take care when using this interface. Since it returns real objects instead of database references, it can consume a significant amount of memory if the user is not careful.

Example

A typical system of usage would be:

sa = SimpleAccess(database)

print "Person        : ", sa.name(person)
print "Gender        : ", sa.gender(person)
print "Birth date    : ", sa.birth_date(person)
print "Birth place   : ", sa.birth_place(person)
print "Death date    : ", sa.death_date(person)
print "Death place   : ", sa.death_place(person)
print "Father        : ", sa.name(sa.father(person))
print "Mother        : ", sa.name(sa.mother(person))
print "Spouse        : ", sa.name(sa.spouse(person))
print "Marriage Type : ", sa.marriage_type(person)
print "Marriage Date : ", sa.marriage_date(person)
print "Marriage Place: ", sa.marriage_place(person)
for child in sa.children(person):
   print "Child         : ", sa.name(child)
  
# Print out burial and baptism events
for event in sa.events( person , [ "Burial", "Baptism" ]):
   print "Event         : ", sa.event_type(event), sa.event_date(event), 
   print sa.event_place(event)

This would produce an output that looks like:

Person        :  Garner, Lewis Anderson
Gender        :  male
Birth date    :  6/21/1855
Birth place   :  Great Falls, MT
Death date    :  6/28/1911
Death place   :  Twin Falls, ID
Father        :  Garner, Robert W.
Mother        :  Zielinski, Phoebe Emily
Spouse        :  Martel, Luella Jacques
Marriage Type :  Married
Marriage Date :  4/1/1875
Marriage Place:  Paragould, AR
Child         :  Garner, Eugene Stanley
Child         :  Garner, Jesse V.
Child         :  Garner, Raymond E.
Child         :  Garner, Jennie S.
Child         :  Garner, Walter E.
Child         :  Garner, Daniel Webster
Child         :  Garner, Bertha P.
Child         :  Garner, Elizabeth
Event         :  Burial 7/1/1911 Twin Falls, ID

One can also alternatively supply a handle rather than a person.

all_citations()[source]

Return all the citations in the database, one at a time as an iterator. The user can treat this just like a list. For example:

:return: list of citations in the database
:rtype: list
all_events()[source]

Return all the events in the database, one at a time as an iterator. The user can treat this just like a list. For example:

for person in sa.all_events():
   sa.print(sa.event_place(event))
Returns:list of events in the database
Return type:list
all_families()[source]

Return all the families in the database, one at a time as an iterator. The user can treat this just like a list. For example:

for person in sa.all_families():
   sa.print(sa.father(person))
Returns:list of families in the database
Return type:list
all_media()[source]

Return all the media in the database, one at a time as an iterator. The user can treat this just like a list. For example:

:return: list of media in the database
:rtype: list
all_notes()[source]

Return all the notes in the database, one at a time as an iterator. The user can treat this just like a list. For example:

:return: list of notes in the database
:rtype: list
all_people()[source]

Return a all the people in the database, one at a time as an iterator. The user can treat this just like a list. For example:

for person in sa.all_people():
   sa.print(person)
Returns:list of people in the database
Return type:list
all_places()[source]

Return all the places in the database, one at a time as an iterator. The user can treat this just like a list. For example:

:return: list of places in the database
:rtype: list
all_repositories()[source]

Return all the repositories in the database, one at a time as an iterator. The user can treat this just like a list. For example:

:return: list of repositories in the database
:rtype: list
all_sources()[source]

Return all the sources in the database, one at a time as an iterator. The user can treat this just like a list. For example:

:return: list of sources in the database
:rtype: list
all_tags()[source]

Return all the tags in the database, one at a time as an iterator. The user can treat this just like a list. For example:

:return: list of tags in the database
:rtype: list
author(source)[source]

Return the author of the source.

Parameters:source (Source) – Source object
Returns:author of the source
Return type:unicode
birth_date(person)[source]

Return a string indicating the date when the person’s birth.

Parameters:person (Person) – Person object
Returns:Returns a string indicating the date when the person’s birth.
Return type:unicode
birth_date_obj(person)[source]

Return the date when the person’s birth.

Parameters:person (Person) – Person object
Returns:Returns the date when the person’s birth.
Return type:Date
birth_or_fallback(person, get_event=False)[source]

Return the date of the person’s birth or fallback event.

Parameters:person (Person) – Person object
Returns:Returns the date when the person’s birth or fallback.
Return type:Date
birth_place(person)[source]

Return a string indicating the place of the person’s birth.

Parameters:person (Person) – Person object
Returns:Returns a string indicating the place of the person’s birth.
Return type:unicode
child_in(person)[source]

Return a list of families in which the person is listed as a child.

Parameters:person (Person) – Person object
Returns:list of Family objects in which the person is listed as a child.
Return type:list
children(obj)[source]

Return a list of the children as the children of the primary spouse.

Parameters:obj (Person or Family) – Person or Family object
Returns:Returns a list of Person objects representing the children
Return type:list
date_string(date_obj)[source]

Return a string representation a date_obj

Parameters:date_obj (Date) – Date object
Returns:Returns a string representation a date_obj
Return type:unicode
death_date(person)[source]

Return a string indicating the date when the person’s death.

Parameters:person (Person) – Person object
Returns:Returns a string indicating the date when the person’s death.
Return type:unicode
death_date_obj(person)[source]

Return the date when the person’s death.

Parameters:person (Person) – Person object
Returns:Returns the date when the person’s death.
Return type:Date
death_or_fallback(person, get_event=False)[source]

Return the date of the person’s death or fallback event.

Parameters:person (Person) – Person object
Returns:Returns the date of the person’s death or fallback.
Return type:Date
death_place(person)[source]

Return a string indicating the place of the person’s death.

Parameters:person (Person) – Person object
Returns:Returns a string indicating the place of the person’s death.
Return type:unicode
describe(obj, prop=None, value=None)[source]

Given a object, return a string describing the object.

display(object_class, prop, value)[source]

Given a object_class, prop, and value return a display string describing object.

Parameters:
  • object_class – “Person”, “Source”, etc.
  • prop – “gramps_id”, or “handle”
  • value – gramps_id or handle.
event(handle)[source]
event_date(event)[source]

Return a string indicating the date of the event

Parameters:event (Event) – Event object
Returns:Returns a string indicating the date of the event
Return type:unicode
event_date_obj(event)[source]

Return a string indicating the date of the event

Parameters:event (Event) – Event object
Returns:Returns a string indicating the date of the event
Return type:unicode
event_place(event)[source]

Return a string indicating the place of the event

Parameters:event (Event) – Event object
Returns:Returns a string indicating the place of the event
Return type:unicode
event_type(event)[source]

Return a string indicating the type of the event

Parameters:event (Event) – Event object
Returns:Returns a string indicating the type of the event
Return type:unicode
events(obj, restrict=None)[source]

Return a list of events associated with the object. This object can be either a Person or Family.

Parameters:
  • obj (Person or Family) – Person or Family
  • restrict (list) – Optional list of strings that will limit the types of events to those of the specified types.
Returns:

list of events associated with the object

Return type:

list

family(handle)[source]
father(obj)[source]

Return the primary father of the person or the father of the associated family.

Parameters:obj (Person or Family) – Person or Family object
Returns:The father in the person’s primary family or the father of the family
Return type:Person
first_name(person)[source]

Return the first name of the person, or and empty string if the person is None

Parameters:person (Person) – Person object
Returns:Returns the first name of the person based of the program preferences
Return type:unicode
gender(person)[source]

Return a string representing the gender of the person

Parameters:person (Person) – Person object
Returns:Returns a string indentifying the person’s gender
Return type:unicode

Given a object_class, prop, and value return the object.

Parameters:
  • object_class – “Person”, “Source”, etc.
  • prop – “gramps_id”, or “handle”
  • value – gramps_id or handle.
gid(obj)[source]

Return the Gramps ID of the person or family

Parameters:obj (Person or Family) – Person or Family object
Returns:Returns the Gramps ID value of the person or family
Return type:unicode
marriage_date(person)[source]

Return a string indicating the date when the person and his/her spouse where married.

Parameters:person (Person) – Person object
Returns:Returns a string indicicating the date when the person and his/her spouse where married.
Return type:unicode
marriage_place(person)[source]

Return a string describing the place where the person and his/her spouse where married.

Parameters:person (Person) – Person object
Returns:Returns a string describing the place where the person and his/her spouse where married.
Return type:unicode
marriage_type(person)[source]

Return a string describing the relationship between the person and his/per primary spouse.

Parameters:person (Person) – Person object
Returns:Returns a string describing the relationship between the person and his/per primary spouse.
Return type:unicode
mother(obj)[source]

Returns the primary mother of the person or the mother of the associated family.

Parameters:obj (Person or Family) – Person object
Returns:The mother in the person’s primary family or the mother of the family
Return type:Person
name(person)[source]

Return the name of the person, or and empty string if the person is None

Parameters:person (Person) – Person object
Returns:Returns the name of the person based of the program preferences
Return type:unicode
page(citation)[source]

Return the page of the citation.

Parameters:citation (Citation) – Source object
Returns:title of the citation
Return type:unicode
parent_in(person)[source]

Return a list of families in which the person is listed as a parent.

Parameters:person (Person) – Person object
Returns:list of Family objects in which the person is listed as a parent.
Return type:list
person(handle)[source]
sources(obj)[source]

Return a list of events associated with the object. This object can be either a Person or Family.

Parameters:obj (Person or Family) – Person or Family
Returns:list of events associated with the object
Return type:list
spouse(person)[source]

Return the primary spouse of the person

Parameters:person (Person) – Person object
Returns:The spouse identified as the person’s primary spouse
Return type:Person
surname(person)[source]

Return the name of the person, or and empty string if the person is None

Parameters:person (Person) – Person object
Returns:Returns the name of the person based of the program preferences
Return type:unicode
title(source)[source]

Return the title of the source.

Parameters:source (Source) – Source object
Returns:title of the source
Return type:unicode
gramps.gen.simple._simpleaccess.by_date(event1, event2)[source]

Sort function that will compare two events by their dates.

Parameters:
  • event1 (Event) – first event
  • event2 (Event) – second event
Returns:

Returns -1 if event1 < event2, 0 if they are equal, and 1 if they are the same.

Return type:

int

Simple Doc

Provide a simplified database access interface to the Gramps database.

class gramps.gen.simple._simpledoc.SimpleDoc(doc)[source]

Bases: object

Provide a simplified database access interface to the Gramps database.

header1(text)[source]

Writes the first level header using the Header1 paragraph

header2(text)[source]

Writes the second level header using the Header2 paragraph

header3(text)[source]

Writes the third level header using the Header3 paragraph

paragraph(text)[source]

Writes a paragraph using the Normal format

title(text)[source]

Writes the Title using the Title paragraph

gramps.gen.simple._simpledoc.make_basic_stylesheet(**kwargs)[source]

Create the basic style sheet for the SimpleDoc class.

kwargs - a dictionary of the form:
item={method: value, ...}, ...

Example:

make_basic_stylesheet(Table={“set_width”: 90})

Simple Table

Provide a simplified table creation interface

class gramps.gen.simple._simpletable.SimpleTable(access, title=None)[source]

Bases: object

Provide a simplified table creation interface.

columns(*cols)[source]

Set the columns

get_cell_markup(x, y=None, data=None)[source]

See if a column has formatting (if x and y are supplied) or see if a cell has formatting. If it does, return the formatted string, otherwise return data that is escaped (if that column has formatting), or just the plain data.

get_cell_type(col)[source]

See if a column has a type, else return “text” as default.

get_raw_data(index)[source]
get_row(index)[source]
get_row_count()[source]
row(*data, **kwargs)[source]

Add a row of data.

row_sort_val(col, val)[source]

Add a row of data to sort by.

set_cell_markup(x, y, data)[source]

Set the cell at position [x][y] to a formatted string.

set_cell_type(col, value)[source]

Set the cell type at position [x].

Manually sets the column that defines link. col is either a number (column) or a (object_type_name, handle).

sort(column_name, reverse=False)[source]
write(document, column_widths=None)[source]

Table Of Contents

Previous topic

The RelationshipCalculator Class

Next topic

The Html Class

This Page