From 9e8f1e8d7d1719404cd224ca826631b77c51d6e7 Mon Sep 17 00:00:00 2001 From: Peter Landgren Date: Fri, 5 Sep 2008 19:40:30 +0000 Subject: [PATCH] Better fix of error in step and cousin relations. svn: r11025 --- src/plugins/rel_sv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/rel_sv.py b/src/plugins/rel_sv.py index 5b8213aed..a05d609ba 100644 --- a/src/plugins/rel_sv.py +++ b/src/plugins/rel_sv.py @@ -85,6 +85,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return u"avlägset släkt" else: result = inlaw + _cousin_level[level] + # Indicate step relations) by adding ' [styv]' if step: result = result + ' [styv]' return result @@ -95,7 +96,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): for word in rel_list[:]: if not word: continue - if word in _cousin_level: + if word.replace(' [styv]', '') in _cousin_level: if item: result.append(item) item = "" @@ -115,8 +116,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append(item) gen_result = [ item + 's' for item in result[0:-1] ] gen_result = ' '.join(gen_result+result[-1:]) - if len(rel_list)>1 and step != '': - # Indicate step relations) by adding ' [styv]' + # Indicate step relations) by adding ' [styv]' if not already added. + if len(rel_list)>1 and step != '' and not gen_result.rfind(' [styv]'): gen_result = gen_result + ' [styv]' return gen_result @@ -516,8 +517,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # being in a lower generation from the common ancestor than the # first person. rel_str = self._get_cousins_descendant(gender_b, reltocommon_b, reltocommon_a, step, inlaw) - # the replace method is to avoid double step indications. Can't figure out why. - return rel_str.replace (' [styv] [styv]', ' [styv]') + return rel_str #------------------------------------------------------------------------- #