use of functions

svn: r15406
This commit is contained in:
Jérôme Rapinat 2010-05-13 17:52:00 +00:00
parent a1c96c8a93
commit 75d8575909

View File

@ -168,29 +168,16 @@ _NEPHEWS_NIECES_LEVEL = [u"", u"les neveux et les nièces",
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
"""
RelationshipCalculator Class
"""
# RelCalc tool - Status Bar
INLAW = u' (par alliance)'
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
# from active person to common ancestor Ga=[level]
def get_cousin(self, level, removed, inlaw=""):
def get_cousin(level, removed, inlaw=""):
"""
cousins = same level, gender = male
"""
if removed == 0 and level < len(_LEVEL_NAME):
return "le %s cousin%s" % (_REMOVED_LEVEL[level - 1], inlaw)
elif level < removed:
self.get_uncle(level - 1, inlaw)
get_uncle(level - 1, inlaw)
elif level < 30:
# limitation gen = 30
@ -204,14 +191,14 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
return u"le cousin lointain, relié à la %dème génération" % \
(level + 1)
def get_cousine(self, level, removed, inlaw=""):
def get_cousine(level, removed, inlaw=""):
"""
cousines = same level, gender = female
"""
if removed == 0 and level < len(_LEVEL_NAME):
return "la %s cousine%s" % (_LEVEL_NAME[level - 1], inlaw)
elif level < removed:
self.get_aunt(level - 1, inlaw)
get_aunt(level - 1, inlaw)
elif level < 30:
# limitation gen = 30
@ -225,7 +212,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
return u"la cousine lointaine, reliée à la %dème génération" % \
(level + 1)
def get_parents(self, level):
def get_parents(level):
"""
ancestors
"""
@ -243,7 +230,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _PARENTS_LEVEL[level]
def get_father(self, level, inlaw=""):
def get_father(level, inlaw=""):
"""
ancestor, gender = male
"""
@ -261,7 +248,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _FATHER_LEVEL[level] % inlaw
def get_mother(self, level, inlaw=""):
def get_mother(level, inlaw=""):
"""
ancestor, gender = female
"""
@ -279,7 +266,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _MOTHER_LEVEL[level] % inlaw
def get_parent_unknown(self, level, inlaw=""):
def get_parent_unknown(level, inlaw=""):
"""
unknown parent
"""
@ -294,7 +281,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return u"un parent lointain%s" % inlaw
def get_son(self, level, inlaw=""):
def get_son(level, inlaw=""):
"""
descendant, gender = male
"""
@ -312,7 +299,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _SON_LEVEL[level] % inlaw
def get_daughter(self, level, inlaw=""):
def get_daughter(level, inlaw=""):
"""
descendant, gender = female
"""
@ -330,7 +317,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _DAUGHTER_LEVEL[level] % inlaw
def get_child_unknown(self, level, inlaw=""):
def get_child_unknown(level, inlaw=""):
"""
descendant, gender = unknown
"""
@ -345,13 +332,13 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return u"un descendant lointain%s" % inlaw
def get_sibling_unknown(self, inlaw=""):
def get_sibling_unknown(inlaw=""):
"""
sibling of an ancestor, gender = unknown
"""
return u"un parent lointain%s" % inlaw
def get_uncle(self, level, inlaw=""):
def get_uncle(level, inlaw=""):
"""
sibling of an ancestor, gender = male
"""
@ -370,7 +357,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _BROTHER_LEVEL[level] % inlaw
def get_aunt(self, level, inlaw=""):
def get_aunt(level, inlaw=""):
"""
sibling of an ancestor, gender = female
"""
@ -389,7 +376,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _SISTER_LEVEL[level] % inlaw
def get_nephew(self, level, inlaw=""):
def get_nephew(level, inlaw=""):
"""
cousin of a descendant, gender = male
"""
@ -406,7 +393,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _NEPHEW_LEVEL[level] % inlaw
def get_niece(self, level, inlaw=""):
def get_niece(level, inlaw=""):
"""
cousin of a descendant, gender = female
"""
@ -424,6 +411,16 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else:
return _NIECE_LEVEL[level] % inlaw
class RelationshipCalculator(Relationship.RelationshipCalculator):
"""
RelationshipCalculator Class
"""
INLAW = u' (par alliance)'
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
# kinship report
def get_plural_relationship_string(self, Ga, Gb,
@ -580,7 +577,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if inlaw and Gb == 1 and not step:
rel_str = u"le gendre"
else:
rel_str = self.get_son(Gb)
rel_str = get_son(Gb)
elif gender_b == gen.lib.Person.FEMALE and Gb < len(_DAUGHTER_LEVEL):
# spouse of son
@ -588,7 +585,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if inlaw and Gb == 1 and not step:
rel_str = u"la bru"
else:
rel_str = self.get_daughter(Gb)
rel_str = get_daughter(Gb)
elif Gb < len(_LEVEL_NAME) and gender_b == gen.lib.Person.MALE:
# don't display inlaw
@ -599,7 +596,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rel_str = u"la descendante lointaine (%dème génération)" % \
(Gb + 1)
else:
return self.get_child_unknown(Gb)
return get_child_unknown(Gb)
elif Gb == 0:
# b is parents/grand parent of a
@ -616,7 +613,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rel_str = u"le père du conjoint"
else:
rel_str = self.get_father(Ga, inlaw)
rel_str = get_father(Ga, inlaw)
elif gender_b == gen.lib.Person.FEMALE and Ga < len(_MOTHER_LEVEL):
# other spouse of mother (new parent)
@ -629,7 +626,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rel_str = u"la mère du conjoint"
else:
rel_str = self.get_mother(Ga, inlaw)
rel_str = get_mother(Ga, inlaw)
elif Ga < len(_LEVEL_NAME) and gender_b == gen.lib.Person.MALE:
rel_str = u"l'ascendant lointain%s (%dème génération)" % \
(inlaw, Ga + 1)
@ -637,15 +634,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rel_str = u"l'ascendante lointaine%s (%dème génération)" % \
(inlaw, Ga + 1)
else:
return self.get_parent_unknown(Ga, inlaw)
return get_parent_unknown(Ga, inlaw)
elif Gb == 1:
# b is sibling/aunt/uncle of a
if gender_b == gen.lib.Person.MALE and Ga < len(_BROTHER_LEVEL):
rel_str = self.get_uncle(Ga, inlaw)
rel_str = get_uncle(Ga, inlaw)
elif gender_b == gen.lib.Person.FEMALE and Ga < len(_SISTER_LEVEL):
rel_str = self.get_aunt(Ga, inlaw)
rel_str = get_aunt(Ga, inlaw)
else:
# don't display inlaw
@ -655,7 +652,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
elif gender_b == gen.lib.Person.FEMALE:
rel_str = u"la tante lointaine" + bygen % (Ga + 1)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(inlaw)
rel_str = get_sibling_unknown(inlaw)
else:
return rel_str
elif Ga == 1:
@ -663,9 +660,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
# b is niece/nephew of a
if gender_b == gen.lib.Person.MALE and Gb < len(_NEPHEW_LEVEL):
rel_str = self.get_nephew(Gb - 1, inlaw)
rel_str = get_nephew(Gb - 1, inlaw)
elif gender_b == gen.lib.Person.FEMALE and Gb < len(_NIECE_LEVEL):
rel_str = self.get_niece(Gb - 1, inlaw)
rel_str = get_niece(Gb - 1, inlaw)
else:
if gender_b == gen.lib.Person.MALE:
rel_str = u"le neveu lointain%s (%dème génération)" % \
@ -674,7 +671,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rel_str = u"la nièce lointaine%s (%dème génération)" % \
(inlaw, Gb)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(inlaw)
rel_str = get_sibling_unknown(inlaw)
else:
return rel_str
elif Ga == Gb:
@ -682,11 +679,11 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
# a and b cousins in the same generation
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_cousin(Ga - 1, 0, inlaw=inlaw)
rel_str = get_cousin(Ga - 1, 0, inlaw=inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_cousine(Ga - 1, 0, inlaw=inlaw)
rel_str = get_cousine(Ga - 1, 0, inlaw=inlaw)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(inlaw)
rel_str = get_sibling_unknown(inlaw)
else:
return rel_str
elif Ga > 1 and Ga > Gb:
@ -703,7 +700,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
desc = u" (cousine germaine d'un parent)"
rel_str = u"la tante à la mode de Bretagne" + desc
elif gender_b == gen.lib.Person.UNKNOWN:
return self.get_sibling_unknown(Ga, inlaw)
return get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Gb <= len(_LEVEL_NAME) and Ga - Gb < len(_REMOVED_LEVEL) and \
@ -717,16 +714,16 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
elif gender_b == gen.lib.Person.FEMALE:
rel_str = u"la tante" + can + civ
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
rel_str = get_sibling_unknown(Ga, inlaw)
else:
return rel_str
else:
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_uncle(Ga, inlaw)
rel_str = get_uncle(Ga, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_aunt(Ga, inlaw)
rel_str = get_aunt(Ga, inlaw)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
rel_str = get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Gb > 1 and Gb > Ga:
@ -742,7 +739,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
elif gender_b == gen.lib.Person.FEMALE:
rel_str = u"la nièce à la mode de Bretagne" + info
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
rel_str = get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Ga <= len(_LEVEL_NAME) and Gb - Ga < len(_REMOVED_LEVEL) and \
@ -756,18 +753,18 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if gender_b == gen.lib.Person.FEMALE:
rel_str = u"la nièce" + can + civ
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
rel_str = get_sibling_unknown(Ga, inlaw)
else:
return rel_str
elif Ga > len(_LEVEL_NAME):
return rel_str
else:
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_nephew(Ga, inlaw)
rel_str = get_nephew(Ga, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_niece(Ga, inlaw)
rel_str = get_niece(Ga, inlaw)
elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw)
rel_str = get_sibling_unknown(Ga, inlaw)
else:
return rel_str
return rel_str