Improve simple access documentation
This commit is contained in:
parent
88f3cfa3f7
commit
3ef1c02155
@ -23,7 +23,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Provide a simplified database access interface to the GRAMPS database.
|
Provide a simplified database access interface to the Gramps database.
|
||||||
"""
|
"""
|
||||||
from __future__ import with_statement, unicode_literals
|
from __future__ import with_statement, unicode_literals
|
||||||
|
|
||||||
@ -49,15 +49,14 @@ from ..constfunc import STRTYPE
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class SimpleAccess(object):
|
class SimpleAccess(object):
|
||||||
"""
|
"""
|
||||||
Provide a simplified database access system. This system has been designed to
|
Provide a simplified database access system. This system has been designed
|
||||||
ease the development of reports.
|
to ease the development of reports.
|
||||||
|
|
||||||
The user needs to take care when using this interface. Since it returns real
|
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
|
objects instead of database references, it can consume a significant amount
|
||||||
of memory if the user is not careful.
|
of memory if the user is not careful.
|
||||||
|
|
||||||
Example
|
**Example**
|
||||||
=======
|
|
||||||
|
|
||||||
A typical system of usage would be::
|
A typical system of usage would be::
|
||||||
|
|
||||||
@ -114,8 +113,8 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Initialize the SimpleAccess object with the database that will be used.
|
Initialize the SimpleAccess object with the database that will be used.
|
||||||
|
|
||||||
@param dbase: GRAMPS database object
|
:param dbase: Gramps database object
|
||||||
@type dbase: DbBase
|
:type dbase: DbBase
|
||||||
"""
|
"""
|
||||||
self.dbase = dbase
|
self.dbase = dbase
|
||||||
|
|
||||||
@ -123,10 +122,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the name of the person, or and empty string if the person is None
|
Return the name of the person, or and empty string if the person is None
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns the name of the person based of the program preferences
|
:return: Returns the name of the person based of the program preferences
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -140,10 +139,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the name of the person, or and empty string if the person is None
|
Return the name of the person, or and empty string if the person is None
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns the name of the person based of the program preferences
|
:return: Returns the name of the person based of the program preferences
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -156,12 +155,14 @@ class SimpleAccess(object):
|
|||||||
|
|
||||||
def first_name(self, person):
|
def first_name(self, person):
|
||||||
"""
|
"""
|
||||||
Return the first name of the person, or and empty string if the person is None
|
Return the first name of the person, or and empty string if the person
|
||||||
|
is None
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns the first name of the person based of the program preferences
|
:return: Returns the first name of the person based of the program
|
||||||
@rtype: unicode
|
preferences
|
||||||
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -173,12 +174,12 @@ class SimpleAccess(object):
|
|||||||
|
|
||||||
def gid(self, obj):
|
def gid(self, obj):
|
||||||
"""
|
"""
|
||||||
Return the GRAMPS ID of the person or family
|
Return the Gramps ID of the person or family
|
||||||
|
|
||||||
@param obj: Person or Family object
|
:param obj: Person or Family object
|
||||||
@type obj: L{gen.lib.Person} or L{gen.lib.Family}
|
:type obj: :py:class:`.Person` or :py:class:`.Family`
|
||||||
@return: Returns the GRAMPS Id value of the person or family
|
:return: Returns the Gramps ID value of the person or family
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if obj:
|
if obj:
|
||||||
return obj.get_gramps_id()
|
return obj.get_gramps_id()
|
||||||
@ -189,10 +190,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string representing the gender of the person
|
Return a string representing the gender of the person
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string indentifying the person's gender
|
:return: Returns a string indentifying the person's gender
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -205,12 +206,12 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a person associated as a parent of the person
|
Return a person associated as a parent of the person
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@param func: function used to extract the appropriate parent
|
:param func: function used to extract the appropriate parent
|
||||||
@type func: function
|
:type func: function
|
||||||
@return: mother or father of the associated person
|
:return: mother or father of the associated person
|
||||||
@rtype: L{gen.lib.Person}
|
:rtype: :py:class:`.Person`
|
||||||
"""
|
"""
|
||||||
assert(person is None or isinstance(person, Person))
|
assert(person is None or isinstance(person, Person))
|
||||||
|
|
||||||
@ -226,12 +227,12 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a person associated as a parent of the family
|
Return a person associated as a parent of the family
|
||||||
|
|
||||||
@param family: Family object
|
:param family: Family object
|
||||||
@type family: L{gen.lib.Family}
|
:type family: :py:class:`.Family`
|
||||||
@param func: function used to extract the appropriate parent
|
:param func: function used to extract the appropriate parent
|
||||||
@type func: function
|
:type func: function
|
||||||
@return: mother or father of the associated family
|
:return: mother or father of the associated family
|
||||||
@rtype: L{gen.lib.Family}
|
:rtype: :py:class:`.Family`
|
||||||
"""
|
"""
|
||||||
assert(family is None or isinstance(family, Family))
|
assert(family is None or isinstance(family, Family))
|
||||||
|
|
||||||
@ -245,12 +246,12 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string describing the date associated with the person
|
Return a string describing the date associated with the person
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@param func: function used to extract the associated date information
|
:param func: function used to extract the associated date information
|
||||||
@type func: function
|
:type func: function
|
||||||
@return: Returns a string describing the date
|
:return: Returns a string describing the date
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(person is None or isinstance(person, Person))
|
assert(person is None or isinstance(person, Person))
|
||||||
|
|
||||||
@ -269,12 +270,12 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the date associated with the person
|
Return the date associated with the person
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@param func: function used to extract the associated date information
|
:param func: function used to extract the associated date information
|
||||||
@type func: function
|
:type func: function
|
||||||
@return: Returns the date
|
:return: Returns the date
|
||||||
@rtype: l{gen.lib.Date}
|
:rtype: l{gen.lib.Date}
|
||||||
"""
|
"""
|
||||||
assert(person is None or isinstance(person, Person))
|
assert(person is None or isinstance(person, Person))
|
||||||
|
|
||||||
@ -295,12 +296,12 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string describing the place associated with the person
|
Return a string describing the place associated with the person
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@param func: function used to extract the associated place information
|
:param func: function used to extract the associated place information
|
||||||
@type func: function
|
:type func: function
|
||||||
@return: Returns a string describing the place
|
:return: Returns a string describing the place
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(person is None or isinstance(person, Person))
|
assert(person is None or isinstance(person, Person))
|
||||||
|
|
||||||
@ -318,10 +319,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the primary spouse of the person
|
Return the primary spouse of the person
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: The spouse identified as the person's primary spouse
|
:return: The spouse identified as the person's primary spouse
|
||||||
@rtype: L{gen.lib.Person}
|
:rtype: :py:class:`.Person`
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -345,11 +346,11 @@ class SimpleAccess(object):
|
|||||||
Return a string describing the relationship between the person and
|
Return a string describing the relationship between the person and
|
||||||
his/per primary spouse.
|
his/per primary spouse.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string describing the relationship between the person and
|
:return: Returns a string describing the relationship between the
|
||||||
his/per primary spouse.
|
person and his/per primary spouse.
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -369,11 +370,11 @@ class SimpleAccess(object):
|
|||||||
Return a string describing the place where the person and his/her spouse
|
Return a string describing the place where the person and his/her spouse
|
||||||
where married.
|
where married.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string describing the place where the person and his/her spouse
|
:return: Returns a string describing the place where the person and
|
||||||
where married.
|
his/her spouse where married.
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -401,11 +402,11 @@ class SimpleAccess(object):
|
|||||||
Return a string indicating the date when the person and his/her spouse
|
Return a string indicating the date when the person and his/her spouse
|
||||||
where married.
|
where married.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string indicicating the date when the person and his/her spouse
|
:return: Returns a string indicicating the date when the person and
|
||||||
where married.
|
his/her spouse where married.
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -433,10 +434,11 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a list of the children as the children of the primary spouse.
|
Return a list of the children as the children of the primary spouse.
|
||||||
|
|
||||||
@param obj: Person or Family object
|
:param obj: Person or Family object
|
||||||
@type obj: L{gen.lib.Person} or L{gen.lib.Family}
|
:type obj: :py:class:`.Person` or :py:class:`.Family`
|
||||||
@return: Returns a list of L{gen.lib.Person} objects representing the children
|
:return: Returns a list of :py:class:`.Person` objects representing the
|
||||||
@rtype: list
|
children
|
||||||
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
assert(obj is None or isinstance(obj, (Person, Family)))
|
assert(obj is None or isinstance(obj, (Person, Family)))
|
||||||
|
|
||||||
@ -458,11 +460,11 @@ class SimpleAccess(object):
|
|||||||
Return the primary father of the person or the father of the associated
|
Return the primary father of the person or the father of the associated
|
||||||
family.
|
family.
|
||||||
|
|
||||||
@param obj: Person or Family object
|
:param obj: Person or Family object
|
||||||
@type obj: L{gen.lib.Person} or L{gen.lib.Family}
|
:type obj: :py:class:`.Person` or :py:class:`.Family`
|
||||||
@return: The father in the person's primary family or the father of the
|
:return: The father in the person's primary family or the father of the
|
||||||
family
|
family
|
||||||
@rtype: L{gen.lib.Person}
|
:rtype: :py:class:`.Person`
|
||||||
"""
|
"""
|
||||||
if isinstance(obj, Person):
|
if isinstance(obj, Person):
|
||||||
return self.__parent(obj, Family.get_father_handle)
|
return self.__parent(obj, Family.get_father_handle)
|
||||||
@ -476,11 +478,11 @@ class SimpleAccess(object):
|
|||||||
Returns the primary mother of the person or the mother of the associated
|
Returns the primary mother of the person or the mother of the associated
|
||||||
family.
|
family.
|
||||||
|
|
||||||
@param obj: Person object
|
:param obj: Person object
|
||||||
@type obj: L{gen.lib.Person} or L{gen.lib.Family}
|
:type obj: :py:class:`.Person` or :py:class:`.Family`
|
||||||
@return: The mother in the person's primary family or the mother of the
|
:return: The mother in the person's primary family or the mother of the
|
||||||
family
|
family
|
||||||
@rtype: L{gen.lib.Person}
|
:rtype: :py:class:`.Person`
|
||||||
"""
|
"""
|
||||||
if isinstance(obj, Person):
|
if isinstance(obj, Person):
|
||||||
return self.__parent(obj, Family.get_mother_handle)
|
return self.__parent(obj, Family.get_mother_handle)
|
||||||
@ -493,10 +495,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the date when the person's birth.
|
Return a string indicating the date when the person's birth.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string indicating the date when the person's birth.
|
:return: Returns a string indicating the date when the person's birth.
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -506,10 +508,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the date when the person's birth.
|
Return the date when the person's birth.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns the date when the person's birth.
|
:return: Returns the date when the person's birth.
|
||||||
@rtype: L{gen.lib.Date}
|
:rtype: :py:class:`.Date`
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -520,10 +522,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the date of the person's birth or fallback event.
|
Return the date of the person's birth or fallback event.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns the date when the person's birth or fallback.
|
:return: Returns the date when the person's birth or fallback.
|
||||||
@rtype: L{gen.lib.Date}
|
:rtype: :py:class:`.Date`
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -539,10 +541,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the place of the person's birth.
|
Return a string indicating the place of the person's birth.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string indicating the place of the person's birth.
|
:return: Returns a string indicating the place of the person's birth.
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -552,10 +554,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the date when the person's death.
|
Return a string indicating the date when the person's death.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string indicating the date when the person's death.
|
:return: Returns a string indicating the date when the person's death.
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -565,10 +567,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the date when the person's death.
|
Return the date when the person's death.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns the date when the person's death.
|
:return: Returns the date when the person's death.
|
||||||
@rtype: L{gen.lib.Date}
|
:rtype: :py:class:`.Date`
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -578,10 +580,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the date of the person's death or fallback event.
|
Return the date of the person's death or fallback event.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns the date of the person's death or fallback.
|
:return: Returns the date of the person's death or fallback.
|
||||||
@rtype: L{gen.lib.Date}
|
:rtype: :py:class:`.Date`
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -597,10 +599,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the place of the person's death.
|
Return a string indicating the place of the person's death.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: Returns a string indicating the place of the person's death.
|
:return: Returns a string indicating the place of the person's death.
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -610,10 +612,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the place of the event
|
Return a string indicating the place of the event
|
||||||
|
|
||||||
@param event: Event object
|
:param event: Event object
|
||||||
@type event: L{gen.lib.Event}
|
:type event: :py:class:`.Event`
|
||||||
@return: Returns a string indicating the place of the event
|
:return: Returns a string indicating the place of the event
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(event is None or isinstance(event, Event))
|
assert(event is None or isinstance(event, Event))
|
||||||
|
|
||||||
@ -627,10 +629,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string representation a date_obj
|
Return a string representation a date_obj
|
||||||
|
|
||||||
@param date_obj: Date object
|
:param date_obj: Date object
|
||||||
@type date_obj: L{gen.lib.Date}
|
:type date_obj: :py:class:`.Date`
|
||||||
@return: Returns a string representation a date_obj
|
:return: Returns a string representation a date_obj
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
if date_obj:
|
if date_obj:
|
||||||
return displayer.display(date_obj)
|
return displayer.display(date_obj)
|
||||||
@ -641,10 +643,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the date of the event
|
Return a string indicating the date of the event
|
||||||
|
|
||||||
@param event: Event object
|
:param event: Event object
|
||||||
@type event: L{gen.lib.Event}
|
:type event: :py:class:`.Event`
|
||||||
@return: Returns a string indicating the date of the event
|
:return: Returns a string indicating the date of the event
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(event is None or isinstance(event, Event))
|
assert(event is None or isinstance(event, Event))
|
||||||
date_obj = event.get_date_object()
|
date_obj = event.get_date_object()
|
||||||
@ -657,10 +659,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the date of the event
|
Return a string indicating the date of the event
|
||||||
|
|
||||||
@param event: Event object
|
:param event: Event object
|
||||||
@type event: L{gen.lib.Event}
|
:type event: :py:class:`.Event`
|
||||||
@return: Returns a string indicating the date of the event
|
:return: Returns a string indicating the date of the event
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(event is None or isinstance(event, Event))
|
assert(event is None or isinstance(event, Event))
|
||||||
if event:
|
if event:
|
||||||
@ -670,10 +672,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a string indicating the type of the event
|
Return a string indicating the type of the event
|
||||||
|
|
||||||
@param event: Event object
|
:param event: Event object
|
||||||
@type event: L{gen.lib.Event}
|
:type event: :py:class:`.Event`
|
||||||
@return: Returns a string indicating the type of the event
|
:return: Returns a string indicating the type of the event
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(event is None or isinstance(event, Event))
|
assert(event is None or isinstance(event, Event))
|
||||||
if event:
|
if event:
|
||||||
@ -684,15 +686,15 @@ class SimpleAccess(object):
|
|||||||
def events(self, obj, restrict=None):
|
def events(self, obj, restrict=None):
|
||||||
"""
|
"""
|
||||||
Return a list of events associated with the object. This object
|
Return a list of events associated with the object. This object
|
||||||
can be either a L{gen.lib.Person} or L{gen.lib.Family}.
|
can be either a :py:class:`.Person` or :py:class:`.Family`.
|
||||||
|
|
||||||
@param obj: Person or Family
|
:param obj: Person or Family
|
||||||
@type obj: L{gen.lib.Person} or L{gen.lib.Family}
|
:type obj: :py:class:`.Person` or :py:class:`.Family`
|
||||||
@param restrict: Optional list of strings that will limit the types
|
:param restrict: Optional list of strings that will limit the types
|
||||||
of events to those of the specified types.
|
of events to those of the specified types.
|
||||||
@type restrict: list
|
:type restrict: list
|
||||||
@return: list of events associated with the object
|
:return: list of events associated with the object
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
assert(obj is None or isinstance(obj, (Person, Family)))
|
assert(obj is None or isinstance(obj, (Person, Family)))
|
||||||
assert(isinstance(restrict, list) or restrict is None)
|
assert(isinstance(restrict, list) or restrict is None)
|
||||||
@ -712,12 +714,12 @@ class SimpleAccess(object):
|
|||||||
def sources(self, obj):
|
def sources(self, obj):
|
||||||
"""
|
"""
|
||||||
Return a list of events associated with the object. This object
|
Return a list of events associated with the object. This object
|
||||||
can be either a L{gen.lib.Person} or L{gen.lib.Family}.
|
can be either a :py:class:`.Person` or :py:class:`.Family`.
|
||||||
|
|
||||||
@param obj: Person or Family
|
:param obj: Person or Family
|
||||||
@type obj: L{gen.lib.Person} or L{gen.lib.Family}
|
:type obj: :py:class:`.Person` or :py:class:`.Family`
|
||||||
@return: list of events associated with the object
|
:return: list of events associated with the object
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
assert(obj is None or isinstance(obj, (Person, Family, Event)))
|
assert(obj is None or isinstance(obj, (Person, Family, Event)))
|
||||||
|
|
||||||
@ -731,11 +733,11 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a list of families in which the person is listed as a parent.
|
Return a list of families in which the person is listed as a parent.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: list of L{gen.lib.Family} objects in which the person is listed
|
:return: list of :py:class:`.Family` objects in which the person is
|
||||||
as a parent.
|
listed as a parent.
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -750,11 +752,11 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return a list of families in which the person is listed as a child.
|
Return a list of families in which the person is listed as a child.
|
||||||
|
|
||||||
@param person: Person object
|
:param person: Person object
|
||||||
@type person: L{gen.lib.Person}
|
:type person: :py:class:`.Person`
|
||||||
@return: list of L{gen.lib.Family} objects in which the person is listed
|
:return: list of :py:class:`.Family` objects in which the person is
|
||||||
as a child.
|
listed as a child.
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
if isinstance(person, STRTYPE):
|
if isinstance(person, STRTYPE):
|
||||||
person = self.dbase.get_person_from_handle(person)
|
person = self.dbase.get_person_from_handle(person)
|
||||||
@ -770,8 +772,8 @@ class SimpleAccess(object):
|
|||||||
Return a all the objects of a particular type in the database, one
|
Return a all the objects of a particular type in the database, one
|
||||||
at a time as an iterator. The user can treat this just like a list.
|
at a time as an iterator. The user can treat this just like a list.
|
||||||
|
|
||||||
@return: list of objects of a particular type in the database
|
:return: list of objects of a particular type in the database
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with gen_cursor() as cursor:
|
with gen_cursor() as cursor:
|
||||||
@ -786,8 +788,8 @@ class SimpleAccess(object):
|
|||||||
for person in sa.all_people():
|
for person in sa.all_people():
|
||||||
sa.print(person)
|
sa.print(person)
|
||||||
|
|
||||||
@return: list of people in the database
|
:return: list of people in the database
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with self.dbase.get_person_cursor() as cursor:
|
with self.dbase.get_person_cursor() as cursor:
|
||||||
@ -805,8 +807,8 @@ class SimpleAccess(object):
|
|||||||
for person in sa.all_families():
|
for person in sa.all_families():
|
||||||
sa.print(sa.father(person))
|
sa.print(sa.father(person))
|
||||||
|
|
||||||
@return: list of families in the database
|
:return: list of families in the database
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
return self.__all_objects(self.dbase.get_family_cursor,
|
return self.__all_objects(self.dbase.get_family_cursor,
|
||||||
self.dbase.get_family_from_handle)
|
self.dbase.get_family_from_handle)
|
||||||
@ -819,8 +821,8 @@ class SimpleAccess(object):
|
|||||||
for person in sa.all_events():
|
for person in sa.all_events():
|
||||||
sa.print(sa.event_place(event))
|
sa.print(sa.event_place(event))
|
||||||
|
|
||||||
@return: list of events in the database
|
:return: list of events in the database
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
return self.__all_objects(self.dbase.get_event_cursor,
|
return self.__all_objects(self.dbase.get_event_cursor,
|
||||||
self.dbase.get_event_from_handle)
|
self.dbase.get_event_from_handle)
|
||||||
@ -830,8 +832,8 @@ class SimpleAccess(object):
|
|||||||
Return all the sources in the database, one at a time as an iterator.
|
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::
|
The user can treat this just like a list. For example::
|
||||||
|
|
||||||
@return: list of sources in the database
|
:return: list of sources in the database
|
||||||
@rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
return self.__all_objects(self.dbase.get_source_cursor,
|
return self.__all_objects(self.dbase.get_source_cursor,
|
||||||
self.dbase.get_source_from_handle)
|
self.dbase.get_source_from_handle)
|
||||||
@ -840,10 +842,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the title of the source.
|
Return the title of the source.
|
||||||
|
|
||||||
@param source: Source object
|
:param source: Source object
|
||||||
@type source: L{gen.lib.Source}
|
:type source: :py:class:`.Source`
|
||||||
@return: title of the source
|
:return: title of the source
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(source is None or isinstance(source, Source))
|
assert(source is None or isinstance(source, Source))
|
||||||
if source:
|
if source:
|
||||||
@ -854,10 +856,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the page of the citation.
|
Return the page of the citation.
|
||||||
|
|
||||||
@param citation: Source object
|
:param citation: Source object
|
||||||
@type citation: L{gen.lib.Citation}
|
:type citation: :py:class:`Citation <.lib.citation.Citation>`
|
||||||
@return: title of the citation
|
:return: title of the citation
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(citation is None or isinstance(citation, Citation))
|
assert(citation is None or isinstance(citation, Citation))
|
||||||
if citation:
|
if citation:
|
||||||
@ -868,10 +870,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Return the author of the source.
|
Return the author of the source.
|
||||||
|
|
||||||
@param source: Source object
|
:param source: Source object
|
||||||
@type source: L{gen.lib.Source}
|
:type source: :py:class:`.Source`
|
||||||
@return: author of the source
|
:return: author of the source
|
||||||
@rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
assert(source is None or isinstance(source, Source))
|
assert(source is None or isinstance(source, Source))
|
||||||
if source:
|
if source:
|
||||||
@ -894,9 +896,10 @@ class SimpleAccess(object):
|
|||||||
"""
|
"""
|
||||||
Given a object_class, prop, and value return a display string
|
Given a object_class, prop, and value return a display string
|
||||||
describing object.
|
describing object.
|
||||||
object_class is "Person", "Source", etc.
|
|
||||||
prop is "gramps_id", or "handle"
|
:param object_class: "Person", "Source", etc.
|
||||||
value is a gramps_id or handle.
|
:param prop: "gramps_id", or "handle"
|
||||||
|
:param value: gramps_id or handle.
|
||||||
"""
|
"""
|
||||||
if object_class in self.dbase.get_table_names():
|
if object_class in self.dbase.get_table_names():
|
||||||
obj = self.dbase.get_table_metadata(object_class)\
|
obj = self.dbase.get_table_metadata(object_class)\
|
||||||
@ -996,9 +999,10 @@ class SimpleAccess(object):
|
|||||||
def get_link(self, object_class, prop, value):
|
def get_link(self, object_class, prop, value):
|
||||||
"""
|
"""
|
||||||
Given a object_class, prop, and value return the object.
|
Given a object_class, prop, and value return the object.
|
||||||
object_class is "Person", "Source", etc.
|
|
||||||
prop is "gramps_id", or "handle"
|
:param object_class: "Person", "Source", etc.
|
||||||
value is a gramps_id or handle.
|
:param prop: "gramps_id", or "handle"
|
||||||
|
:param value: gramps_id or handle.
|
||||||
"""
|
"""
|
||||||
if object_class in self.dbase.get_table_names():
|
if object_class in self.dbase.get_table_names():
|
||||||
return self.dbase.get_table_metadata(object_class) \
|
return self.dbase.get_table_metadata(object_class) \
|
||||||
@ -1006,16 +1010,15 @@ class SimpleAccess(object):
|
|||||||
|
|
||||||
def by_date(event1, event2):
|
def by_date(event1, event2):
|
||||||
"""
|
"""
|
||||||
DEPRECATED!
|
|
||||||
Sort function that will compare two events by their dates.
|
Sort function that will compare two events by their dates.
|
||||||
|
|
||||||
@param event1: first event
|
:param event1: first event
|
||||||
@type event1: L{Event}
|
:type event1: :py:class:`.Event`
|
||||||
@param event2: second event
|
:param event2: second event
|
||||||
@type event2: L{Event}
|
:type event2: :py:class:`.Event`
|
||||||
@return: Returns -1 if event1 < event2, 0 if they are equal, and
|
:return: Returns -1 if event1 < event2, 0 if they are equal, and
|
||||||
1 if they are the same.
|
1 if they are the same.
|
||||||
@rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
if event1 and event2:
|
if event1 and event2:
|
||||||
return cmp(event1.get_date_object() , event2.get_date_object())
|
return cmp(event1.get_date_object() , event2.get_date_object())
|
||||||
|
@ -21,14 +21,14 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Provide a simplified database access interface to the GRAMPS database.
|
Provide a simplified database access interface to the Gramps database.
|
||||||
"""
|
"""
|
||||||
from ..plug.docgen import StyleSheet, ParagraphStyle, TableStyle,\
|
from ..plug.docgen import StyleSheet, ParagraphStyle, TableStyle,\
|
||||||
TableCellStyle, FONT_SANS_SERIF, PARA_ALIGN_LEFT
|
TableCellStyle, FONT_SANS_SERIF, PARA_ALIGN_LEFT
|
||||||
|
|
||||||
class SimpleDoc(object):
|
class SimpleDoc(object):
|
||||||
"""
|
"""
|
||||||
Provide a simplified database access interface to the GRAMPS database.
|
Provide a simplified database access interface to the Gramps database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, doc):
|
def __init__(self, doc):
|
||||||
|
Loading…
Reference in New Issue
Block a user