* src/Relationship.py: Factor out relationship distance computation.
* src/plugins/rel_ru.py: Use self.get_distance(). * src/plugins/rel_de.py: Use self.get_distance(). * configure.in, configure: Change version. * src/plugins/rel_hu.py: Convert to class. svn: r2858
This commit is contained in:
parent
5e5c7c104a
commit
3e287429d3
@ -1,3 +1,10 @@
|
|||||||
|
2004-02-16 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
|
* src/Relationship.py: Factor out relationship distance computation.
|
||||||
|
* src/plugins/rel_ru.py: Use self.get_distance().
|
||||||
|
* src/plugins/rel_de.py: Use self.get_distance().
|
||||||
|
* configure.in, configure: Change version.
|
||||||
|
* src/plugins/rel_hu.py: Convert to class.
|
||||||
|
|
||||||
2004-02-15 Don Allingham <dallingham@users.sourceforge.net>
|
2004-02-15 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
* src/Relationship.py: more fixes
|
* src/Relationship.py: more fixes
|
||||||
* src/gramps_main.py: changed db on relationship calculator when db changes.
|
* src/gramps_main.py: changed db on relationship calculator when db changes.
|
||||||
|
711
gramps2/configure
vendored
711
gramps2/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -2,11 +2,11 @@ dnl Process this file with autoconf to produce a configure script.
|
|||||||
dnl May need to run automake && aclocal first
|
dnl May need to run automake && aclocal first
|
||||||
|
|
||||||
AC_PREREQ(2.57)
|
AC_PREREQ(2.57)
|
||||||
AC_INIT(gramps, 0.99, gramps-bugs@lists.sourceforge.net)
|
AC_INIT(gramps, 1.1.0, gramps-bugs@lists.sourceforge.net)
|
||||||
AC_CONFIG_SRCDIR(src/gramps.py)
|
AC_CONFIG_SRCDIR(src/gramps.py)
|
||||||
AM_INIT_AUTOMAKE(1.6.3)
|
AM_INIT_AUTOMAKE(1.6.3)
|
||||||
dnl RELEASE=0.CVS$(head -c 10 ${srcdir}/ChangeLog | tr -d '-')
|
RELEASE=0.CVS$(head -c 10 ${srcdir}/ChangeLog | tr -d '-')
|
||||||
RELEASE=1
|
dnl RELEASE=1
|
||||||
|
|
||||||
VERSIONSTRING=$VERSION
|
VERSIONSTRING=$VERSION
|
||||||
if test x"$RELEASE" != "x"
|
if test x"$RELEASE" != "x"
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
import RelLib
|
import RelLib
|
||||||
import GrampsCfg
|
import types
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -247,32 +247,34 @@ class RelationshipCalculator:
|
|||||||
return 0
|
return 0
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def get_relationship(self,orig_person,other_person):
|
def get_relationship_distance(self,orig_person,other_person):
|
||||||
"""
|
"""
|
||||||
returns a string representping the relationshp between the two people,
|
Returns a tuple (firstRel,secondRel,common):
|
||||||
along with a list of common ancestors (typically father,mother)
|
|
||||||
|
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
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
firstRel = -1
|
||||||
|
secondRel = -1
|
||||||
|
common = []
|
||||||
|
|
||||||
firstMap = {}
|
firstMap = {}
|
||||||
firstList = []
|
firstList = []
|
||||||
secondMap = {}
|
secondMap = {}
|
||||||
secondList = []
|
secondList = []
|
||||||
common = []
|
|
||||||
rank = 9999999
|
rank = 9999999
|
||||||
|
|
||||||
if orig_person == None:
|
|
||||||
return ("undefined",[])
|
|
||||||
|
|
||||||
if orig_person == other_person:
|
|
||||||
return ('', [])
|
|
||||||
|
|
||||||
if self.is_spouse(orig_person,other_person):
|
|
||||||
return ("spouse",[])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.apply_filter(orig_person,0,firstList,firstMap)
|
self.apply_filter(orig_person,0,firstList,firstMap)
|
||||||
self.apply_filter(other_person,0,secondList,secondMap)
|
self.apply_filter(other_person,0,secondList,secondMap)
|
||||||
except RuntimeError,msg:
|
except RuntimeError,msg:
|
||||||
return (_("Relationship loop detected"),None)
|
return (firstRel,secondRel,_("Relationship loop detected"))
|
||||||
|
|
||||||
for person_id in firstList:
|
for person_id in firstList:
|
||||||
if person_id in secondList:
|
if person_id in secondList:
|
||||||
@ -283,17 +285,38 @@ class RelationshipCalculator:
|
|||||||
elif new_rank == rank:
|
elif new_rank == rank:
|
||||||
common.append(person_id)
|
common.append(person_id)
|
||||||
|
|
||||||
firstRel = -1
|
|
||||||
secondRel = -1
|
|
||||||
|
|
||||||
if common:
|
if common:
|
||||||
person_id = common[0]
|
person_id = common[0]
|
||||||
secondRel = firstMap[person_id]
|
secondRel = firstMap[person_id]
|
||||||
firstRel = secondMap[person_id]
|
firstRel = secondMap[person_id]
|
||||||
|
|
||||||
if firstRel == -1:
|
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",[])
|
||||||
|
|
||||||
|
if orig_person == other_person:
|
||||||
|
return ('', [])
|
||||||
|
|
||||||
|
if self.is_spouse(orig_person,other_person):
|
||||||
|
return ("spouse",[])
|
||||||
|
|
||||||
|
(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:
|
||||||
|
person_id = common[0]
|
||||||
|
else:
|
||||||
return ("",[])
|
return ("",[])
|
||||||
elif firstRel == 0:
|
|
||||||
|
if firstRel == 0:
|
||||||
if secondRel == 0:
|
if secondRel == 0:
|
||||||
return ('',common)
|
return ('',common)
|
||||||
elif other_person.get_gender() == RelLib.Person.male:
|
elif other_person.get_gender() == RelLib.Person.male:
|
||||||
@ -327,42 +350,21 @@ class RelationshipCalculator:
|
|||||||
returns a string representing the relationshp between the two people,
|
returns a string representing the relationshp between the two people,
|
||||||
along with a list of common ancestors (typically father,mother)
|
along with a list of common ancestors (typically father,mother)
|
||||||
"""
|
"""
|
||||||
firstMap = {}
|
|
||||||
firstList = []
|
|
||||||
secondMap = {}
|
|
||||||
secondList = []
|
|
||||||
common = []
|
|
||||||
rank = 9999999
|
|
||||||
|
|
||||||
if orig_person == None:
|
if orig_person == None:
|
||||||
return ("undefined",[])
|
return ("undefined",[])
|
||||||
|
|
||||||
if orig_person == other_person:
|
if orig_person == other_person:
|
||||||
return ('', [])
|
return ('', [])
|
||||||
|
|
||||||
try:
|
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||||
self.apply_filter(orig_person,0,firstList,firstMap)
|
|
||||||
self.apply_filter(other_person,0,secondList,secondMap)
|
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||||
except RuntimeError,msg:
|
return (common,[])
|
||||||
return (_("Relationship loop detected"),None)
|
elif common:
|
||||||
|
|
||||||
for person_id in firstList:
|
|
||||||
if person_id in secondList:
|
|
||||||
new_rank = firstMap[person_id]
|
|
||||||
if new_rank < rank:
|
|
||||||
rank = new_rank
|
|
||||||
common = [ person_id ]
|
|
||||||
elif new_rank == rank:
|
|
||||||
common.append(person_id)
|
|
||||||
|
|
||||||
firstRel = -1
|
|
||||||
secondRel = -1
|
|
||||||
|
|
||||||
if common:
|
|
||||||
person_id = common[0]
|
person_id = common[0]
|
||||||
secondRel = firstMap[person_id]
|
else:
|
||||||
firstRel = secondMap[person_id]
|
return ("",[])
|
||||||
|
|
||||||
if firstRel == 0:
|
if firstRel == 0:
|
||||||
if secondRel == 0:
|
if secondRel == 0:
|
||||||
return ('',common)
|
return ('',common)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
import RelLib
|
import RelLib
|
||||||
import Relationship
|
import Relationship
|
||||||
|
import types
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -341,50 +342,25 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
Special cases: relation strings "", "undefined" and "spouse".
|
Special cases: relation strings "", "undefined" and "spouse".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
firstMap = {}
|
|
||||||
firstList = []
|
|
||||||
secondMap = {}
|
|
||||||
secondList = []
|
|
||||||
common = []
|
|
||||||
rank = 9999999
|
|
||||||
|
|
||||||
if orig_person == None:
|
if orig_person == None:
|
||||||
return ("undefined",[])
|
return ("undefined",[])
|
||||||
|
|
||||||
firstName = orig_person.get_primary_name().get_regular_name()
|
|
||||||
secondName = other_person.get_primary_name().get_regular_name()
|
|
||||||
|
|
||||||
if orig_person == other_person:
|
if orig_person == other_person:
|
||||||
return ('', [])
|
return ('', [])
|
||||||
|
|
||||||
if self.is_spouse(orig_person,other_person):
|
if self.is_spouse(orig_person,other_person):
|
||||||
return ("spouse",[])
|
return ("spouse",[])
|
||||||
|
|
||||||
try:
|
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||||
self.apply_filter(orig_person,0,firstList,firstMap)
|
|
||||||
self.apply_filter(other_person,0,secondList,secondMap)
|
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||||
except RuntimeError,msg:
|
return (common,[])
|
||||||
return (_("Relationship loop detected"),None)
|
elif common:
|
||||||
|
|
||||||
for person_id in firstList:
|
|
||||||
if person_id in secondList:
|
|
||||||
new_rank = firstMap[person_id]
|
|
||||||
if new_rank < rank:
|
|
||||||
rank = new_rank
|
|
||||||
common = [ person_id ]
|
|
||||||
elif new_rank == rank:
|
|
||||||
common.append(person_id)
|
|
||||||
|
|
||||||
firstRel = -1
|
|
||||||
secondRel = -1
|
|
||||||
|
|
||||||
if common:
|
|
||||||
person_id = common[0]
|
person_id = common[0]
|
||||||
secondRel = firstMap[person_id]
|
else:
|
||||||
firstRel = secondMap[person_id]
|
|
||||||
|
|
||||||
if firstRel == -1:
|
|
||||||
return ("",[])
|
return ("",[])
|
||||||
elif firstRel == 0:
|
|
||||||
|
if firstRel == 0:
|
||||||
if secondRel == 0:
|
if secondRel == 0:
|
||||||
return ('',common)
|
return ('',common)
|
||||||
elif other_person.get_gender() == RelLib.Person.male:
|
elif other_person.get_gender() == RelLib.Person.male:
|
||||||
@ -417,57 +393,6 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
else:
|
else:
|
||||||
return (self.get_junior_female_cousin(secondRel-1,firstRel-1),common)
|
return (self.get_junior_female_cousin(secondRel-1,firstRel-1),common)
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
"""
|
|
||||||
firstMap = {}
|
|
||||||
firstList = []
|
|
||||||
secondMap = {}
|
|
||||||
secondList = []
|
|
||||||
common = []
|
|
||||||
rank = 9999999
|
|
||||||
|
|
||||||
if orig_person == None:
|
|
||||||
return ("undefined",[])
|
|
||||||
|
|
||||||
if orig_person == other_person:
|
|
||||||
return ('', [])
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.apply_filter(orig_person,0,firstList,firstMap)
|
|
||||||
self.apply_filter(other_person,0,secondList,secondMap)
|
|
||||||
except RuntimeError,msg:
|
|
||||||
return (_("Relationship loop detected"),None)
|
|
||||||
|
|
||||||
for person_id in firstList:
|
|
||||||
if person_id in secondList:
|
|
||||||
new_rank = firstMap[person_id]
|
|
||||||
if new_rank < rank:
|
|
||||||
rank = new_rank
|
|
||||||
common = [ person_id ]
|
|
||||||
elif new_rank == rank:
|
|
||||||
common.append(person_id)
|
|
||||||
|
|
||||||
firstRel = -1
|
|
||||||
secondRel = -1
|
|
||||||
|
|
||||||
if common:
|
|
||||||
person = common[0]
|
|
||||||
secondRel = firstMap[person_id]
|
|
||||||
firstRel = secondMap[person_id]
|
|
||||||
|
|
||||||
if firstRel == 0:
|
|
||||||
if secondRel == 0:
|
|
||||||
return ('',common)
|
|
||||||
else:
|
|
||||||
return (self.get_parents(secondRel),common)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Register this class with the Plugins system
|
# Register this class with the Plugins system
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2003 Donald N. Allingham
|
# Copyright (C) 2003-2004 Donald N. Allingham
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -19,6 +19,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
#
|
#
|
||||||
# Written by Egyeki Gergely <egeri@elte.hu>, 2004
|
# Written by Egyeki Gergely <egeri@elte.hu>, 2004
|
||||||
#
|
#
|
||||||
@ -30,10 +32,10 @@
|
|||||||
|
|
||||||
import RelLib
|
import RelLib
|
||||||
import Date
|
import Date
|
||||||
|
import Relationship
|
||||||
from Relationship import apply_filter, is_spouse
|
|
||||||
from Plugins import register_relcalc
|
from Plugins import register_relcalc
|
||||||
|
import types
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -53,288 +55,282 @@ _level =\
|
|||||||
# Specific relationship functions
|
# Specific relationship functions
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||||
|
|
||||||
def get_parents (level):
|
def __init__(self,db):
|
||||||
if level == 0: return ""
|
Relationship.RelationshipCalculator.__init__(self,db)
|
||||||
elif level == 1: return "szülei"
|
|
||||||
elif level == 2: return "nagyszülei"
|
|
||||||
elif level == 3: return "dédszülei"
|
def get_parents (self,level):
|
||||||
elif level == 4: return "ükszülei"
|
if level == 0: return ""
|
||||||
else : return "%s szülei" % _level[level]
|
elif level == 1: return "szülei"
|
||||||
|
elif level == 2: return "nagyszülei"
|
||||||
|
elif level == 3: return "dédszülei"
|
||||||
|
elif level == 4: return "ükszülei"
|
||||||
|
else : return "%s szülei" % _level[level]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_father (level):
|
def get_father (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "apja"
|
elif level == 1: return "apja"
|
||||||
elif level == 2: return "nagyapja"
|
elif level == 2: return "nagyapja"
|
||||||
elif level == 3: return "dédapja"
|
elif level == 3: return "dédapja"
|
||||||
elif level == 4: return "ükapja"
|
elif level == 4: return "ükapja"
|
||||||
else : return "%s ükapja" % (_level[level])
|
else : return "%s ükapja" % (_level[level])
|
||||||
|
|
||||||
def get_mother (level):
|
def get_mother (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "anyja"
|
elif level == 1: return "anyja"
|
||||||
elif level == 2: return "nagyanyja"
|
elif level == 2: return "nagyanyja"
|
||||||
elif level == 3: return "dédanyja"
|
elif level == 3: return "dédanyja"
|
||||||
elif level == 4: return "ükanyja"
|
elif level == 4: return "ükanyja"
|
||||||
else : return "%s ükanyja" % (_level[level])
|
else : return "%s ükanyja" % (_level[level])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_son (level):
|
def get_son (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "fia"
|
elif level == 1: return "fia"
|
||||||
elif level == 2: return "unokája"
|
elif level == 2: return "unokája"
|
||||||
elif level == 3: return "dédunokája"
|
elif level == 3: return "dédunokája"
|
||||||
elif level == 4: return "ükunokája"
|
elif level == 4: return "ükunokája"
|
||||||
else : return "%s unokája" % (_level[level])
|
else : return "%s unokája" % (_level[level])
|
||||||
|
|
||||||
|
|
||||||
def get_daughter (level):
|
def get_daughter (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "lánya"
|
elif level == 1: return "lánya"
|
||||||
else : return get_son(level)
|
else : return self.get_son(level)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_uncle (level):
|
def get_uncle (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "testvére"
|
elif level == 1: return "testvére"
|
||||||
elif level == 2: return "nagybátyja"
|
elif level == 2: return "nagybátyja"
|
||||||
else : return "%s nagybátyja" % (_level[level])
|
else : return "%s nagybátyja" % (_level[level])
|
||||||
|
|
||||||
|
|
||||||
def get_aunt (level):
|
def get_aunt (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "testvére"
|
elif level == 1: return "testvére"
|
||||||
elif level == 2: return "nagynénje"
|
elif level == 2: return "nagynénje"
|
||||||
else : return "%s nagynénje" % (_level[level])
|
else : return "%s nagynénje" % (_level[level])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_nephew (level):
|
def get_nephew (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "unokája"
|
elif level == 1: return "unokája"
|
||||||
else : return "%s unokája" % (_level[level])
|
else : return "%s unokája" % (_level[level])
|
||||||
|
|
||||||
def get_niece(level):
|
def get_niece(self,level):
|
||||||
return get_nephew(level)
|
return self.get_nephew(level)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_male_cousin (level):
|
def get_male_cousin (self,level):
|
||||||
if level == 0: return ""
|
if level == 0: return ""
|
||||||
elif level == 1: return "unokatestvére"
|
elif level == 1: return "unokatestvére"
|
||||||
else : return "%s unokatestvére" % (_level[level])
|
else : return "%s unokatestvére" % (_level[level])
|
||||||
|
|
||||||
def get_female_cousin (level):
|
def get_female_cousin (self,level):
|
||||||
return get_male_cousin(level)
|
return self.get_male_cousin(level)
|
||||||
|
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
#
|
#
|
||||||
# brother and sister age differences
|
# brother and sister age differences
|
||||||
#
|
#
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
|
|
||||||
def get_age_comp(orig_person,other_person):
|
def get_age_comp(self,orig_person,other_person):
|
||||||
# 0=nothing, -1=other is younger 1=other is older
|
# 0=nothing, -1=other is younger 1=other is older
|
||||||
orig_birth_event = orig_person.get_birth()
|
orig_birth_event = orig_person.get_birth()
|
||||||
orig_birth_date = orig_birth_event.get_date_object()
|
orig_birth_date = orig_birth_event.get_date_object()
|
||||||
other_birth_event = other_person.get_birth()
|
other_birth_event = other_person.get_birth()
|
||||||
other_birth_date = other_birth_event.get_date_object()
|
other_birth_date = other_birth_event.get_date_object()
|
||||||
if (orig_birth_date == "")or(other_birth_date == "") :return 0
|
if (orig_birth_date == "")or(other_birth_date == "") :return 0
|
||||||
else :return Date.compare_dates(orig_birth_date,other_birth_date)
|
else :return Date.compare_dates(orig_birth_date,other_birth_date)
|
||||||
|
|
||||||
|
|
||||||
def get_age_brother (level):
|
def get_age_brother (self,level):
|
||||||
if level == 0 : return "testvére"
|
if level == 0 : return "testvére"
|
||||||
elif level == 1 : return "öccse"
|
elif level == 1 : return "öccse"
|
||||||
else : return "bátyja"
|
else : return "bátyja"
|
||||||
|
|
||||||
def get_age_sister (level):
|
def get_age_sister (self,level):
|
||||||
if level == 0 : return "testvére"
|
if level == 0 : return "testvére"
|
||||||
elif level == 1 : return "húga"
|
elif level == 1 : return "húga"
|
||||||
else : return "nővére"
|
else : return "nővére"
|
||||||
|
|
||||||
#---------------------------------------------
|
#---------------------------------------------
|
||||||
#
|
#
|
||||||
# en: father-in-law, mother-in-law, son-in-law, daughter-in-law
|
# en: father-in-law, mother-in-law, son-in-law, daughter-in-law
|
||||||
# hu: após, anyós, vő, meny
|
# hu: após, anyós, vő, meny
|
||||||
#
|
#
|
||||||
#---------------------------------------------
|
#---------------------------------------------
|
||||||
|
|
||||||
def is_fathermother_in_law(orig,other):
|
def is_fathermother_in_law(self,orig,other):
|
||||||
for f in other.getFamilyList():
|
for f in other.get_family_id_list():
|
||||||
if other == f.getFather(): sp = f.getMother()
|
family = self.db.find_family_from_id(f)
|
||||||
elif other == f.getMother() : sp = f.getFather()
|
sp_id = None
|
||||||
for g in orig.getFamilyList():
|
if family:
|
||||||
if sp in g.getChildList(): return 1
|
if other == family.get_father_id():
|
||||||
return 0
|
sp_id = family.get_mother_id()
|
||||||
|
elif other == family.get_mother_id():
|
||||||
|
sp_id = family.get_father_id()
|
||||||
|
for g in orig.get_family_id_list():
|
||||||
|
family = self.db.find_family_from_id(g)
|
||||||
|
if family:
|
||||||
|
if sp_id in family.get_child_id_list():
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
def get_fathermother_in_law_common(orig,other):
|
def get_fathermother_in_law_common(self,orig,other):
|
||||||
for f in other.getFamilyList():
|
for f in other.get_family_id_list():
|
||||||
if other == f.getFather(): sp = f.getMother()
|
family = self.db.find_family_from_id(f)
|
||||||
elif other == f.getMother() : sp = f.getFather()
|
sp_id = None
|
||||||
for g in orig.getFamilyList():
|
if family:
|
||||||
if sp in g.getChildList(): return [sp]
|
if other == family.get_father_id():
|
||||||
return []
|
sp_id = family.get_mother_id()
|
||||||
|
elif other == family.get_mother_id():
|
||||||
|
sp_id = family.get_father_idr()
|
||||||
|
for g in orig.get_family_id_list():
|
||||||
|
family = self.db.find_family_from_id(g)
|
||||||
|
if family:
|
||||||
|
if sp_id in family.get_child_id_list():
|
||||||
|
return [sp]
|
||||||
|
return []
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# hu: sógor, sógornő
|
# hu: sógor, sógornő
|
||||||
# en: brother-in-law, sister-in-law
|
# en: brother-in-law, sister-in-law
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
def is_brothersister_in_law(orig,other):
|
def is_brothersister_in_law(self,orig,other):
|
||||||
for f in orig.getFamilyList():
|
for f in orig.get_family_id_list():
|
||||||
if orig == f.getFather(): sp = f.getMother()
|
family = self.db.find_family_from_id(f)
|
||||||
elif orig == f.getMother() : sp = f.getFather()
|
sp_id = None
|
||||||
p = other.getMainParents()
|
if family:
|
||||||
if (p != None):
|
if orig == family.get_father_id():
|
||||||
c= p.getChildList()
|
sp_id = family.get_mother_id()
|
||||||
if (other in c)and(sp in c): return 1
|
elif other == family.get_mother_id():
|
||||||
return 0
|
sp_id = family.get_father_idr()
|
||||||
|
|
||||||
def get_brothersister_in_law_common(orig,other):
|
p = other.get_main_parents_family_id()
|
||||||
for f in orig.getFamilyList():
|
family = self.db.find_family_from_id(p)
|
||||||
if orig == f.getFather(): sp = f.getMother()
|
if family:
|
||||||
elif orig == f.getMother() : sp = f.getFather()
|
c = family.get_child_id_list()
|
||||||
p = other.getMainParents()
|
if (other.get_id() in c) and (sp_id in c):
|
||||||
if (p != None):
|
return 1
|
||||||
c= p.getChildList()
|
return 0
|
||||||
if (other in c)and(sp in c): return [sp]
|
|
||||||
return []
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
def get_brothersister_in_law_common(self,orig,other):
|
||||||
#
|
for f in orig.get_family_id_list():
|
||||||
# get_relationship
|
family = self.db.find_family_from_id(f)
|
||||||
#
|
sp_id = None
|
||||||
#-------------------------------------------------------------------------
|
if family:
|
||||||
|
if orig == family.get_father_id():
|
||||||
|
sp_id = family.get_mother_id()
|
||||||
|
elif other == family.get_mother_id():
|
||||||
|
sp_id = family.get_father_idr()
|
||||||
|
|
||||||
def get_relationship(orig_person,other_person):
|
p = other.get_main_parents_family_id()
|
||||||
"""
|
family = self.db.find_family_from_id(p)
|
||||||
returns a string representing the relationshp between the two people,
|
if family:
|
||||||
along with a list of common ancestors (typically father,mother)
|
c = family.get_child_id_list()
|
||||||
"""
|
if (other.get_id() in c) and (sp_id in c):
|
||||||
firstMap = {}
|
return [sp]
|
||||||
firstList = []
|
return []
|
||||||
secondMap = {}
|
|
||||||
secondList = []
|
#-------------------------------------------------------------------------
|
||||||
common = []
|
#
|
||||||
rank = 9999999
|
# get_relationship
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
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)
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self.is_fathermother_in_law(other_person,orig_person):
|
||||||
|
if other_person.getGender() == RelLib.Person.male:
|
||||||
|
return ("apósa",self.get_fathermother_in_law_common(other_person,orig_person))
|
||||||
|
elif other_person.getGender() == RelLib.Person.female:
|
||||||
|
return ("anyósa",self.get_fathermother_in_law_common(other_person,orig_person))
|
||||||
|
elif other_person.getGender() == 2 :
|
||||||
|
return ("apósa vagy anyósa",self.get_fathermother_in_law_common(other_person,orig_person))
|
||||||
|
|
||||||
|
if self.is_fathermother_in_law(orig_person,other_person):
|
||||||
|
if orig_person.getGender() == RelLib.Person.male:
|
||||||
|
return ("veje",self.get_fathermother_in_law_common(orig_person,other_person))
|
||||||
|
elif orig_person.getGender() == RelLib.Person.female:
|
||||||
|
return ("menye",self.get_fathermother_in_law_common(orig_person,other_person))
|
||||||
|
elif orig_person.getGender() == 2 :
|
||||||
|
return ("veje vagy menye",self.get_fathermother_in_law_common(orig_person,other_person))
|
||||||
|
|
||||||
|
if self.is_brothersister_in_law(orig_person,other_person):
|
||||||
|
if other_person.getGender() == RelLib.Person.male:
|
||||||
|
return ("sógora",self.get_brothersister_in_law_common(orig_person,other_person))
|
||||||
|
elif other_person.getGender() == RelLib.Person.female:
|
||||||
|
return ("sógornője",self.get_brothersister_in_law_common(orig_person,other_person))
|
||||||
|
elif other_person.getGender() == 2 :
|
||||||
|
return ("sógora vagy sógornője",self.get_brothersister_in_law_common(orig_person,other_person))
|
||||||
|
|
||||||
|
|
||||||
if orig_person == None:
|
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||||
return ("nem meghatározható",[])
|
|
||||||
|
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||||
if orig_person == other_person:
|
return (common,[])
|
||||||
return ('', [])
|
elif common:
|
||||||
|
person_id = common[0]
|
||||||
if is_spouse(orig_person,other_person):
|
|
||||||
return ("házastársa",[])
|
|
||||||
|
|
||||||
|
|
||||||
if is_fathermother_in_law(other_person,orig_person):
|
|
||||||
if other_person.getGender() == RelLib.Person.male:
|
|
||||||
return ("apósa",get_fathermother_in_law_common(other_person,orig_person))
|
|
||||||
elif other_person.getGender() == RelLib.Person.female:
|
|
||||||
return ("anyósa",get_fathermother_in_law_common(other_person,orig_person))
|
|
||||||
elif other_person.getGender() == 2 :
|
|
||||||
return ("apósa vagy anyósa",get_fathermother_in_law_common(other_person,orig_person))
|
|
||||||
|
|
||||||
if is_fathermother_in_law(orig_person,other_person):
|
|
||||||
if orig_person.getGender() == RelLib.Person.male:
|
|
||||||
return ("veje",get_fathermother_in_law_common(orig_person,other_person))
|
|
||||||
elif orig_person.getGender() == RelLib.Person.female:
|
|
||||||
return ("menye",get_fathermother_in_law_common(orig_person,other_person))
|
|
||||||
elif orig_person.getGender() == 2 :
|
|
||||||
return ("veje vagy menye",get_fathermother_in_law_common(orig_person,other_person))
|
|
||||||
|
|
||||||
if is_brothersister_in_law(orig_person,other_person):
|
|
||||||
if other_person.getGender() == RelLib.Person.male:
|
|
||||||
return ("sógora",get_brothersister_in_law_common(orig_person,other_person))
|
|
||||||
elif other_person.getGender() == RelLib.Person.female:
|
|
||||||
return ("sógornője",get_brothersister_in_law_common(orig_person,other_person))
|
|
||||||
elif other_person.getGender() == 2 :
|
|
||||||
return ("sógora vagy sógornője",get_brothersister_in_law_common(orig_person,other_person))
|
|
||||||
|
|
||||||
|
|
||||||
apply_filter(orig_person,0,firstList,firstMap)
|
|
||||||
apply_filter(other_person,0,secondList,secondMap)
|
|
||||||
|
|
||||||
for person in firstList:
|
|
||||||
if person in secondList:
|
|
||||||
new_rank = firstMap[person.get_id()]
|
|
||||||
if new_rank < rank:
|
|
||||||
rank = new_rank
|
|
||||||
common = [ person ]
|
|
||||||
elif new_rank == rank:
|
|
||||||
common.append(person)
|
|
||||||
|
|
||||||
firstRel = -1
|
|
||||||
secondRel = -1
|
|
||||||
|
|
||||||
length = len(common)
|
|
||||||
|
|
||||||
if length == 1:
|
|
||||||
person = common[0]
|
|
||||||
secondRel = firstMap[person.get_id()]
|
|
||||||
firstRel = secondMap[person.get_id()]
|
|
||||||
elif length == 2:
|
|
||||||
p1 = common[0]
|
|
||||||
secondRel = firstMap[p1.get_id()]
|
|
||||||
firstRel = secondMap[p1.get_id()]
|
|
||||||
elif length > 2:
|
|
||||||
person = common[0]
|
|
||||||
secondRel = firstMap[person.get_id()]
|
|
||||||
firstRel = secondMap[person.get_id()]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if firstRel == -1:
|
|
||||||
return ("",[])
|
|
||||||
|
|
||||||
elif firstRel == 0:
|
|
||||||
if secondRel == 0:
|
|
||||||
return ('',common)
|
|
||||||
elif other_person.get_gender() == RelLib.Person.male:
|
|
||||||
return (get_father(secondRel),common)
|
|
||||||
else:
|
else:
|
||||||
return (get_mother(secondRel),common)
|
return ("",[])
|
||||||
|
|
||||||
elif secondRel == 0:
|
if firstRel == 0:
|
||||||
if other_person.get_gender() == RelLib.Person.male:
|
if secondRel == 0:
|
||||||
return (get_son(firstRel),common)
|
return ('',common)
|
||||||
else:
|
elif other_person.get_gender() == RelLib.Person.male:
|
||||||
return (get_daughter(firstRel),common)
|
return (self.get_father(secondRel),common)
|
||||||
|
else:
|
||||||
|
return (self.get_mother(secondRel),common)
|
||||||
|
|
||||||
elif firstRel == 1:
|
elif secondRel == 0:
|
||||||
if other_person.get_gender() == RelLib.Person.male:
|
if other_person.get_gender() == RelLib.Person.male:
|
||||||
if secondRel == 1:
|
return (self.get_son(firstRel),common)
|
||||||
return (get_age_brother(get_age_comp(orig_person,other_person)),common)
|
else:
|
||||||
else :return (get_uncle(secondRel),common)
|
return (self.get_daughter(firstRel),common)
|
||||||
else:
|
|
||||||
if secondRel == 1:
|
|
||||||
return (get_age_sister(get_age_comp(orig_person,other_person)),common)
|
|
||||||
else :return (get_aunt(secondRel),common)
|
|
||||||
|
|
||||||
elif secondRel == 1:
|
elif firstRel == 1:
|
||||||
if other_person.get_gender() == RelLib.Person.male:
|
if other_person.get_gender() == RelLib.Person.male:
|
||||||
return (get_nephew(firstRel-1),common)
|
if secondRel == 1:
|
||||||
else:
|
return (self.get_age_brother(self.get_age_comp(orig_person,other_person)),common)
|
||||||
return (get_niece(firstRel-1),common)
|
else :return (self.get_uncle(secondRel),common)
|
||||||
|
else:
|
||||||
|
if secondRel == 1:
|
||||||
|
return (self.get_age_sister(self.get_age_comp(orig_person,other_person)),common)
|
||||||
|
else :return (self.get_aunt(secondRel),common)
|
||||||
|
|
||||||
|
elif secondRel == 1:
|
||||||
|
if other_person.get_gender() == RelLib.Person.male:
|
||||||
|
return (self.get_nephew(firstRel-1),common)
|
||||||
|
else:
|
||||||
|
return (self.get_niece(firstRel-1),common)
|
||||||
|
|
||||||
else:
|
|
||||||
if other_person.get_gender() == RelLib.Person.male:
|
|
||||||
return (get_male_cousin(firstRel-1), common)
|
|
||||||
else:
|
else:
|
||||||
return (get_female_cousin(firstRel-1), common)
|
if other_person.get_gender() == RelLib.Person.male:
|
||||||
|
return (self.get_male_cousin(firstRel-1), common)
|
||||||
|
else:
|
||||||
|
return (self.get_female_cousin(firstRel-1), common)
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -343,7 +339,7 @@ def get_relationship(orig_person,other_person):
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
register_relcalc(get_relationship,
|
register_relcalc(RelationshipCalculator,
|
||||||
["hu", "HU", "hu_HU", "hu_HU.utf8", "hu_HU.UTF8"])
|
["hu", "HU", "hu_HU", "hu_HU.utf8", "hu_HU.UTF8"])
|
||||||
|
|
||||||
# Local variables:
|
# Local variables:
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
import RelLib
|
import RelLib
|
||||||
import Relationship
|
import Relationship
|
||||||
|
import types
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -204,6 +205,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
return 0
|
return 0
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_relationship(self,orig_person,other_person):
|
def get_relationship(self,orig_person,other_person):
|
||||||
"""
|
"""
|
||||||
Returns a string representing the relationshp between the two people,
|
Returns a string representing the relationshp between the two people,
|
||||||
@ -212,50 +215,25 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
Special cases: relation strings "", "undefined" and "spouse".
|
Special cases: relation strings "", "undefined" and "spouse".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
firstMap = {}
|
|
||||||
firstList = []
|
|
||||||
secondMap = {}
|
|
||||||
secondList = []
|
|
||||||
common = []
|
|
||||||
rank = 9999999
|
|
||||||
|
|
||||||
if orig_person == None:
|
if orig_person == None:
|
||||||
return ("undefined",[])
|
return ("undefined",[])
|
||||||
|
|
||||||
firstName = orig_person.get_primary_name().get_regular_name()
|
|
||||||
secondName = other_person.get_primary_name().get_regular_name()
|
|
||||||
|
|
||||||
if orig_person == other_person:
|
if orig_person == other_person:
|
||||||
return ('', [])
|
return ('', [])
|
||||||
|
|
||||||
if self.is_spouse(orig_person,other_person):
|
if self.is_spouse(orig_person,other_person):
|
||||||
return ("spouse",[])
|
return ("spouse",[])
|
||||||
|
|
||||||
try:
|
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person)
|
||||||
self.apply_filter(orig_person,0,firstList,firstMap)
|
|
||||||
self.apply_filter(other_person,0,secondList,secondMap)
|
if type(common) == types.StringType or type(common) == types.UnicodeType:
|
||||||
except RuntimeError,msg:
|
return (common,[])
|
||||||
return (_("Relationship loop detected"),None)
|
elif common:
|
||||||
|
|
||||||
for person_id in firstList:
|
|
||||||
if person_id in secondList:
|
|
||||||
new_rank = firstMap[person_id]
|
|
||||||
if new_rank < rank:
|
|
||||||
rank = new_rank
|
|
||||||
common = [ person_id ]
|
|
||||||
elif new_rank == rank:
|
|
||||||
common.append(person_id)
|
|
||||||
|
|
||||||
firstRel = -1
|
|
||||||
secondRel = -1
|
|
||||||
|
|
||||||
if common:
|
|
||||||
person_id = common[0]
|
person_id = common[0]
|
||||||
secondRel = firstMap[person_id]
|
else:
|
||||||
firstRel = secondMap[person_id]
|
|
||||||
|
|
||||||
if firstRel == -1:
|
|
||||||
return ("",[])
|
return ("",[])
|
||||||
elif firstRel == 0:
|
|
||||||
|
if firstRel == 0:
|
||||||
if secondRel == 0:
|
if secondRel == 0:
|
||||||
return ('',common)
|
return ('',common)
|
||||||
elif other_person.get_gender() == RelLib.Person.male:
|
elif other_person.get_gender() == RelLib.Person.male:
|
||||||
@ -288,57 +266,6 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
else:
|
else:
|
||||||
return (self.get_junior_female_cousin(secondRel-1,firstRel-secondRel),common)
|
return (self.get_junior_female_cousin(secondRel-1,firstRel-secondRel),common)
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
"""
|
|
||||||
firstMap = {}
|
|
||||||
firstList = []
|
|
||||||
secondMap = {}
|
|
||||||
secondList = []
|
|
||||||
common = []
|
|
||||||
rank = 9999999
|
|
||||||
|
|
||||||
if orig_person == None:
|
|
||||||
return ("undefined",[])
|
|
||||||
|
|
||||||
if orig_person == other_person:
|
|
||||||
return ('', [])
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.apply_filter(orig_person,0,firstList,firstMap)
|
|
||||||
self.apply_filter(other_person,0,secondList,secondMap)
|
|
||||||
except RuntimeError,msg:
|
|
||||||
return (_("Relationship loop detected"),None)
|
|
||||||
|
|
||||||
for person_id in firstList:
|
|
||||||
if person_id in secondList:
|
|
||||||
new_rank = firstMap[person_id]
|
|
||||||
if new_rank < rank:
|
|
||||||
rank = new_rank
|
|
||||||
common = [ person_id ]
|
|
||||||
elif new_rank == rank:
|
|
||||||
common.append(person_id)
|
|
||||||
|
|
||||||
firstRel = -1
|
|
||||||
secondRel = -1
|
|
||||||
|
|
||||||
if common:
|
|
||||||
person_id = common[0]
|
|
||||||
secondRel = firstMap[person_id]
|
|
||||||
firstRel = secondMap[person_id]
|
|
||||||
|
|
||||||
if firstRel == 0:
|
|
||||||
if secondRel == 0:
|
|
||||||
return ('',common)
|
|
||||||
else:
|
|
||||||
return (self.get_parents(secondRel),common)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Register this class with the Plugins system
|
# Register this class with the Plugins system
|
||||||
|
Loading…
Reference in New Issue
Block a user