2008-12-28 02:27:43 +05:30
|
|
|
# encoding: utf-8
|
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program - What Next Gramplet plugin
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Reinhard Mueller
|
2010-05-01 09:42:42 +05:30
|
|
|
# Copyright (C) 2010 Jakim Friant
|
2008-12-28 02:27:43 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2009-12-21 19:13:50 +05:30
|
|
|
# $Id$
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-09-17 08:43:19 +05:30
|
|
|
from gen.lib import EventType, FamilyRelType, MarkerType
|
2009-10-26 01:59:45 +05:30
|
|
|
from gen.plug import Gramplet
|
2010-01-14 09:38:04 +05:30
|
|
|
from gen.display.name import displayer as name_displayer
|
2010-05-01 09:42:42 +05:30
|
|
|
from gen.plug.report import utils as ReportUtils
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import sgettext as _
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# The Gramplet
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class WhatNextGramplet(Gramplet):
|
|
|
|
|
|
|
|
# Minimum number of lines we want to see. Further lines with the same
|
|
|
|
# distance to the main person will be added on top of this.
|
|
|
|
TODOS_WANTED = 10
|
|
|
|
|
|
|
|
# How many generations of descendants to process before we go up to the
|
|
|
|
# next level of ancestors.
|
|
|
|
DOWNS_PER_UP = 2
|
|
|
|
|
|
|
|
# After an ancestor was processed, how many extra rounds to delay until the
|
|
|
|
# descendants of this ancestor are processed.
|
|
|
|
ANCESTOR_DELAY = 1
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
# Use COMPLETE marker on a person to indicate that this person has no
|
|
|
|
# further marriages, if COMPLETE marker is not set, warn about this at the
|
|
|
|
# time the marriages for the person are processed.
|
|
|
|
PERSON_NEED_COMPLETE = False
|
|
|
|
|
|
|
|
# Use COMPLETE marker on a family to indicate that there are no further
|
|
|
|
# children in this family, if COMPLETE marker is not set, warn about this
|
|
|
|
# at the time the children of this family are processed.
|
|
|
|
FAMILY_NEED_COMPLETE = False
|
|
|
|
|
|
|
|
# Ignore all people and families with TODO_TYPE marker set. This way,
|
|
|
|
# hopeless cases can be marked separately and don't clutter up the list.
|
|
|
|
IGNORE_TODO = False
|
|
|
|
|
2008-12-28 02:27:43 +05:30
|
|
|
def init(self):
|
|
|
|
|
2009-01-08 04:19:58 +05:30
|
|
|
self.set_tooltip(_("Double-click name for details"))
|
2008-12-28 02:27:43 +05:30
|
|
|
self.set_text(_("No Family Tree loaded."))
|
|
|
|
|
|
|
|
|
|
|
|
def db_changed(self):
|
|
|
|
|
2008-12-29 19:45:20 +05:30
|
|
|
self.dbstate.db.connect('home-person-changed', self.update)
|
2008-12-28 02:27:43 +05:30
|
|
|
self.dbstate.db.connect('person-add', self.update)
|
|
|
|
self.dbstate.db.connect('person-delete', self.update)
|
|
|
|
self.dbstate.db.connect('person-update', self.update)
|
|
|
|
self.dbstate.db.connect('family-add', self.update)
|
|
|
|
self.dbstate.db.connect('family-delete', self.update)
|
|
|
|
self.dbstate.db.connect('family-update', self.update)
|
|
|
|
|
|
|
|
|
|
|
|
def main(self):
|
|
|
|
|
|
|
|
default_person = self.dbstate.db.get_default_person()
|
2009-02-24 00:41:46 +05:30
|
|
|
if default_person is None:
|
2008-12-28 02:27:43 +05:30
|
|
|
self.set_text(_("No Home Person set."))
|
|
|
|
return
|
|
|
|
|
|
|
|
self.__counter = 0
|
|
|
|
|
|
|
|
self.set_text("")
|
|
|
|
|
|
|
|
# List of already processed persons and families, to avoid recursing
|
|
|
|
# back down to ourselves or meeting the same person through different
|
|
|
|
# paths.
|
|
|
|
self.__processed_persons = {default_person.get_handle(): True}
|
|
|
|
self.__processed_families = {}
|
|
|
|
|
|
|
|
# List of lists of ancestors in currently processed generation. We go
|
|
|
|
# up one generation in each round.
|
|
|
|
# The lists are separated into my own ancestors, the ancestors of my
|
|
|
|
# spouses, the ancestors of my children's spouses, the ancestors of my
|
|
|
|
# parent's other spouses, the ancestors of my grandchildren's spouses,
|
|
|
|
# the ancestors of my sibling's spouses etc.
|
|
|
|
ancestors = [[default_person]]
|
2010-05-25 15:36:53 +05:30
|
|
|
ancestors_queue = ([[[default_person]]] +
|
2010-05-25 18:51:06 +05:30
|
|
|
[[] for i in range(self.ANCESTOR_DELAY)])
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
# List of lists of families of relatives in currently processed
|
|
|
|
# distance. We go up one level of distance in each round.
|
|
|
|
# For example, at the end of the third round, this is (potentially) a
|
|
|
|
# list of 4 lists:
|
|
|
|
# 1. my own great-grandchildren
|
|
|
|
# 2. grandchildren of my parents (= my nephews and nieces)
|
|
|
|
# 3. children of my grandparents (= my uncles and aunts)
|
|
|
|
# 4. my great-grandparents
|
|
|
|
# At the beginning of the fourth round, the other families of my
|
|
|
|
# great-grandparents are added (if they were married more than once).
|
|
|
|
# The separation into these levels is done to allow the spouses of the
|
|
|
|
# earlier level to be listed before the kins of the later level, e.g.
|
|
|
|
# the spouses of my nephews and nieces are listed before my uncles and
|
|
|
|
# aunts.
|
|
|
|
# Not that this may slightly vary with the parameters given at the
|
|
|
|
# beginning of this class definition, but the principle remains the
|
|
|
|
# same.
|
|
|
|
families = []
|
2010-01-27 17:37:25 +05:30
|
|
|
families_queue = [[] for i in range(self.ANCESTOR_DELAY)]
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
# List of spouses to add to ancestors list so we track ancestors of
|
|
|
|
# spouses, too, but delayed as defined by the parameter.
|
|
|
|
spouses = []
|
2010-05-25 15:36:53 +05:30
|
|
|
spouses_queue = []
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
while (ancestors or families):
|
|
|
|
# (Other) families of parents
|
|
|
|
for ancestor_group in ancestors_queue.pop(0):
|
|
|
|
new_family_group = []
|
|
|
|
new_spouses_group = []
|
|
|
|
for person in ancestor_group:
|
|
|
|
for family in self.__get_families(person):
|
|
|
|
spouse = self.__get_spouse(person, family)
|
2009-09-17 08:43:19 +05:30
|
|
|
if spouse is UnknownPerson:
|
2008-12-28 02:27:43 +05:30
|
|
|
self.__missing_spouse(person)
|
2009-09-17 08:43:19 +05:30
|
|
|
elif spouse is not None:
|
|
|
|
self.__process_person(spouse, new_spouses_group)
|
|
|
|
self.__process_family(family, person, spouse, new_family_group)
|
|
|
|
self.__process_person_2(person)
|
2008-12-28 02:27:43 +05:30
|
|
|
if new_family_group:
|
|
|
|
families.append(new_family_group)
|
|
|
|
if new_spouses_group:
|
|
|
|
spouses.append(new_spouses_group)
|
|
|
|
if self.__counter >= self.TODOS_WANTED:
|
|
|
|
break
|
|
|
|
|
|
|
|
# Next generation of children
|
|
|
|
for down in range(self.DOWNS_PER_UP):
|
|
|
|
new_families = []
|
|
|
|
for family_group in families:
|
|
|
|
children = []
|
2009-09-17 08:43:19 +05:30
|
|
|
for (family, person, spouse) in family_group:
|
2008-12-28 02:27:43 +05:30
|
|
|
for child in self.__get_children(family):
|
2009-09-17 08:43:19 +05:30
|
|
|
self.__process_person(child, children)
|
|
|
|
self.__process_family_2(family, person, spouse)
|
2008-12-28 02:27:43 +05:30
|
|
|
if self.__counter >= self.TODOS_WANTED:
|
|
|
|
break
|
|
|
|
|
|
|
|
# Families of children
|
|
|
|
new_family_group = []
|
|
|
|
new_spouses_group = []
|
|
|
|
for person in children:
|
|
|
|
for family in self.__get_families(person):
|
|
|
|
spouse = self.__get_spouse(person, family)
|
2009-09-17 08:43:19 +05:30
|
|
|
if spouse is UnknownPerson:
|
2008-12-28 02:27:43 +05:30
|
|
|
self.__missing_spouse(person)
|
2009-09-17 08:43:19 +05:30
|
|
|
elif spouse is not None:
|
|
|
|
self.__process_person(spouse, new_spouses_group)
|
|
|
|
self.__process_family(family, person, spouse, new_family_group)
|
|
|
|
self.__process_person_2(person)
|
2008-12-28 02:27:43 +05:30
|
|
|
if new_family_group:
|
|
|
|
new_families.append(new_family_group)
|
|
|
|
if new_spouses_group:
|
|
|
|
spouses.append(new_spouses_group)
|
|
|
|
if self.__counter >= self.TODOS_WANTED:
|
|
|
|
break
|
|
|
|
families = new_families
|
2010-05-25 15:36:53 +05:30
|
|
|
spouses_queue.append(spouses)
|
|
|
|
spouses = []
|
2008-12-28 02:27:43 +05:30
|
|
|
if self.__counter >= self.TODOS_WANTED:
|
|
|
|
break
|
|
|
|
if self.__counter >= self.TODOS_WANTED:
|
|
|
|
break
|
|
|
|
|
|
|
|
# Parents
|
|
|
|
new_ancestors = []
|
|
|
|
new_families = []
|
|
|
|
for ancestor_group in ancestors:
|
2009-09-17 08:43:19 +05:30
|
|
|
new_ancestor_group_1 = []
|
|
|
|
new_ancestor_group_2 = []
|
2008-12-28 02:27:43 +05:30
|
|
|
new_family_group = []
|
|
|
|
for person in ancestor_group:
|
|
|
|
(father, mother, family) = self.__get_parents(person)
|
2009-09-17 08:43:19 +05:30
|
|
|
if family is UnknownFamily:
|
|
|
|
self.__missing_parents(person)
|
|
|
|
elif family is not None:
|
|
|
|
if father is UnknownPerson:
|
2008-12-28 02:27:43 +05:30
|
|
|
self.__missing_father(person)
|
2009-09-17 08:43:19 +05:30
|
|
|
elif father is not None:
|
|
|
|
self.__process_person(father, new_ancestor_group_1)
|
|
|
|
if mother is UnknownPerson:
|
2008-12-28 02:27:43 +05:30
|
|
|
self.__missing_mother(person)
|
2009-09-17 08:43:19 +05:30
|
|
|
elif mother is not None:
|
|
|
|
if father is None:
|
|
|
|
self.__process_person(mother, new_ancestor_group_1)
|
|
|
|
else:
|
|
|
|
self.__process_person(mother, new_ancestor_group_2)
|
|
|
|
self.__process_family(family, father, mother, new_family_group)
|
|
|
|
if new_ancestor_group_1 or new_ancestor_group_2:
|
|
|
|
new_ancestors.append(new_ancestor_group_1 + new_ancestor_group_2)
|
2008-12-28 02:27:43 +05:30
|
|
|
if new_family_group:
|
|
|
|
new_families.append(new_family_group)
|
|
|
|
if self.__counter >= self.TODOS_WANTED:
|
|
|
|
break
|
2010-05-25 15:36:53 +05:30
|
|
|
ancestors = new_ancestors + spouses_queue.pop(0)
|
2008-12-28 02:27:43 +05:30
|
|
|
ancestors_queue.append(ancestors)
|
|
|
|
families_queue.append(new_families)
|
|
|
|
families += families_queue.pop(0)
|
|
|
|
if self.__counter >= self.TODOS_WANTED:
|
|
|
|
break
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
# Separator between rounds
|
|
|
|
if self.__counter > 0:
|
|
|
|
self.append_text("\n")
|
|
|
|
|
2008-12-28 02:27:43 +05:30
|
|
|
self.append_text("", scroll_to='begin')
|
|
|
|
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
def __process_person(self, person, append_list):
|
|
|
|
|
|
|
|
if person.get_handle() in self.__processed_persons:
|
|
|
|
return
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
self.__processed_persons[person.get_handle()] = True
|
|
|
|
|
|
|
|
missingbits = []
|
|
|
|
|
|
|
|
primary_name = person.get_primary_name()
|
|
|
|
|
|
|
|
if not primary_name.get_first_name():
|
|
|
|
missingbits.append(_("first name unknown"))
|
|
|
|
|
|
|
|
if not primary_name.get_surname():
|
|
|
|
missingbits.append(_("surname unknown"))
|
|
|
|
|
|
|
|
name = name_displayer.display_name(primary_name)
|
|
|
|
if not name:
|
|
|
|
name = _("(person with unknown name)")
|
|
|
|
|
|
|
|
has_birth = False
|
|
|
|
|
|
|
|
for event_ref in person.get_primary_event_ref_list():
|
|
|
|
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
|
|
if event.get_type() not in [EventType.BIRTH, EventType.DEATH]:
|
|
|
|
continue
|
|
|
|
missingbits.extend(self.__process_event(event))
|
|
|
|
if event.get_type() == EventType.BIRTH:
|
|
|
|
has_birth = True
|
|
|
|
|
|
|
|
if not has_birth:
|
|
|
|
missingbits.append(_("birth event missing"))
|
|
|
|
|
|
|
|
if missingbits:
|
|
|
|
self.link(name, 'Person', person.get_handle())
|
|
|
|
self.append_text(_(": %(list)s\n") % {
|
|
|
|
'list': _(", ").join(missingbits)})
|
|
|
|
self.__counter += 1
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
append_list.append(person)
|
|
|
|
|
|
|
|
|
|
|
|
def __process_person_2(self, person):
|
|
|
|
|
|
|
|
missingbits = []
|
|
|
|
|
|
|
|
primary_name = person.get_primary_name()
|
|
|
|
name = name_displayer.display_name(primary_name)
|
|
|
|
if not name:
|
|
|
|
name = _("(person with unknown name)")
|
|
|
|
|
|
|
|
if self.PERSON_NEED_COMPLETE and person.get_marker() != MarkerType.COMPLETE:
|
|
|
|
missingbits.append(_("person not complete"))
|
|
|
|
|
|
|
|
if missingbits:
|
|
|
|
self.link(name, 'Person', person.get_handle())
|
|
|
|
self.append_text(_(": %(list)s\n") % {
|
|
|
|
'list': _(", ").join(missingbits)})
|
|
|
|
self.__counter += 1
|
|
|
|
|
2008-12-28 02:27:43 +05:30
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
def __process_family(self, family, person1, person2, append_list):
|
|
|
|
|
|
|
|
if family.get_handle() in self.__processed_families:
|
|
|
|
return
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
self.__processed_families[family.get_handle()] = True
|
|
|
|
|
|
|
|
missingbits = []
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
if person1 is UnknownPerson or person1 is None:
|
|
|
|
name1 = _("(unknown person)")
|
|
|
|
else:
|
2008-12-28 02:27:43 +05:30
|
|
|
name1 = name_displayer.display(person1)
|
|
|
|
if not name1:
|
|
|
|
name1 = _("(person with unknown name)")
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
if person2 is UnknownPerson or person2 is None:
|
|
|
|
name2 = _("(unknown person)")
|
|
|
|
else:
|
2008-12-28 02:27:43 +05:30
|
|
|
name2 = name_displayer.display(person2)
|
|
|
|
if not name2:
|
|
|
|
name2 = _("(person with unknown name)")
|
|
|
|
|
|
|
|
name = _("%(name1)s and %(name2)s") % {
|
|
|
|
'name1': name1,
|
|
|
|
'name2': name2}
|
|
|
|
|
|
|
|
has_marriage = False
|
|
|
|
|
|
|
|
for event_ref in family.get_event_ref_list():
|
|
|
|
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
|
|
|
if event.get_type() not in [EventType.MARRIAGE, EventType.DIVORCE]:
|
|
|
|
continue
|
|
|
|
missingbits.extend(self.__process_event(event))
|
|
|
|
if event.get_type() == EventType.MARRIAGE:
|
|
|
|
has_marriage = True
|
|
|
|
|
|
|
|
if family.get_relationship() == FamilyRelType.MARRIED:
|
|
|
|
if not has_marriage:
|
|
|
|
missingbits.append(_("marriage event missing"))
|
|
|
|
elif family.get_relationship() == FamilyRelType.UNKNOWN:
|
|
|
|
missingbits.append(_("relation type unknown"))
|
|
|
|
|
|
|
|
if missingbits:
|
2008-12-31 09:30:55 +05:30
|
|
|
self.link(name, 'Family', family.get_handle())
|
2008-12-28 02:27:43 +05:30
|
|
|
self.append_text(_(": %(list)s\n") % {
|
|
|
|
'list': _(", ").join(missingbits)})
|
|
|
|
self.__counter += 1
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
append_list.append((family, person1, person2))
|
|
|
|
|
|
|
|
|
|
|
|
def __process_family_2(self, family, person1, person2):
|
|
|
|
|
|
|
|
missingbits = []
|
|
|
|
|
|
|
|
if person1 is UnknownPerson or person1 is None:
|
|
|
|
name1 = _("(unknown person)")
|
|
|
|
else:
|
|
|
|
name1 = name_displayer.display(person1)
|
|
|
|
if not name1:
|
|
|
|
name1 = _("(person with unknown name)")
|
|
|
|
|
|
|
|
if person2 is UnknownPerson or person2 is None:
|
|
|
|
name2 = _("(unknown person)")
|
|
|
|
else:
|
|
|
|
name2 = name_displayer.display(person2)
|
|
|
|
if not name2:
|
|
|
|
name2 = _("(person with unknown name)")
|
|
|
|
|
|
|
|
name = _("%(name1)s and %(name2)s") % {
|
|
|
|
'name1': name1,
|
|
|
|
'name2': name2}
|
|
|
|
|
|
|
|
if self.FAMILY_NEED_COMPLETE and family.get_marker() != MarkerType.COMPLETE:
|
|
|
|
missingbits.append(_("family not complete"))
|
|
|
|
|
|
|
|
if missingbits:
|
|
|
|
self.link(name, 'Family', family.get_handle())
|
|
|
|
self.append_text(_(": %(list)s\n") % {
|
|
|
|
'list': _(", ").join(missingbits)})
|
|
|
|
self.__counter += 1
|
|
|
|
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
def __process_event(self, event):
|
|
|
|
|
|
|
|
missingbits = []
|
|
|
|
|
|
|
|
date = event.get_date_object()
|
|
|
|
if date.is_empty():
|
|
|
|
missingbits.append(_("date unknown"))
|
|
|
|
elif not date.is_regular():
|
|
|
|
missingbits.append(_("date incomplete"))
|
|
|
|
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if not place_handle:
|
|
|
|
missingbits.append(_("place unknown"))
|
|
|
|
|
|
|
|
if missingbits:
|
|
|
|
return [_("%(type)s: %(list)s") % {
|
|
|
|
'type': event.get_type(),
|
|
|
|
'list': _(", ").join(missingbits)}]
|
|
|
|
else:
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
def __missing_spouse(self, person):
|
|
|
|
self.__missing_link(person, _("spouse missing"))
|
|
|
|
|
|
|
|
|
|
|
|
def __missing_father(self, person):
|
|
|
|
self.__missing_link(person, _("father missing"))
|
|
|
|
|
|
|
|
|
|
|
|
def __missing_mother(self, person):
|
|
|
|
self.__missing_link(person, _("mother missing"))
|
|
|
|
|
|
|
|
|
|
|
|
def __missing_parents(self, person):
|
|
|
|
self.__missing_link(person, _("parents missing"))
|
|
|
|
|
|
|
|
|
|
|
|
def __missing_link(self, person, text):
|
|
|
|
|
|
|
|
name = name_displayer.display(person)
|
|
|
|
self.link(name, 'Person', person.get_handle())
|
|
|
|
self.append_text(_(": %s\n") % text)
|
|
|
|
self.__counter += 1
|
|
|
|
|
|
|
|
|
|
|
|
def __get_spouse(self, person, family):
|
|
|
|
|
|
|
|
spouse_handle = ReportUtils.find_spouse(person, family)
|
|
|
|
if not spouse_handle:
|
2009-09-17 08:43:19 +05:30
|
|
|
if family.get_relationship() == FamilyRelType.MARRIED:
|
|
|
|
return UnknownPerson
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
spouse = self.dbstate.db.get_person_from_handle(spouse_handle)
|
|
|
|
if self.IGNORE_TODO and spouse.get_marker() == MarkerType.TODO_TYPE:
|
2008-12-28 02:27:43 +05:30
|
|
|
return None
|
2009-09-17 08:43:19 +05:30
|
|
|
else:
|
|
|
|
return spouse
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
|
|
|
|
def __get_children(self, family):
|
|
|
|
|
|
|
|
for child_ref in family.get_child_ref_list():
|
2009-09-17 08:43:19 +05:30
|
|
|
child = self.dbstate.db.get_person_from_handle(child_ref.ref)
|
|
|
|
if self.IGNORE_TODO and child.get_marker() == MarkerType.TODO_TYPE:
|
2008-12-28 02:27:43 +05:30
|
|
|
continue
|
2009-09-17 08:43:19 +05:30
|
|
|
yield child
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
|
|
|
|
def __get_families(self, person):
|
|
|
|
|
|
|
|
for family_handle in person.get_family_handle_list():
|
|
|
|
if family_handle in self.__processed_families:
|
|
|
|
continue
|
2009-09-17 08:43:19 +05:30
|
|
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
|
|
|
if self.IGNORE_TODO and family.get_marker() == MarkerType.TODO_TYPE:
|
|
|
|
continue
|
|
|
|
yield family
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
|
|
|
|
def __get_parents(self, person):
|
|
|
|
|
|
|
|
family_handle = person.get_main_parents_family_handle()
|
2009-09-17 08:43:19 +05:30
|
|
|
if not family_handle:
|
|
|
|
return (UnknownPerson, UnknownPerson, UnknownFamily)
|
|
|
|
if family_handle in self.__processed_families:
|
2008-12-28 02:27:43 +05:30
|
|
|
return (None, None, None)
|
|
|
|
|
|
|
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
2009-09-17 08:43:19 +05:30
|
|
|
if self.IGNORE_TODO and family.get_marker() == MarkerType.TODO_TYPE:
|
|
|
|
return (None, None, None)
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
father_handle = family.get_father_handle()
|
2009-09-17 08:43:19 +05:30
|
|
|
if not father_handle:
|
|
|
|
if family.get_relationship() == FamilyRelType.MARRIED:
|
|
|
|
father = UnknownPerson
|
|
|
|
else:
|
|
|
|
father = None
|
2008-12-28 02:27:43 +05:30
|
|
|
else:
|
2009-09-17 08:43:19 +05:30
|
|
|
father = self.dbstate.db.get_person_from_handle(father_handle)
|
|
|
|
if self.IGNORE_TODO and father.get_marker() == MarkerType.TODO_TYPE:
|
|
|
|
father = None
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
mother_handle = family.get_mother_handle()
|
2009-09-17 08:43:19 +05:30
|
|
|
if not mother_handle:
|
|
|
|
mother = UnknownPerson
|
2008-12-28 02:27:43 +05:30
|
|
|
else:
|
2009-09-17 08:43:19 +05:30
|
|
|
mother = self.dbstate.db.get_person_from_handle(mother_handle)
|
|
|
|
if self.IGNORE_TODO and mother.get_marker() == MarkerType.TODO_TYPE:
|
|
|
|
mother = None
|
2008-12-28 02:27:43 +05:30
|
|
|
|
|
|
|
return (father, mother, family)
|
|
|
|
|
|
|
|
|
2009-09-17 08:43:19 +05:30
|
|
|
class UnknownPersonClass(object):
|
|
|
|
pass
|
|
|
|
class UnknownFamilyClass(object):
|
|
|
|
pass
|
|
|
|
|
|
|
|
UnknownPerson = UnknownPersonClass()
|
|
|
|
UnknownFamily = UnknownFamilyClass()
|