0002006: Ancestor filter does not work properly with living people excluded in Narrative Web report.

svn: r10610
This commit is contained in:
Brian Matherly 2008-04-20 23:35:39 +00:00
parent 2c2abb6b7c
commit 6a06a88442

View File

@ -24,6 +24,13 @@
Proxy class for the GRAMPS databases. Filter out all living people. Proxy class for the GRAMPS databases. Filter out all living people.
""" """
#-------------------------------------------------------------------------
#
# Python libraries
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS libraries # GRAMPS libraries
@ -46,16 +53,16 @@ class LivingProxyDb(ProxyDbBase):
MODE_EXCLUDE = 0 MODE_EXCLUDE = 0
MODE_RESTRICT = 1 MODE_RESTRICT = 1
def __init__(self,db,mode,current_year=None,years_after_death=0): def __init__(self, dbase, mode, current_year=None, years_after_death=0):
""" """
Create a new LivingProxyDb instance. Create a new LivingProxyDb instance.
@param db: The database to be a proxy for @param dbase: The database to be a proxy for
@type db: DbBase @type dbase: DbBase
@param mode: The method for handling living people. @param mode: The method for handling living people.
LivingProxyDb.MODE_EXCLUDE will remove living people altogether. LivingProxyDb.MODE_EXCLUDE will remove living people altogether.
LivingProxyDb.MODE_RESTRICT will remove all information and change their LivingProxyDb.MODE_RESTRICT will remove all information and change
given name to "Living". their given name to "Living".
@type mode: int @type mode: int
@param current_year: The current year to use for living determination. @param current_year: The current year to use for living determination.
If None is supplied, the current year will be found from the system. If None is supplied, the current year will be found from the system.
@ -64,7 +71,7 @@ class LivingProxyDb(ProxyDbBase):
still consider them living. still consider them living.
@type years_after_death: int @type years_after_death: int
""" """
ProxyDbBase.__init__(self, db) ProxyDbBase.__init__(self, dbase)
self.mode = mode self.mode = mode
if current_year != None: if current_year != None:
self.current_date = Date() self.current_date = Date()
@ -364,13 +371,26 @@ class LivingProxyDb(ProxyDbBase):
yield (class_name, handle) yield (class_name, handle)
return return
def __is_living(self,person): def __is_living(self, person):
"""
Check if a person is considered living.
Returns True if the person is considered living.
Returns False if the person is not considered living.
"""
return probably_alive( person, return probably_alive( person,
self.db, self.db,
self.current_date, self.current_date,
self.years_after_death ) self.years_after_death )
def __remove_living_from_family(self,family): def __remove_living_from_family(self, family):
"""
Remove information from a family that pertains to living people.
Returns a family instance with information about living people removed.
Returns None if family is None.
"""
if family is None:
return None
parent_is_living = False parent_is_living = False
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
@ -403,6 +423,9 @@ class LivingProxyDb(ProxyDbBase):
return family return family
def _restrict_person(person): def _restrict_person(person):
"""
Remove information from a person and replace the first name with "Living".
"""
new_person = Person() new_person = Person()
new_name = Name() new_name = Name()
old_name = person.get_primary_name() old_name = person.get_primary_name()