2006-08-30 01:26:42 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2003-2006 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2010-01-12 21:41:39 +05:30
|
|
|
# Copyright (C) 2010 Andrew I Baznikin
|
2006-08-30 01:26:42 +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_cs.py 9912 2008-01-22 09:17:46Z acraphae $
|
2006-08-30 01:26:42 +05:30
|
|
|
|
|
|
|
# Czech terms added by Zdeněk Hataš. Based on rel_sk.py by Lubo Vasko
|
2010-01-05 23:37:09 +05:30
|
|
|
"""
|
|
|
|
Czech-specific classes for relationships.
|
|
|
|
"""
|
2006-08-30 01:26:42 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2006-08-30 01:26:42 +05:30
|
|
|
import Relationship
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Czech-specific definitions of relationships
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
_level_name = [ "", "prvního", "druhého", "třetího", "čtvrtého", "pátého", "šestého",
|
|
|
|
"sedmého", "osmého", "devátého", "desátého", "jedenáctého", "dvanáctého",
|
|
|
|
"třináctého", "čtrnáctého", "patnáctého", "šestnáctého",
|
|
|
|
"sedemnáctého", "osmnáctého", "devatenáctého", "dvacátého", "dvacátého prvního", "dvacátého druhého",
|
|
|
|
"dvacátého třetího", "dvacátého čtvrtého","dvacátého pátého","dvacátého šestého","dvacátého sedmého",
|
|
|
|
"dvacátého osmého","dvacátého devátého","třicátého" ]
|
|
|
|
|
|
|
|
_parents_level = [ "", "rodiče", "prarodiče", "praprarodiče",
|
|
|
|
"vzdálení příbuzní", ]
|
|
|
|
|
|
|
|
_father_level = [ "", "otec", "děd", "praděd", "prapředek", ]
|
|
|
|
|
|
|
|
_mother_level = [ "", "matka", "babička", "prababička", "prapředek", ]
|
|
|
|
|
|
|
|
_son_level = [ "", "syn", "vnuk", "pravnuk", ]
|
|
|
|
|
|
|
|
_daughter_level = [ "", "dcera", "vnučka", "pravnučka", ]
|
|
|
|
|
|
|
|
_sister_level = [ "", "sestra", "teta", "prateta", "praprateta", ]
|
|
|
|
|
|
|
|
_brother_level = [ "", "bratr", "strýc", "prastrýc", "praprastrýc", ]
|
|
|
|
|
|
|
|
_nephew_level = [ "", "synovec", "prasynovec", "praprasynovec", ]
|
|
|
|
|
|
|
|
_niece_level = [ "", "neteř", "praneteř", "prapraneteř", ]
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
2010-01-05 23:37:09 +05:30
|
|
|
"""
|
|
|
|
RelationshipCalculator Class
|
|
|
|
"""
|
2006-08-30 01:26:42 +05:30
|
|
|
|
2007-08-18 19:01:50 +05:30
|
|
|
def __init__(self):
|
|
|
|
Relationship.RelationshipCalculator.__init__(self)
|
2006-08-30 01:26:42 +05:30
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_male_cousin(self, level):
|
|
|
|
if level > len(_level_name)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený příbuzný"
|
|
|
|
else:
|
|
|
|
return "bratranec %s stupně" % (_level_name[level])
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_female_cousin(self, level):
|
|
|
|
if level > len(_level_name)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálená příbuzná"
|
|
|
|
else:
|
|
|
|
return "sestřenice %s stupně" % (_level_name[level])
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_parents(self, level):
|
|
|
|
if level > len(_parents_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdáleení příbuzní"
|
|
|
|
else:
|
|
|
|
return _parents_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_father(self, level):
|
|
|
|
if level > len(_father_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený příbuzný"
|
|
|
|
else:
|
|
|
|
return _father_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_son(self, level):
|
|
|
|
if level > len(_son_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený potomek"
|
|
|
|
else:
|
|
|
|
return _son_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_mother(self, level):
|
|
|
|
if level > len(_mother_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený předek"
|
|
|
|
else:
|
|
|
|
return _mother_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_daughter(self, level):
|
|
|
|
if level > len(_daughter_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený potomek"
|
|
|
|
else:
|
|
|
|
return _daughter_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_aunt(self, level):
|
|
|
|
if level > len(_sister_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený předek"
|
|
|
|
else:
|
|
|
|
return _sister_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_uncle(self, level):
|
|
|
|
if level > len(_brother_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený předek"
|
|
|
|
else:
|
|
|
|
return _brother_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_nephew(self, level):
|
|
|
|
if level > len(_nephew_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený potomek"
|
|
|
|
else:
|
|
|
|
return _nephew_level[level]
|
|
|
|
|
2010-01-05 23:37:09 +05:30
|
|
|
def get_niece(self, level):
|
|
|
|
if level > len(_niece_level)-1:
|
2006-08-30 01:26:42 +05:30
|
|
|
return "vzdálený potomek"
|
|
|
|
else:
|
|
|
|
return _niece_level[level]
|
|
|
|
|
2010-01-12 21:41:39 +05:30
|
|
|
def get_relationship(self, secondRel, firstRel, orig_person_gender, other_person_gender):
|
2006-08-30 01:26:42 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return a string representing the relationshp between the two people,
|
2006-08-30 01:26:42 +05:30
|
|
|
along with a list of common ancestors (typically father,mother)
|
|
|
|
|
|
|
|
Special cases: relation strings "", "undefined" and "spouse".
|
|
|
|
"""
|
|
|
|
|
2010-01-12 21:41:39 +05:30
|
|
|
common = ""
|
2006-08-30 01:26:42 +05:30
|
|
|
if firstRel == 0:
|
|
|
|
if secondRel == 0:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('', common)
|
2010-01-12 21:41:39 +05:30
|
|
|
elif other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_father(secondRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_mother(secondRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
elif secondRel == 0:
|
2010-01-12 21:41:39 +05:30
|
|
|
if other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_son(firstRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_daughter(firstRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
elif firstRel == 1:
|
2010-01-12 21:41:39 +05:30
|
|
|
if other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_uncle(secondRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_aunt(secondRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
elif secondRel == 1:
|
2010-01-12 21:41:39 +05:30
|
|
|
if other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_nephew(firstRel-1), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return (self.get_niece(firstRel-1), common)
|
2008-06-16 20:31:46 +05:30
|
|
|
elif firstRel == secondRel == 2:
|
2010-01-12 21:41:39 +05:30
|
|
|
if other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('vlastní bratranec', common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('vlastní sestřenice', common)
|
2006-08-30 01:26:42 +05:30
|
|
|
elif firstRel == 3 and secondRel == 2:
|
2010-01-12 21:41:39 +05:30
|
|
|
if other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('bratranec druhého stupně', common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('sestřenice druhého stupně', common)
|
2006-08-30 01:26:42 +05:30
|
|
|
elif firstRel == 2 and secondRel == 3:
|
2010-01-12 21:41:39 +05:30
|
|
|
if other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('bratranec druhého stupně', common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('sestřenice druhého stupně', common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-12 21:41:39 +05:30
|
|
|
if other_person_gender == gen.lib.Person.MALE:
|
2010-01-05 23:37:09 +05:30
|
|
|
if firstRel+secondRel > len(_level_name)-1:
|
|
|
|
return (self.get_male_cousin(firstRel+secondRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('vzdálený bratranec', common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
if firstRel+secondRel > len(_level_name)-1:
|
|
|
|
return (self.get_female_cousin(firstRel+secondRel), common)
|
2006-08-30 01:26:42 +05:30
|
|
|
else:
|
2010-01-05 23:37:09 +05:30
|
|
|
return ('vzdálená sestřenice', common)
|
2010-01-12 21:41:39 +05:30
|
|
|
|
|
|
|
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
|
|
|
|
reltocommon_a, reltocommon_b,
|
|
|
|
only_birth=True,
|
|
|
|
in_law_a=False, in_law_b=False):
|
|
|
|
return self.get_relationship(Ga, Gb, gender_a, gender_b)[0];
|
|
|
|
|
|
|
|
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
|
|
|
|
in_law_a=False, in_law_b=False):
|
|
|
|
return self.get_relationship(1, 1, gender_a, gender_b)[0];
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
# Test function. Call it as follows from the command line (so as to find
|
|
|
|
# imported modules):
|
|
|
|
# export PYTHONPATH=/path/to/gramps/src
|
|
|
|
# python src/plugins/rel/rel_cs.py
|
|
|
|
# (Above not needed here)
|
|
|
|
|
|
|
|
"""TRANSLATORS, copy this if statement at the bottom of your
|
|
|
|
rel_xx.py module, and test your work with:
|
|
|
|
python src/plugins/rel/rel_xx.py
|
|
|
|
"""
|
|
|
|
from Relationship import test
|
|
|
|
RC = RelationshipCalculator()
|
|
|
|
test(RC, True)
|