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:
objectProvide 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
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
Return the author of the source.
Parameters: source ( Source) – Source objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: list of Familyobjects 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 ( PersonorFamily) – Person or Family objectReturns: Returns a list of Personobjects representing the childrenReturn type: list
-
date_string(date_obj)[source]¶ Return a string representation a date_obj
Parameters: date_obj ( Date) – Date objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: 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_date(event)[source]¶ Return a string indicating the date of the event
Parameters: event ( Event) – Event objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: 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
PersonorFamily.Parameters: Returns: list of events associated with the object
Return type: list
-
father(obj)[source]¶ Return the primary father of the person or the father of the associated family.
Parameters: obj ( PersonorFamily) – Person or Family objectReturns: 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 objectReturns: 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 objectReturns: Returns a string indentifying the person’s gender Return type: unicode
-
get_link(object_class, prop, value)[source]¶ 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 ( PersonorFamily) – Person or Family objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: 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 ( PersonorFamily) – Person objectReturns: 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 objectReturns: 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 objectReturns: 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 objectReturns: list of Familyobjects in which the person is listed as a parent.Return type: list
-
sources(obj)[source]¶ Return a list of events associated with the object. This object can be either a
PersonorFamily.Parameters: obj ( PersonorFamily) – Person or FamilyReturns: list of events associated with the object Return type: list
-
spouse(person)[source]¶ Return the primary spouse of the person
Parameters: person ( Person) – Person objectReturns: The spouse identified as the person’s primary spouse Return type: Person
-
Simple Doc¶
Provide a simplified database access interface to the Gramps database.
Simple Table¶
Provide a simplified table creation interface
-
class
gramps.gen.simple._simpletable.SimpleTable(access, title=None)[source]¶ Bases:
objectProvide a simplified table creation interface.
-
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.
-