1683 Untranslatable text in Relationship calculator window - no crash on rel_xx tests - get working with current API (contribution by Andrew I Baznikin, lcc)

svn: r14021
This commit is contained in:
Jérôme Rapinat 2010-01-10 16:32:57 +00:00
parent 04763f50fe
commit 9b7d972c99

View File

@ -149,7 +149,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return "%dº sobrinho" % level
def get_distant_nieve(self, level):
def get_distant_niece(self, level):
if level < len(_level_name_female):
return "%s sobrinha" % (_level_name_female[level])
else:
@ -246,84 +246,71 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return "%dª sobrinha neta" % (level-1)
def get_relationship(self, orig_person, other_person):
def get_relationship(self, secondRel, firstRel, orig_person_gender, other_person_gender):
"""
returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father, mother)
"""
if orig_person is None:
return ("indefinido", [])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(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(orig_person, other_person)
if isinstance(common, basestring):
return (common, [])
elif common:
person_handle = common[0]
else:
return ("", [])
firstRel = len(firstRel)
secondRel = len(secondRel)
common = ""
if firstRel == 0:
if secondRel == 0:
return ('', common)
elif other_person.get_gender() == gen.lib.Person.MALE:
elif other_person_gender == gen.lib.Person.MALE:
return (self.get_father(secondRel), common)
else:
return (self.get_mother(secondRel), common)
elif secondRel == 0:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return (self.get_son(firstRel), common)
else:
return (self.get_daughter(firstRel), common)
elif firstRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return (self.get_uncle(secondRel), common)
else:
return (self.get_aunt(secondRel), common)
elif secondRel == 1:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return (self.get_nephew(firstRel-1), common)
else:
return (self.get_niece(firstRel-1), common)
elif firstRel == secondRel == 2:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return ('primo irmão', common)
else:
return ('prima irmã', common)
elif firstRel == secondRel:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return (self.get_male_cousin(firstRel-1), common)
else:
return (self.get_female_cousin(firstRel-1), common)
elif firstRel == secondRel+1:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return (self.get_distant_nephew(secondRel), common)
else:
return (self.get_distant_niece(secondRel), common)
elif firstRel+1 == secondRel:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return (self.get_distant_uncle(firstRel), common)
else:
return (self.get_distant_aunt(firstRel), common)
else:
if other_person.get_gender() == gen.lib.Person.MALE:
if other_person_gender == gen.lib.Person.MALE:
return (self.get_male_relative(firstRel, secondRel), common)
else:
return (self.get_female_relative(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(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