2003-08-15 04:03:30 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
2003-04-30 09:51:04 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-02-06 10:28:11 +05:30
|
|
|
# Copyright (C) 2003-2004 Donald N. Allingham
|
2003-04-30 09:51:04 +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-02-06 10:28:11 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-04-30 09:51:04 +05:30
|
|
|
# Written by Alex Roitman, largely based on Relationship.py by Don Allingham.
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import RelLib
|
2004-02-15 12:38:55 +05:30
|
|
|
import Relationship
|
2004-02-17 10:17:24 +05:30
|
|
|
import types
|
2004-02-16 04:14:50 +05:30
|
|
|
from gettext import gettext as _
|
2003-04-30 09:51:04 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2003-04-30 18:53:25 +05:30
|
|
|
# Russian-specific definitions of relationships
|
2003-04-30 09:51:04 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2004-02-16 08:04:50 +05:30
|
|
|
_parents_level = [ "", "родители",
|
|
|
|
"дедушки/бабушки", "прадедушки/прабабушки", "прапрадедушки/прапрабабушки",
|
|
|
|
]
|
|
|
|
|
2003-05-30 05:31:38 +05:30
|
|
|
_male_cousin_level = [
|
|
|
|
"", "двоюродный", "троюродный", "четвероюродный",
|
|
|
|
"пятиюродный", "шестиюродный", "семиюродный", "восьмиюродный",
|
|
|
|
"девятиюродный", "десятиюродный", "одиннацатиюродный", "двенадцатиюродный",
|
|
|
|
"тринадцатиюродный", "четырнадцатиюродный", "пятнадцатиюродный", "шестнадцатиюродный",
|
|
|
|
"семнадцатиюродный", "восемнадцатиюродный", "девятнадцатиюродный","двадцатиюродный" ]
|
|
|
|
|
|
|
|
_female_cousin_level = [
|
|
|
|
"", "двоюродная", "троюродная", "четвероюродная",
|
|
|
|
"пятиюродная", "шестиюродная", "семиюродная", "восьмиюродная",
|
|
|
|
"девятиюродная", "десятиюродная", "одиннацатиюродная", "двенадцатиюродная",
|
|
|
|
"тринадцатиюродная", "четырнадцатиюродная", "пятнадцатиюродная", "шестнадцатиюродная",
|
|
|
|
"семнадцатиюродная", "восемнадцатиюродная", "девятнадцатиюродная","двадцатиюродная" ]
|
|
|
|
|
|
|
|
_junior_male_removed_level = [
|
|
|
|
"брат", "племянник", "внучатый племянник", "правнучатый племянник",
|
|
|
|
"праправнучатый племянник", "прапраправнучатый племянник",
|
|
|
|
"прапрапраправнучатый племянник" ]
|
|
|
|
|
|
|
|
_junior_female_removed_level = [
|
|
|
|
"сестра", "племянница", "внучатая племянница", "правнучатая племянница",
|
|
|
|
"праправнучатая племянница", "прапраправнучатая племянница",
|
|
|
|
"прапрапраправнучатая племянница" ]
|
|
|
|
|
|
|
|
_senior_male_removed_level = [
|
|
|
|
"", "дядя", "дед", "прадед", "прапрадед", "прапрапрадед","прапрапрапрадед" ]
|
|
|
|
|
|
|
|
_senior_female_removed_level = [
|
|
|
|
"", "тетка", "бабка", "прабабка", "прапрабабка", "прапрапрабабка","прапрапрапрабабка" ]
|
|
|
|
|
|
|
|
_father_level = [
|
|
|
|
"", "отец", "дед", "прадед", "прапрадед", "прапрапрадед", "прапрапрапрадед" ]
|
|
|
|
|
|
|
|
_mother_level = [
|
|
|
|
"", "мать", "бабка", "прабабка", "прапрабабка", "прапрапрабабка", "прапрапрапрабабка" ]
|
|
|
|
|
|
|
|
_son_level = [
|
|
|
|
"", "сын", "внук", "правнук", "праправнук", "прапраправнук", "прапрапраправнук" ]
|
|
|
|
|
|
|
|
_daughter_level = [
|
|
|
|
"", "дочь", "внучка", "правнучка", "праправнучка", "прапраправнучка",
|
|
|
|
"прапрапраправнучка" ]
|
|
|
|
|
|
|
|
_sister_level = [
|
|
|
|
"", "сестра", "тетка", "двоюродная бабка", "двоюродная прабабка",
|
|
|
|
"двоюродная прапрабабка", "двоюродная прапрапрабабка", "двоюродная прапрапрапрабабка" ]
|
|
|
|
|
|
|
|
_brother_level = [
|
|
|
|
"", "брат", "дядя", "двоюродный дед", "двоюродный прадед",
|
|
|
|
"двоюродный прапрадед", "двоюродный прапрапрадед", "двоюродный прапрапрапрадед" ]
|
|
|
|
|
|
|
|
_nephew_level = [
|
|
|
|
"", "племянник", "внучатый племянник", "правнучатый племянник",
|
|
|
|
"праправнучатый племянник", "прапраправнучатый племянник",
|
|
|
|
"прапрапраправнучатый племянник" ]
|
|
|
|
|
|
|
|
_niece_level = [
|
|
|
|
"", "племянница", "внучатая племянница", "правнучатая племянница",
|
|
|
|
"праправнучатая племянница", "прапраправнучатая племянница",
|
|
|
|
"прапрапраправнучатая племянница" ]
|
2003-04-30 09:51:04 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-02-15 12:38:55 +05:30
|
|
|
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
2003-04-30 09:51:04 +05:30
|
|
|
|
2004-02-15 12:38:55 +05:30
|
|
|
def __init__(self,db):
|
|
|
|
Relationship.RelationshipCalculator.__init__(self,db)
|
2003-04-30 09:51:04 +05:30
|
|
|
|
2004-02-16 08:04:50 +05:30
|
|
|
def get_parents(self,level):
|
|
|
|
if level>len(_parents_level)-1:
|
|
|
|
return _("remote ancestors")
|
|
|
|
else:
|
|
|
|
return _parents_level[level]
|
|
|
|
|
2004-02-15 12:38:55 +05:30
|
|
|
def get_junior_male_cousin(self,level,removed):
|
|
|
|
if removed > len(_junior_male_removed_level)-1 or level>len(_male_cousin_level)-1:
|
|
|
|
return "дальний родственник"
|
|
|
|
else:
|
|
|
|
return "%s %s" % (_male_cousin_level[level],_junior_male_removed_level[removed])
|
|
|
|
|
|
|
|
def get_senior_male_cousin(self,level,removed):
|
|
|
|
if removed > len(_senior_male_removed_level)-1 or level>len(_male_cousin_level)-1:
|
|
|
|
return "дальний родственник"
|
|
|
|
else:
|
|
|
|
return "%s %s" % (_male_cousin_level[level],_senior_male_removed_level[removed])
|
|
|
|
|
|
|
|
def get_junior_female_cousin(self,level,removed):
|
|
|
|
if removed > len(_junior_female_removed_level)-1 or level>len(_male_cousin_level)-1:
|
|
|
|
return "дальняя родственница"
|
|
|
|
else:
|
|
|
|
return "%s %s" % (_female_cousin_level[level],_junior_female_removed_level[removed])
|
|
|
|
|
|
|
|
def get_senior_female_cousin(self,level,removed):
|
|
|
|
if removed > len(_senior_female_removed_level)-1 or level>len(_male_cousin_level)-1:
|
|
|
|
return "дальняя родственница"
|
|
|
|
else:
|
|
|
|
return "%s %s" % (_female_cousin_level[level],_senior_female_removed_level[removed])
|
|
|
|
|
|
|
|
def get_father(self,level):
|
|
|
|
if level>len(_father_level)-1:
|
|
|
|
return "дальний предок"
|
2003-04-30 09:51:04 +05:30
|
|
|
else:
|
2004-02-15 12:38:55 +05:30
|
|
|
return _father_level[level]
|
|
|
|
|
|
|
|
def get_son(self,level):
|
|
|
|
if level>len(_son_level)-1:
|
|
|
|
return "дальний потомок"
|
|
|
|
else:
|
|
|
|
return _son_level[level]
|
|
|
|
|
|
|
|
def get_mother(self,level):
|
|
|
|
if level>len(_mother_level)-1:
|
|
|
|
return "дальний предок"
|
|
|
|
else:
|
|
|
|
return _mother_level[level]
|
|
|
|
|
|
|
|
def get_daughter(self,level):
|
|
|
|
if level>len(_daughter_level)-1:
|
|
|
|
return "дальний потомок"
|
2003-04-30 09:51:04 +05:30
|
|
|
else:
|
2004-02-15 12:38:55 +05:30
|
|
|
return _daughter_level[level]
|
|
|
|
|
|
|
|
def get_aunt(self,level):
|
|
|
|
if level>len(_sister_level)-1:
|
|
|
|
return "дальний предок"
|
2003-04-30 09:51:04 +05:30
|
|
|
else:
|
2004-02-15 12:38:55 +05:30
|
|
|
return _sister_level[level]
|
|
|
|
|
|
|
|
def get_uncle(self,level):
|
|
|
|
if level>len(_brother_level)-1:
|
|
|
|
return "дальний предок"
|
2003-04-30 09:51:04 +05:30
|
|
|
else:
|
2004-02-15 12:38:55 +05:30
|
|
|
return _brother_level[level]
|
|
|
|
|
|
|
|
def get_nephew(self,level):
|
|
|
|
if level>len(_nephew_level)-1:
|
|
|
|
return "дальний потомок"
|
2003-04-30 18:53:25 +05:30
|
|
|
else:
|
2004-02-15 12:38:55 +05:30
|
|
|
return _nephew_level[level]
|
|
|
|
|
|
|
|
def get_niece(self,level):
|
|
|
|
if level>len(_niece_level)-1:
|
|
|
|
return "дальний потомок"
|
|
|
|
else:
|
|
|
|
return _niece_level[level]
|
|
|
|
|
|
|
|
def get_relationship(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)
|
|
|
|
|
|
|
|
Special cases: relation strings "", "undefined" and "spouse".
|
|
|
|
"""
|
|
|
|
|
|
|
|
if orig_person == None:
|
|
|
|
return ("undefined",[])
|
|
|
|
|
2004-08-21 09:01:51 +05:30
|
|
|
if orig_person.get_handle() == other_person.get_handle():
|
2004-02-15 12:38:55 +05:30
|
|
|
return ('', [])
|
2004-02-17 10:17:24 +05:30
|
|
|
|
2004-02-15 12:38:55 +05:30
|
|
|
if self.is_spouse(orig_person,other_person):
|
|
|
|
return ("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-15 12:38:55 +05:30
|
|
|
return ("",[])
|
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-15 12:38:55 +05:30
|
|
|
if secondRel == 0:
|
|
|
|
return ('',common)
|
2005-02-01 09:16:29 +05:30
|
|
|
elif other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-15 12:38:55 +05:30
|
|
|
return (self.get_father(secondRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_mother(secondRel),common)
|
|
|
|
elif secondRel == 0:
|
2005-02-01 09:16:29 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-15 12:38:55 +05:30
|
|
|
return (self.get_son(firstRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_daughter(firstRel),common)
|
|
|
|
elif firstRel == 1:
|
2005-02-01 09:16:29 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-15 12:38:55 +05:30
|
|
|
return (self.get_uncle(secondRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_aunt(secondRel),common)
|
|
|
|
elif secondRel == 1:
|
2005-02-01 09:16:29 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-15 12:38:55 +05:30
|
|
|
return (self.get_nephew(firstRel-1),common)
|
|
|
|
else:
|
|
|
|
return (self.get_niece(firstRel-1),common)
|
|
|
|
elif secondRel > firstRel:
|
2005-02-01 09:16:29 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-15 12:38:55 +05:30
|
|
|
return (self.get_senior_male_cousin(firstRel-1,secondRel-firstRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_senior_female_cousin(firstRel-1,secondRel-firstRel),common)
|
2003-04-30 09:51:04 +05:30
|
|
|
else:
|
2005-02-01 09:16:29 +05:30
|
|
|
if other_person.get_gender() == RelLib.Person.MALE:
|
2004-02-15 12:38:55 +05:30
|
|
|
return (self.get_junior_male_cousin(secondRel-1,firstRel-secondRel),common)
|
|
|
|
else:
|
|
|
|
return (self.get_junior_female_cousin(secondRel-1,firstRel-secondRel),common)
|
2003-04-30 09:51:04 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2004-02-16 04:14:50 +05:30
|
|
|
# Register this class with the Plugins system
|
2003-04-30 09:51:04 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-01-05 10:32:19 +05:30
|
|
|
from PluginMgr import register_relcalc
|
2003-04-30 09:51:04 +05:30
|
|
|
|
2004-02-15 12:38:55 +05:30
|
|
|
register_relcalc(RelationshipCalculator,
|
2004-02-10 08:22:57 +05:30
|
|
|
["ru","RU","ru_RU","koi8r","ru_koi8r","russian","Russian","ru_RU.koi8r","ru_RU.KOI8-R","ru_RU.utf8","ru_RU.UTF8", "ru_RU.utf-8","ru_RU.UTF-8","ru_RU.iso88595","ru_RU.iso8859-5","ru_RU.iso-8859-5"])
|