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
|
|
|
|
#
|
2005-07-09 01:54:54 +05:30
|
|
|
# Copyright (C) 2003-2005 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
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
|
|
|
|
#
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
# $Id:rel_ru.py 9912 2008-01-22 09:17:46Z acraphae $
|
2004-02-06 10:28:11 +05:30
|
|
|
|
2003-04-30 09:51:04 +05:30
|
|
|
# Written by Alex Roitman, largely based on Relationship.py by Don Allingham.
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2004-02-15 12:38:55 +05:30
|
|
|
import Relationship
|
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
|
|
|
|
2007-08-18 19:01:50 +05:30
|
|
|
def __init__(self):
|
|
|
|
Relationship.RelationshipCalculator.__init__(self)
|
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:
|
2005-04-26 21:34:21 +05:30
|
|
|
return "дальние родственники"
|
2004-02-16 08:04:50 +05:30
|
|
|
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]
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def get_relationship(self,db, orig_person, other_person):
|
2004-02-15 12:38:55 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return a string representing the relationshp between the two people,
|
2004-02-15 12:38:55 +05:30
|
|
|
along with a list of common ancestors (typically father,mother)
|
|
|
|
|
|
|
|
Special cases: relation strings "", "undefined" and "spouse".
|
|
|
|
"""
|
|
|
|
|
2008-06-16 20:31:46 +05:30
|
|
|
if orig_person is None:
|
2004-02-15 12:38:55 +05:30
|
|
|
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
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
is_spouse = self.is_spouse(db, orig_person, other_person)
|
2005-07-09 01:54:54 +05:30
|
|
|
if is_spouse:
|
|
|
|
return (is_spouse,[])
|
2004-02-15 12:38:55 +05:30
|
|
|
|
2007-10-24 18:22:07 +05:30
|
|
|
#get_relationship_distance changed, first data is relation to
|
|
|
|
#orig person, apperently secondRel in this function
|
|
|
|
(secondRel,firstRel,common) = \
|
2008-02-24 19:25:55 +05:30
|
|
|
self.get_relationship_distance(db, orig_person, other_person)
|
2004-02-17 10:17:24 +05:30
|
|
|
|
2008-05-26 01:25:47 +05:30
|
|
|
if isinstance(common, basestring):
|
2004-02-17 10:17:24 +05:30
|
|
|
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)
|
2007-10-08 22:11:39 +05:30
|
|
|
elif other_person.get_gender() == gen.lib.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:
|
2007-10-08 22:11:39 +05:30
|
|
|
if other_person.get_gender() == gen.lib.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:
|
2007-10-08 22:11:39 +05:30
|
|
|
if other_person.get_gender() == gen.lib.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:
|
2007-10-08 22:11:39 +05:30
|
|
|
if other_person.get_gender() == gen.lib.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:
|
2007-10-08 22:11:39 +05:30
|
|
|
if other_person.get_gender() == gen.lib.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:
|
2007-10-08 22:11:39 +05:30
|
|
|
if other_person.get_gender() == gen.lib.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)
|
2009-10-24 19:23:20 +05:30
|
|
|
|