Fixed error with some step relations.

svn: r11014
This commit is contained in:
Peter Landgren 2008-09-03 18:13:55 +00:00
parent 167e361db2
commit b77cfeeffa

View File

@ -3,6 +3,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2003-2006 Donald N. Allingham
# Copyright (C) 2008 Peter G. Landgren
# #
# 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
@ -115,7 +116,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
gen_result = [ item + 's' for item in result[0:-1] ] gen_result = [ item + 's' for item in result[0:-1] ]
gen_result = ' '.join(gen_result+result[-1:]) gen_result = ' '.join(gen_result+result[-1:])
if len(rel_list)>1 and step != '': if len(rel_list)>1 and step != '':
# Indicate step relation8s) by adding ' [styv]' # Indicate step relations) by adding ' [styv]'
gen_result = gen_result + ' [styv]' gen_result = gen_result + ' [styv]'
return gen_result return gen_result
@ -138,8 +139,10 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if inlaw != '': if inlaw != '':
#Preceed with inlaw prefix #Preceed with inlaw prefix
result[-1] = u'svär' + result[-1] result[-1] = u'svär' + result[-1]
if len(result)>1 and len(result) % 2 == 0 and (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''): if len(result)>1 and len(result) % 2 == 0 and \
# Correct string "-2" with genitive s and add a space to get correctSwedish, if even number in result (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's ' result[-2] = result[-2] + 's '
return self.pair_up(result, step) return self.pair_up(result, step)
@ -164,8 +167,10 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if inlaw != '': if inlaw != '':
#Preceed with inlaw prefix #Preceed with inlaw prefix
result[-1] = u'svär' + result[-1] result[-1] = u'svär' + result[-1]
if len(result)>1 and len(result) % 2 == 0 and (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''): if len(result)>1 and len(result) % 2 == 0 and \
# Correct string "-2" with genitive s and add a space to get correct Swedish, if even number in result (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's ' result[-2] = result[-2] + 's '
return self.pair_up(result, step) return self.pair_up(result, step)
@ -180,8 +185,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
result.append('mor') result.append('mor')
if inlaw != '' : if inlaw != '' :
inlaw = 'ingifta ' inlaw = 'ingifta '
if inlaw != '' and len(result) % 2 !=0: if len(result) % 2 != 0:
# Correct string "-1" with genitive s and add a space to get correct Swedish, if even number in result # Correct string "-1" with genitive s and add a space to get
# correct Swedish, if odd number of ancestors
result[-1] = result[-1] + 's ' result[-1] = result[-1] + 's '
result.append(self._get_cousin(level, step, inlaw)) result.append(self._get_cousin(level, step, inlaw))
if step != '' and len(result)==1: if step != '' and len(result)==1:
@ -217,8 +223,10 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if inlaw != '': if inlaw != '':
#Preceed with inlaw prefix #Preceed with inlaw prefix
result[-1] = u'svär' + result[-1] result[-1] = u'svär' + result[-1]
if len(result)>1 and len(result) % 2 == 0 and (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''): if len(result)>1 and len(result) % 2 == 0 and \
# Correct string "-2" with genitive s and add a space to get correct Swedish, if even number in result (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's ' result[-2] = result[-2] + 's '
return self.pair_up(result, step) return self.pair_up(result, step)
@ -239,8 +247,10 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if inlaw != '' and person_gender == gen.lib.Person.UNKNOWN: if inlaw != '' and person_gender == gen.lib.Person.UNKNOWN:
#Preceed with inlaw prefix #Preceed with inlaw prefix
result[-1] = u'svåger/svägerska' result[-1] = u'svåger/svägerska'
if len(result)>1 and len(result) % 2 == 0 and (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''): if len(result)>1 and len(result) % 2 == 0 and \
# Correct string "-2" with genitive s and add a space to get correct Swedish, if even number in result (person_gender == gen.lib.Person.UNKNOWN or inlaw != ''):
# Correct string "-2" with genitive s and add a space to get
# correct Swedish, if even number in result
result[-2] = result[-2] + 's ' result[-2] = result[-2] + 's '
return self.pair_up(result, step) return self.pair_up(result, step)
@ -369,7 +379,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
# being in a higher generation from the common ancestor than the # being in a higher generation from the common ancestor than the
# first person. # first person.
if Gb <= len(_level_name): if Gb <= len(_level_name):
rel_str = u"förfäders " + self._get_cousin_kinship(Ga) + " i "+ _level_name[Gb] + " generationen" rel_str = u"förfäders " + self._get_cousin_kinship(Ga) + \
" i "+ _level_name[Gb] + " generationen"
else: else:
rel_str = u"avlägsna kusiner" rel_str = u"avlägsna kusiner"
elif Gb > 1 and Gb > Ga: elif Gb > 1 and Gb > Ga:
@ -509,7 +520,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
# being in a lower generation from the common ancestor than the # being in a lower generation from the common ancestor than the
# first person. # first person.
rel_str = self._get_cousins_descendant(gender_b, reltocommon_b, reltocommon_a, step, inlaw) rel_str = self._get_cousins_descendant(gender_b, reltocommon_b, reltocommon_a, step, inlaw)
return rel_str # the replace method is to avoid double step indications. Can't figure out why.
return rel_str.replace (' [styv] [styv]', ' [styv]')
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #