2003-03-23 01:56:44 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-07-09 01:54:54 +05:30
|
|
|
# Copyright (C) 2003-2005 Donald N. Allingham
|
2003-03-23 01:56:44 +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
|
|
|
|
#
|
|
|
|
|
2004-01-23 20:14:28 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-03-23 01:56:44 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import RelLib
|
2004-02-17 10:17:24 +05:30
|
|
|
import types
|
2004-01-13 10:35:39 +05:30
|
|
|
from gettext import gettext as _
|
2005-07-09 01:54:54 +05:30
|
|
|
from Utils import strip_context as __
|
2003-03-23 01:56:44 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2003-04-30 05:54:32 +05:30
|
|
|
_level_name = [ "", "first", "second", "third", "fourth", "fifth", "sixth",
|
|
|
|
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth",
|
|
|
|
"thirteenth", "fourteenth", "fifteenth", "sixteenth",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth", "eighteenth", "nineteenth", "twentieth" ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_removed_level = [ "", " once removed", " twice removed", " three times removed",
|
|
|
|
" four times removed", " five times removed", " six times removed",
|
2005-07-09 01:54:54 +05:30
|
|
|
" sevent times removed", " eight times removed", " nine times removed",
|
2003-04-30 05:54:32 +05:30
|
|
|
" ten times removed", " eleven times removed", " twelve times removed",
|
|
|
|
" thirteen times removed", " fourteen times removed", " fifteen times removed",
|
|
|
|
" sixteen times removed", " seventeen times removed", " eighteen times removed",
|
|
|
|
" nineteen times removed", " twenty times removed" ]
|
|
|
|
|
2003-08-11 08:27:12 +05:30
|
|
|
_parents_level = [ "", "parents", "grandparents", "great grandparents", "second great grandparents",
|
|
|
|
"third great grandparents", "fourth great grandparents",
|
|
|
|
"fifth great grandparents", "sixth great grandparents",
|
|
|
|
"seventh great grandparents", "eighth great grandparents",
|
|
|
|
"ninth great grandparents", "tenth great grandparents",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great grandparents", "twelfth great grandparents",
|
2003-08-11 08:27:12 +05:30
|
|
|
"thirteenth great grandparents", "fourteenth great grandparents",
|
|
|
|
"fifteenth great grandparents", "sixteenth great grandparents",
|
|
|
|
"seventeenth great grandparents", "eighteenth great grandparents",
|
|
|
|
"nineteenth great grandparents", "twentieth great grandparents", ]
|
|
|
|
|
2003-04-30 05:54:32 +05:30
|
|
|
_father_level = [ "", "father", "grandfather", "great grandfather", "second great grandfather",
|
|
|
|
"third great grandfather", "fourth great grandfather",
|
|
|
|
"fifth great grandfather", "sixth great grandfather",
|
|
|
|
"seventh great grandfather", "eighth great grandfather",
|
|
|
|
"ninth great grandfather", "tenth great grandfather",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great grandfather", "twelfth great grandfather",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great grandfather", "fourteenth great grandfather",
|
|
|
|
"fifteenth great grandfather", "sixteenth great grandfather",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great grandfather", "eighteenth great grandfather",
|
|
|
|
"nineteenth great grandfather", "twentieth great grandfather", ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_mother_level = [ "", "mother", "grandmother", "great grandmother", "second great grandmother",
|
|
|
|
"third great grandmother", "fourth great grandmother",
|
|
|
|
"fifth great grandmother", "sixth great grandmother",
|
|
|
|
"seventh great grandmother", "eighth great grandmother",
|
|
|
|
"ninth great grandmother", "tenth great grandmother",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great grandmother", "twelfth great grandmother",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great grandmother", "fourteenth great grandmother",
|
|
|
|
"fifteenth great grandmother", "sixteenth great grandmother",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great grandmother", "eighteenth great grandmother",
|
|
|
|
"nineteenth great grandmother", "twentieth great grandmother", ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_son_level = [ "", "son", "grandson", "great grandson", "second great grandson",
|
|
|
|
"third great grandson", "fourth great grandson",
|
|
|
|
"fifth great grandson", "sixth great grandson",
|
|
|
|
"seventh great grandson", "eighth great grandson",
|
|
|
|
"ninth great grandson", "tenth great grandson",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great grandson", "twelfth great grandson",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great grandson", "fourteenth great grandson",
|
|
|
|
"fifteenth great grandson", "sixteenth great grandson",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great grandson", "eighteenth great grandson",
|
|
|
|
"nineteenth great grandson", "twentieth great grandson", ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_daughter_level = [ "", "daughter", "granddaughter", "great granddaughter",
|
|
|
|
"second great granddaughter",
|
|
|
|
"third great granddaughter", "fourth great granddaughter",
|
|
|
|
"fifth great granddaughter", "sixth great granddaughter",
|
|
|
|
"seventh great granddaughter", "eighth great granddaughter",
|
|
|
|
"ninth great granddaughter", "tenth great granddaughter",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great granddaughter", "twelfth great granddaughter",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great granddaughter", "fourteenth great granddaughter",
|
|
|
|
"fifteenth great granddaughter", "sixteenth great granddaughter",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great granddaughter", "eighteenth great granddaughter",
|
|
|
|
"nineteenth great granddaughter", "twentieth great granddaughter", ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_sister_level = [ "", "sister", "aunt", "grandaunt", "great grandaunt", "second great grandaunt",
|
|
|
|
"third great grandaunt", "fourth great grandaunt",
|
|
|
|
"fifth great grandaunt", "sixth great grandaunt",
|
|
|
|
"seventh great grandaunt", "eighth great grandaunt",
|
|
|
|
"ninth great grandaunt", "tenth great grandaunt",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great grandaunt", "twelfth great grandaunt",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great grandaunt", "fourteenth great grandaunt",
|
|
|
|
"fifteenth great grandaunt", "sixteenth great grandaunt",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great grandaunt", "eighteenth great grandaunt",
|
|
|
|
"nineteenth great grandaunt", "twentieth great grandaunt", ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_brother_level = [ "", "brother", "uncle", "granduncle", "great granduncle", "second great granduncle",
|
|
|
|
"third great granduncle", "fourth great granduncle",
|
|
|
|
"fifth great granduncle", "sixth great granduncle",
|
|
|
|
"seventh great granduncle", "eighth great granduncle",
|
|
|
|
"ninth great granduncle", "tenth great granduncle",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great granduncle", "twelfth great granduncle",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great granduncle", "fourteenth great granduncle",
|
|
|
|
"fifteenth great granduncle", "sixteenth great granduncle",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great granduncle", "eighteenth great granduncle",
|
|
|
|
"nineteenth great granduncle", "twentieth great granduncle", ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_nephew_level = [ "", "nephew", "grandnephew", "great grandnephew", "second great grandnephew",
|
|
|
|
"third great grandnephew", "fourth great grandnephew",
|
|
|
|
"fifth great grandnephew", "sixth great grandnephew",
|
|
|
|
"seventh great grandnephew", "eighth great grandnephew",
|
|
|
|
"ninth great grandnephew", "tenth great grandnephew",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great grandnephew", "twelfth great grandnephew",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great grandnephew", "fourteenth great grandnephew",
|
|
|
|
"fifteenth great grandnephew", "sixteenth great grandnephew",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great grandnephew", "eighteenth great grandnephew",
|
|
|
|
"nineteenth great grandnephew", "twentieth great grandnephew", ]
|
2003-04-30 05:54:32 +05:30
|
|
|
|
|
|
|
_niece_level = [ "", "niece", "grandniece", "great grandniece", "second great grandniece",
|
|
|
|
"third great grandniece", "fourth great grandniece",
|
|
|
|
"fifth great grandniece", "sixth great grandniece",
|
|
|
|
"seventh great grandniece", "eighth great grandniece",
|
|
|
|
"ninth great grandniece", "tenth great grandniece",
|
2003-09-10 19:13:47 +05:30
|
|
|
"eleventh great grandniece", "twelfth great grandniece",
|
2003-04-30 05:54:32 +05:30
|
|
|
"thirteenth great grandniece", "fourteenth great grandniece",
|
|
|
|
"fifteenth great grandniece", "sixteenth great grandniece",
|
2003-07-10 22:33:04 +05:30
|
|
|
"seventeenth great grandniece", "eighteenth great grandniece",
|
|
|
|
"nineteenth great grandniece", "twentieth great grandniece", ]
|
2003-03-23 01:56:44 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-02-14 11:10:30 +05:30
|
|
|
|
|
|
|
class RelationshipCalculator:
|
|
|
|
|
|
|
|
def __init__(self,db):
|
|
|
|
self.db = db
|
|
|
|
|
2004-02-16 04:40:12 +05:30
|
|
|
def set_db(self,db):
|
|
|
|
self.db = db
|
|
|
|
|
2004-08-21 00:40:01 +05:30
|
|
|
def apply_filter(self,person,rel_str,plist,pmap):
|
2004-02-16 04:40:12 +05:30
|
|
|
if person == None:
|
2004-02-14 11:10:30 +05:30
|
|
|
return
|
2004-07-28 07:59:07 +05:30
|
|
|
plist.append(person.get_handle())
|
2004-08-21 00:40:01 +05:30
|
|
|
pmap[person.get_handle()] = rel_str
|
2004-02-14 11:10:30 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle = person.get_main_parents_family_handle()
|
2005-04-23 21:23:30 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
if family_handle != None and family:
|
2004-08-07 10:46:57 +05:30
|
|
|
father = self.db.get_person_from_handle(family.get_father_handle())
|
|
|
|
mother = self.db.get_person_from_handle(family.get_mother_handle())
|
2004-08-21 00:40:01 +05:30
|
|
|
self.apply_filter(father,rel_str+'f',plist,pmap)
|
|
|
|
self.apply_filter(mother,rel_str+'m',plist,pmap)
|
2004-02-14 11:10:30 +05:30
|
|
|
|
|
|
|
def get_cousin(self,level,removed):
|
|
|
|
if removed > len(_removed_level)-1 or level>len(_level_name)-1:
|
|
|
|
return "distant relative"
|
|
|
|
else:
|
|
|
|
return "%s cousin%s" % (_level_name[level],_removed_level[removed])
|
|
|
|
|
|
|
|
def get_parents(self,level):
|
|
|
|
if level>len(_parents_level)-1:
|
|
|
|
return "distant ancestors"
|
2003-03-23 01:56:44 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
return _parents_level[level]
|
|
|
|
|
|
|
|
def get_father(self,level):
|
|
|
|
if level>len(_father_level)-1:
|
|
|
|
return "distant ancestor"
|
2003-03-23 01:56:44 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
return _father_level[level]
|
|
|
|
|
|
|
|
def get_son(self,level):
|
|
|
|
if level>len(_son_level)-1:
|
|
|
|
return "distant descendant"
|
2003-03-23 01:56:44 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
return _son_level[level]
|
|
|
|
|
|
|
|
def get_mother(self,level):
|
|
|
|
if level>len(_mother_level)-1:
|
|
|
|
return "distant ancestor"
|
2003-03-23 01:56:44 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
return _mother_level[level]
|
|
|
|
|
|
|
|
def get_daughter(self,level):
|
|
|
|
if level>len(_daughter_level)-1:
|
|
|
|
return "distant descendant"
|
|
|
|
else:
|
|
|
|
return _daughter_level[level]
|
|
|
|
|
|
|
|
def get_aunt(self,level):
|
|
|
|
if level>len(_sister_level)-1:
|
|
|
|
return "distant ancestor"
|
|
|
|
else:
|
|
|
|
return _sister_level[level]
|
|
|
|
|
|
|
|
def get_uncle(self,level):
|
|
|
|
if level>len(_brother_level)-1:
|
|
|
|
return "distant ancestor"
|
|
|
|
else:
|
|
|
|
return _brother_level[level]
|
|
|
|
|
|
|
|
def get_nephew(self,level):
|
|
|
|
if level>len(_nephew_level)-1:
|
|
|
|
return "distant descendant"
|
|
|
|
else:
|
|
|
|
return _nephew_level[level]
|
|
|
|
|
|
|
|
def get_niece(self,level):
|
|
|
|
if level>len(_niece_level)-1:
|
|
|
|
return "distant descendant"
|
|
|
|
else:
|
|
|
|
return _niece_level[level]
|
|
|
|
|
|
|
|
def is_spouse(self,orig,other):
|
2004-07-28 07:59:07 +05:30
|
|
|
for f in orig.get_family_handle_list():
|
2004-08-20 03:05:16 +05:30
|
|
|
family = self.db.get_family_from_handle(f)
|
2005-07-09 01:54:54 +05:30
|
|
|
if family and other.get_handle() in [family.get_father_handle(),
|
|
|
|
family.get_mother_handle()]:
|
|
|
|
family_rel = family.get_relationship()
|
|
|
|
# Determine person's gender
|
|
|
|
if other.get_gender() == RelLib.Person.MALE:
|
|
|
|
gender = RelLib.Person.MALE
|
|
|
|
elif other.get_gender() == RelLib.Person.FEMALE:
|
|
|
|
gender = RelLib.Person.FEMALE
|
|
|
|
# Person's gender is unknown, try guessing from spouse's
|
|
|
|
elif orig.get_gender() == RelLib.Person.MALE:
|
|
|
|
if family_rel == RelLib.Family.CIVIL_UNION:
|
|
|
|
gender = RelLib.Person.MALE
|
|
|
|
else:
|
|
|
|
gender = RelLib.Person.FEMALE
|
|
|
|
elif orig.get_gender() == RelLib.Person.FEMALE:
|
|
|
|
if family_rel == RelLib.Family.CIVIL_UNION:
|
|
|
|
gender = RelLib.Person.FEMALE
|
|
|
|
else:
|
|
|
|
gender = RelLib.Person.MALE
|
|
|
|
else:
|
|
|
|
gender = RelLib.Person.UNKNOWN
|
|
|
|
|
|
|
|
if family_rel == RelLib.Family.MARRIED:
|
|
|
|
if gender == RelLib.Person.MALE:
|
|
|
|
return _("husband")
|
|
|
|
elif gender == RelLib.Person.FEMALE:
|
|
|
|
return _("wife")
|
|
|
|
else:
|
|
|
|
return __("gender unknown|spouse")
|
|
|
|
elif family_rel == RelLib.Family.UNMARRIED:
|
|
|
|
if gender == RelLib.Person.MALE:
|
|
|
|
return __("unmarried|husband")
|
|
|
|
elif gender == RelLib.Person.FEMALE:
|
|
|
|
return __("unmarried|wife")
|
|
|
|
else:
|
|
|
|
return __("gender unknown,unmarried|spouse")
|
|
|
|
elif family_rel == RelLib.Family.CIVIL_UNION:
|
|
|
|
if gender == RelLib.Person.MALE:
|
|
|
|
return __("male,civil union|partner")
|
|
|
|
elif gender == RelLib.Person.FEMALE:
|
|
|
|
return __("female,civil union|partner")
|
|
|
|
else:
|
|
|
|
return __("gender unknown,civil union|partner")
|
|
|
|
else:
|
|
|
|
if gender == RelLib.Person.MALE:
|
|
|
|
return __("male,unknown relation|partner")
|
|
|
|
elif gender == RelLib.Person.FEMALE:
|
|
|
|
return __("female,unknown relation|partner")
|
|
|
|
else:
|
|
|
|
return __("gender unknown,unknown relation|partner")
|
2004-02-14 11:10:30 +05:30
|
|
|
else:
|
2005-07-09 01:54:54 +05:30
|
|
|
return None
|
|
|
|
return None
|
2004-02-14 11:10:30 +05:30
|
|
|
|
2004-02-17 10:17:24 +05:30
|
|
|
def get_relationship_distance(self,orig_person,other_person):
|
2004-02-14 11:10:30 +05:30
|
|
|
"""
|
2004-02-17 10:17:24 +05:30
|
|
|
Returns a tuple (firstRel,secondRel,common):
|
|
|
|
|
|
|
|
firstRel Number of generations from the orig_person to their
|
|
|
|
closest common ancestor
|
|
|
|
secondRel Number of generations from the other_person to their
|
|
|
|
closest common ancestor
|
|
|
|
common list of their common ancestors, the closest is the first
|
|
|
|
|
|
|
|
is returned
|
2004-02-14 11:10:30 +05:30
|
|
|
"""
|
2004-02-17 10:17:24 +05:30
|
|
|
|
|
|
|
firstRel = -1
|
|
|
|
secondRel = -1
|
|
|
|
common = []
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
firstMap = {}
|
|
|
|
firstList = []
|
|
|
|
secondMap = {}
|
|
|
|
secondList = []
|
|
|
|
rank = 9999999
|
2004-02-16 04:40:12 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
try:
|
2004-08-21 00:40:01 +05:30
|
|
|
self.apply_filter(orig_person,'',firstList,firstMap)
|
|
|
|
self.apply_filter(other_person,'',secondList,secondMap)
|
2004-08-20 17:41:56 +05:30
|
|
|
except RuntimeError:
|
2004-02-17 10:17:24 +05:30
|
|
|
return (firstRel,secondRel,_("Relationship loop detected"))
|
2004-02-16 04:40:12 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in firstList:
|
|
|
|
if person_handle in secondList:
|
2004-08-21 00:40:01 +05:30
|
|
|
new_rank = len(firstMap[person_handle])
|
2004-02-14 11:10:30 +05:30
|
|
|
if new_rank < rank:
|
|
|
|
rank = new_rank
|
2004-07-28 07:59:07 +05:30
|
|
|
common = [ person_handle ]
|
2004-02-14 11:10:30 +05:30
|
|
|
elif new_rank == rank:
|
2004-07-28 07:59:07 +05:30
|
|
|
common.append(person_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
|
2004-02-16 02:58:31 +05:30
|
|
|
if common:
|
2004-07-28 07:59:07 +05:30
|
|
|
person_handle = common[0]
|
|
|
|
secondRel = firstMap[person_handle]
|
|
|
|
firstRel = secondMap[person_handle]
|
2004-02-16 04:40:12 +05:30
|
|
|
|
2004-02-17 10:17:24 +05:30
|
|
|
return (firstRel,secondRel,common)
|
|
|
|
|
|
|
|
def get_relationship(self,orig_person,other_person):
|
|
|
|
"""
|
|
|
|
returns a string representping the relationshp between the two people,
|
|
|
|
along with a list of common ancestors (typically father,mother)
|
|
|
|
"""
|
|
|
|
|
|
|
|
if orig_person == None:
|
|
|
|
return ("undefined",[])
|
|
|
|
|
2004-08-21 09:30:53 +05:30
|
|
|
if orig_person.get_handle() == other_person.get_handle():
|
2004-02-17 10:17:24 +05:30
|
|
|
return ('', [])
|
|
|
|
|
2005-07-09 01:54:54 +05:30
|
|
|
is_spouse = self.is_spouse(orig_person,other_person)
|
|
|
|
if is_spouse:
|
|
|
|
return (is_spouse,[])
|
2004-02-17 10:17:24 +05:30
|
|
|
|
|
|
|
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
|
|
|
|
|
|
|
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
|
|
|
return (common,[])
|
|
|
|
elif common:
|
2004-07-28 07:59:07 +05:30
|
|
|
person_handle = common[0]
|
2004-02-17 10:17:24 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
return ("",[])
|
2004-02-17 10:17:24 +05:30
|
|
|
|
2004-08-21 00:40:01 +05:30
|
|
|
firstRel = len(firstRel)
|
|
|
|
secondRel = len(secondRel)
|
|
|
|
|
2004-02-17 10:17:24 +05:30
|
|
|
if firstRel == 0:
|
2004-02-14 11:10:30 +05:30
|
|
|
if secondRel == 0:
|
|
|
|
return ('',common)
|
2005-05-31 02:11:43 +05:30
|
|
|
elif other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-14 11:10:30 +05:30
|
|
|
return (self.get_father(secondRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_mother(secondRel),common)
|
|
|
|
elif secondRel == 0:
|
2005-05-31 02:11:43 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-14 11:10:30 +05:30
|
|
|
return (self.get_son(firstRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_daughter(firstRel),common)
|
|
|
|
elif firstRel == 1:
|
2005-05-31 02:11:43 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-14 11:10:30 +05:30
|
|
|
return (self.get_uncle(secondRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_aunt(secondRel),common)
|
|
|
|
elif secondRel == 1:
|
2005-05-31 02:11:43 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-14 11:10:30 +05:30
|
|
|
return (self.get_nephew(firstRel-1),common)
|
|
|
|
else:
|
|
|
|
return (self.get_niece(firstRel-1),common)
|
2003-03-23 01:56:44 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
if secondRel > firstRel:
|
|
|
|
return (self.get_cousin(firstRel-1,secondRel-firstRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_cousin(secondRel-1,firstRel-secondRel),common)
|
|
|
|
|
2004-02-16 02:58:31 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
def get_grandparents_string(self,orig_person,other_person):
|
|
|
|
"""
|
|
|
|
returns a string representing the relationshp between the two people,
|
|
|
|
along with a list of common ancestors (typically father,mother)
|
|
|
|
"""
|
|
|
|
if orig_person == None:
|
|
|
|
return ("undefined",[])
|
|
|
|
|
|
|
|
if orig_person == other_person:
|
|
|
|
return ('', [])
|
|
|
|
|
2004-02-17 10:17:24 +05:30
|
|
|
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
|
|
|
|
|
|
|
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
|
|
|
return (common,[])
|
|
|
|
elif common:
|
2004-07-28 07:59:07 +05:30
|
|
|
person_handle = common[0]
|
2004-02-17 10:17:24 +05:30
|
|
|
else:
|
|
|
|
return ("",[])
|
|
|
|
|
2004-08-21 00:40:01 +05:30
|
|
|
if len(firstRel) == 0:
|
|
|
|
if len(secondRel) == 0:
|
2004-02-14 11:10:30 +05:30
|
|
|
return ('',common)
|
|
|
|
else:
|
2004-08-21 00:40:01 +05:30
|
|
|
return (self.get_parents(len(secondRel)),common)
|
2003-08-11 08:27:12 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
return None
|