1683 Untranslatable text in Relationship calculator window - no crash on rel_xx tests (contribution by Andrew I Baznikin)
svn: r13973
This commit is contained in:
parent
4acca6c7af
commit
7001690176
@ -4,6 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2003-2005 Donald N. Allingham
|
# Copyright (C) 2003-2005 Donald N. Allingham
|
||||||
# Copyright (C) 2008 Brian G. Matherly
|
# Copyright (C) 2008 Brian G. Matherly
|
||||||
|
# Copyright (C) 2010 Andrew I Baznikin
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -123,7 +124,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('sønne')
|
result.append('sønne')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('søn')
|
result.append('søn')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
@ -146,47 +147,21 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('sønne')
|
result.append('sønne')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('søn')
|
result.append('søn')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
else:
|
else:
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('bror')
|
result.append('bror')
|
||||||
else:
|
else:
|
||||||
result.append('søster')
|
result.append('søster')
|
||||||
return self.pair_up(result)
|
return self.pair_up(result)
|
||||||
|
|
||||||
def get_relationship(self,db, orig_person, other_person):
|
def get_relationship(self,
|
||||||
"""
|
secondRel, firstRel, orig_person, other_person):
|
||||||
Return 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 is None:
|
|
||||||
return ("undefined",[])
|
|
||||||
|
|
||||||
if orig_person.get_handle() == other_person.get_handle():
|
|
||||||
return ('', [])
|
|
||||||
|
|
||||||
is_spouse = self.is_spouse(db, orig_person, other_person)
|
|
||||||
if is_spouse:
|
|
||||||
return (is_spouse,[])
|
|
||||||
|
|
||||||
#get_relationship_distance changed, first data is relation to
|
|
||||||
#orig person, apperently secondRel in this function
|
|
||||||
(secondRel,firstRel,common) = \
|
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
|
||||||
|
|
||||||
if isinstance(common, basestring):
|
|
||||||
return (common,[])
|
|
||||||
elif common:
|
|
||||||
person_handle = common[0]
|
|
||||||
else:
|
|
||||||
return ("",[])
|
|
||||||
|
|
||||||
|
common = ""
|
||||||
if not firstRel:
|
if not firstRel:
|
||||||
if not secondRel:
|
if not secondRel:
|
||||||
return ('',common)
|
return ('',common)
|
||||||
@ -197,6 +172,16 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
else:
|
else:
|
||||||
return (self.get_two_way_rel(other_person,firstRel,secondRel),common)
|
return (self.get_two_way_rel(other_person,firstRel,secondRel),common)
|
||||||
|
|
||||||
|
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(reltocommon_a, reltocommon_b, 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_two_way_rel(gender_b,"","")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
# Test function. Call it as follows from the command line (so as to find
|
# Test function. Call it as follows from the command line (so as to find
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2003-2005 Donald N. Allingham
|
# Copyright (C) 2003-2005 Donald N. Allingham
|
||||||
# Copyright (C) 2008 Brian G. Matherly
|
# Copyright (C) 2008 Brian G. Matherly
|
||||||
|
# Copyright (C) 2010 Andrew I Baznikin
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -86,7 +87,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('isän')
|
result.append('isän')
|
||||||
else:
|
else:
|
||||||
result.append('äidin')
|
result.append('äidin')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('isä')
|
result.append('isä')
|
||||||
else:
|
else:
|
||||||
result.append('äiti')
|
result.append('äiti')
|
||||||
@ -101,9 +102,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('tyttären')
|
result.append('tyttären')
|
||||||
else:
|
else:
|
||||||
result.append('lapsen')
|
result.append('lapsen')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('poika')
|
result.append('poika')
|
||||||
elif person.get_gender() == gen.lib.Person.FEMALE:
|
elif person == gen.lib.Person.FEMALE:
|
||||||
result.append('tytär')
|
result.append('tytär')
|
||||||
else:
|
else:
|
||||||
result.append('lapsi')
|
result.append('lapsi')
|
||||||
@ -138,9 +139,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('tyttären')
|
result.append('tyttären')
|
||||||
else:
|
else:
|
||||||
result.append('lapsen')
|
result.append('lapsen')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('poika')
|
result.append('poika')
|
||||||
elif person.get_gender() == gen.lib.Person.FEMALE:
|
elif person == gen.lib.Person.FEMALE:
|
||||||
result.append('tytär')
|
result.append('tytär')
|
||||||
else:
|
else:
|
||||||
result.append('lapsi')
|
result.append('lapsi')
|
||||||
@ -167,36 +168,10 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
return ' '.join(result)
|
return ' '.join(result)
|
||||||
|
|
||||||
|
|
||||||
def get_relationship(self,db, orig_person, other_person):
|
def get_relationship(self,
|
||||||
"""
|
secondRel, firstRel, orig_person, other_person):
|
||||||
Return 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 is None:
|
|
||||||
return ("undefined",[])
|
|
||||||
|
|
||||||
if orig_person.get_handle() == other_person.get_handle():
|
|
||||||
return ('', [])
|
|
||||||
|
|
||||||
is_spouse = self.is_spouse(db, orig_person, other_person)
|
|
||||||
if is_spouse:
|
|
||||||
return (is_spouse,[])
|
|
||||||
|
|
||||||
#get_relationship_distance changed, first data is relation to
|
|
||||||
#orig person, apperently secondRel in this function
|
|
||||||
(secondRel,firstRel,common) = \
|
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
|
||||||
|
|
||||||
if isinstance(common, basestring):
|
|
||||||
return (common,[])
|
|
||||||
elif common:
|
|
||||||
person_handle = common[0]
|
|
||||||
else:
|
|
||||||
return ("",[])
|
|
||||||
|
|
||||||
|
common = ""
|
||||||
if not firstRel:
|
if not firstRel:
|
||||||
if not secondRel:
|
if not secondRel:
|
||||||
return ('',common)
|
return ('',common)
|
||||||
@ -205,7 +180,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
elif not secondRel:
|
elif not secondRel:
|
||||||
return (self.get_direct_descendant(other_person,firstRel),common)
|
return (self.get_direct_descendant(other_person,firstRel),common)
|
||||||
elif len(firstRel) == 1:
|
elif len(firstRel) == 1:
|
||||||
if other_person.get_gender() == gen.lib.Person.MALE:
|
if other_person == gen.lib.Person.MALE:
|
||||||
return (self.get_ancestors_brother(secondRel),common)
|
return (self.get_ancestors_brother(secondRel),common)
|
||||||
else:
|
else:
|
||||||
return (self.get_ancestors_sister(secondRel),common)
|
return (self.get_ancestors_sister(secondRel),common)
|
||||||
@ -214,6 +189,19 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
else:
|
else:
|
||||||
return (self.get_cousins_descendant(other_person,firstRel,secondRel),common)
|
return (self.get_cousins_descendant(other_person,firstRel,secondRel),common)
|
||||||
|
|
||||||
|
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(reltocommon_a, reltocommon_b, 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):
|
||||||
|
if gender_b == gen.lib.Person.MALE:
|
||||||
|
return self.get_ancestors_brother("")
|
||||||
|
else:
|
||||||
|
return self.get_ancestors_sister("")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
# Test function. Call it as follows from the command line (so as to find
|
# Test function. Call it as follows from the command line (so as to find
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2003-2005 Donald N. Allingham
|
# Copyright (C) 2003-2005 Donald N. Allingham
|
||||||
# Copyright (C) 2008 Brian G. Matherly
|
# Copyright (C) 2008 Brian G. Matherly
|
||||||
|
# Copyright (C) 2010 Andrew I Baznikin
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -114,7 +115,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('sønne')
|
result.append('sønne')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('sønn')
|
result.append('sønn')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
@ -131,7 +132,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('mor')
|
result.append('mor')
|
||||||
if level > 1:
|
if level > 1:
|
||||||
result.append(self.get_cousin(level))
|
result.append(self.get_cousin(level))
|
||||||
elif person.get_gender() == gen.lib.Person.MALE:
|
elif person == gen.lib.Person.MALE:
|
||||||
result.append('fetter')
|
result.append('fetter')
|
||||||
else:
|
else:
|
||||||
result.append('kusine')
|
result.append('kusine')
|
||||||
@ -160,7 +161,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('sønn')
|
result.append('sønn')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('sønn')
|
result.append('sønn')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
@ -206,47 +207,21 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
result.append('sønne')
|
result.append('sønne')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('sønn')
|
result.append('sønn')
|
||||||
else:
|
else:
|
||||||
result.append('datter')
|
result.append('datter')
|
||||||
else:
|
else:
|
||||||
if person.get_gender() == gen.lib.Person.MALE:
|
if person == gen.lib.Person.MALE:
|
||||||
result.append('bror')
|
result.append('bror')
|
||||||
else:
|
else:
|
||||||
result.append('søster')
|
result.append('søster')
|
||||||
return self.pair_up(result)
|
return self.pair_up(result)
|
||||||
|
|
||||||
def get_relationship(self,db, orig_person, other_person):
|
def get_relationship(self,
|
||||||
"""
|
secondRel, firstRel, orig_person, other_person):
|
||||||
Return 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 is None:
|
|
||||||
return ("undefined",[])
|
|
||||||
|
|
||||||
if orig_person.get_handle() == other_person.get_handle():
|
|
||||||
return ('', [])
|
|
||||||
|
|
||||||
is_spouse = self.is_spouse(db, orig_person, other_person)
|
|
||||||
if is_spouse:
|
|
||||||
return (is_spouse,[])
|
|
||||||
|
|
||||||
#get_relationship_distance changed, first data is relation to
|
|
||||||
#orig person, apperently secondRel in this function
|
|
||||||
(secondRel,firstRel,common) = \
|
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
|
||||||
|
|
||||||
if isinstance(common, basestring):
|
|
||||||
return (common,[])
|
|
||||||
elif common:
|
|
||||||
person_handle = common[0]
|
|
||||||
else:
|
|
||||||
return ("",[])
|
|
||||||
|
|
||||||
|
common = ""
|
||||||
if not firstRel:
|
if not firstRel:
|
||||||
if not secondRel:
|
if not secondRel:
|
||||||
return ('',common)
|
return ('',common)
|
||||||
@ -255,7 +230,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
elif not secondRel:
|
elif not secondRel:
|
||||||
return (self.get_direct_descendant(other_person,firstRel),common)
|
return (self.get_direct_descendant(other_person,firstRel),common)
|
||||||
elif len(firstRel) == 1:
|
elif len(firstRel) == 1:
|
||||||
if other_person.get_gender() == gen.lib.Person.MALE:
|
if other_person == gen.lib.Person.MALE:
|
||||||
return (self.get_ancestors_brother(secondRel),common)
|
return (self.get_ancestors_brother(secondRel),common)
|
||||||
else:
|
else:
|
||||||
return (self.get_ancestors_sister(secondRel),common)
|
return (self.get_ancestors_sister(secondRel),common)
|
||||||
@ -263,6 +238,16 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
|||||||
return (self.get_ancestors_cousin(other_person,secondRel,firstRel),common)
|
return (self.get_ancestors_cousin(other_person,secondRel,firstRel),common)
|
||||||
else:
|
else:
|
||||||
return (self.get_cousins_descendant(other_person,firstRel,secondRel),common)
|
return (self.get_cousins_descendant(other_person,firstRel,secondRel),common)
|
||||||
|
|
||||||
|
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(reltocommon_a, reltocommon_b, 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_two_way_rel(gender_b,"","")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user