diff --git a/src/plugins/rel/rel_da.py b/src/plugins/rel/rel_da.py index 16b1699e1..cba49adad 100644 --- a/src/plugins/rel/rel_da.py +++ b/src/plugins/rel/rel_da.py @@ -196,3 +196,20 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_direct_descendant(other_person,firstRel),common) else: return (self.get_two_way_rel(other_person,firstRel,secondRel),common) + +if __name__ == "__main__": + + # Test function. Call it as follows from the command line (so as to find + # imported modules): + # export PYTHONPATH=/path/to/gramps/src + # python src/plugins/rel/rel_da.py + # (Above not needed here) + + """TRANSLATORS, copy this if statement at the bottom of your + rel_xx.py module, and test your work with: + python src/plugins/rel/rel_xx.py + """ + from Relationship import test + RC = RelationshipCalculator() + test(RC, True) + diff --git a/src/plugins/rel/rel_de.py b/src/plugins/rel/rel_de.py index 7b2ad196f..4559cb541 100644 --- a/src/plugins/rel/rel_de.py +++ b/src/plugins/rel/rel_de.py @@ -281,12 +281,12 @@ if __name__ == "__main__": # Test function. Call it as follows from the command line (so as to find # imported modules): # export PYTHONPATH=/path/to/gramps/src - # python src/plugins/rel_fr.py + # python src/plugins/rel/rel_de.py # (Above not needed here) """TRANSLATORS, copy this if statement at the bottom of your rel_xx.py module, and test your work with: - python src/plugins/rel_xx.py + python src/plugins/rel/rel_xx.py """ from Relationship import test rc = RelationshipCalculator() diff --git a/src/plugins/rel/rel_es.py b/src/plugins/rel/rel_es.py index 1d656d12e..6cbce9723 100644 --- a/src/plugins/rel/rel_es.py +++ b/src/plugins/rel/rel_es.py @@ -326,3 +326,19 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_male_relative(firstRel,secondRel),common) else: return (self.get_female_relative(firstRel,secondRel),common) + +if __name__ == "__main__": + + # Test function. Call it as follows from the command line (so as to find + # imported modules): + # export PYTHONPATH=/path/to/gramps/src + # python src/plugins/rel/rel_es.py + # (Above not needed here) + + """TRANSLATORS, copy this if statement at the bottom of your + rel_xx.py module, and test your work with: + python src/plugins/rel/rel_xx.py + """ + from Relationship import test + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_fi.py b/src/plugins/rel/rel_fi.py index c327ca30e..9d5c2034b 100644 --- a/src/plugins/rel/rel_fi.py +++ b/src/plugins/rel/rel_fi.py @@ -213,3 +213,19 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_ancestors_cousin(secondRel,firstRel),common) else: return (self.get_cousins_descendant(other_person,firstRel,secondRel),common) + +if __name__ == "__main__": + + # Test function. Call it as follows from the command line (so as to find + # imported modules): + # export PYTHONPATH=/path/to/gramps/src + # python src/plugins/rel/rel_fi.py + # (Above not needed here) + + """TRANSLATORS, copy this if statement at the bottom of your + rel_xx.py module, and test your work with: + python src/plugins/rel/rel_xx.py + """ + from Relationship import test + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_fr.py b/src/plugins/rel/rel_fr.py index 86a88316d..5550bcd7b 100644 --- a/src/plugins/rel/rel_fr.py +++ b/src/plugins/rel/rel_fr.py @@ -1,11 +1,10 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2007 Donald N. Allingham # Copyright (C) 2008-2009 Brian G. Matherly -# Copyright (C) 2007-2009 Jerome Rapinat +# Copyright (C) 2007-2010 Jerome Rapinat # # 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 @@ -36,132 +35,132 @@ import Relationship #------------------------------------------------------------------------- -# level is used for generation level: -# at %th generation +# level est utilisé pour trouver/afficher le niveau de la génération : +# à la %sème génération -_LEVEL_NAME = [ - "première", - "deuxième", - "troisième", - "quatrième", - "cinquième", - "sixième", - "septième", - "huitième", - "neuvième", - "dixième", - "onzième", - "douzième", - "treizième", - "quatorzième", - "quinzième", - "seizième", - "dix-septième", - "dix-huitième", - "dix-neuvième", - "vingtième", - "vingt-et-unième", - "vingt-deuxième", - "vingt-troisième", - "vingt-quatrième", - "vingt-cinquième", - "vingt-sixième", - "vingt-septième", - "vingt-huitième", - "vingt-neuvième", - "trentième", +_level_name = [ + u"première", + u"deuxième", + u"troisième", + u"quatrième", + u"cinquième", + u"sixième", + u"septième", + u"huitième", + u"neuvième", + u"dixième", + u"onzième", + u"douzième", + u"treizième", + u"quatorzième", + u"quinzième", + u"seizième", + u"dix-septième", + u"dix-huitième", + u"dix-neuvième", + u"vingtième", + u"vingt-et-unième", + u"vingt-deuxième", + u"vingt-troisième", + u"vingt-quatrième", + u"vingt-cinquième", + u"vingt-sixième", + u"vingt-septième", + u"vingt-huitième", + u"vingt-neuvième", + u"trentième", ] -# for degree (canon et civil), limitation 20+20 also used for -# the first [premier] cousin +# pour le degrè (canon et civil), limitation 20+20 ainsi que pour +# LE [premier] cousin -_REMOVED_LEVEL = [ - "premier", - "deuxième", - "troisième", - "quatrième", - "cinquième", - "sixième", - "septième", - "huitième", - "neuvième", - "dixième", - "onzième", - "douzième", - "treizième", - "quatorzième", - "quinzième", - "seizième", - "dix-septième", - "dix-huitième", - "dix-neuvième", - "vingtième", - "vingt-et-unième", - "vingt-deuxième", - "vingt-troisième", - "vingt-quatrième", - "vingt-cinquième", - "vingt-sixième", - "vingt-septième", - "vingt-huitième", - "vingt-neuvième", - "trentième", - "trente-et-unième", - "trente-deuxième", - "trente-troisième", - "trente-quatrième", - "trente-cinquième", - "trente-sixième", - "trente-septième", - "trente-huitième", - "trente-neuvième", - "quarantième", - "quanrante-et-unième", +_removed_level = [ + u"premier", + u"deuxième", + u"troisième", + u"quatrième", + u"cinquième", + u"sixième", + u"septième", + u"huitième", + u"neuvième", + u"dixième", + u"onzième", + u"douzième", + u"treizième", + u"quatorzième", + u"quinzième", + u"seizième", + u"dix-septième", + u"dix-huitième", + u"dix-neuvième", + u"vingtième", + u"vingt-et-unième", + u"vingt-deuxième", + u"vingt-troisième", + u"vingt-quatrième", + u"vingt-cinquième", + u"vingt-sixième", + u"vingt-septième", + u"vingt-huitième", + u"vingt-neuvième", + u"trentième", + u"trente-et-unième", + u"trente-deuxième", + u"trente-troisième", + u"trente-quatrième", + u"trente-cinquième", + u"trente-sixième", + u"trente-septième", + u"trente-huitième", + u"trente-neuvième", + u"quarantième", + u"quanrante-et-unième", ] -# small lists, use generation level if > [5] +# listes volontairement limitées | small lists, use generation level if > [5] -_FATHER_LEVEL = ["", "le père%s", "le grand-père%s", - "l'arrière-grand-père%s", "le trisaïeul%s"] +_father_level = [u"", u"le père%s", u"le grand-père%s", + u"l'arrière-grand-père%s", u"le trisaïeul%s"] -_MOTHER_LEVEL = ["", "la mère%s", "la grand-mère%s", - "l'arrière-grand-mère%s", "la trisaïeule%s"] +_mother_level = [u"", u"la mère%s", u"la grand-mère%s", + u"l'arrière-grand-mère%s", u"la trisaïeule%s"] -_SON_LEVEL = ["", "le fils%s", "le petit-fils%s", - "l'arrière-petit-fils%s"] +_son_level = [u"", u"le fils%s", u"le petit-fils%s", + u"l'arrière-petit-fils%s"] -_DAUGHTER_LEVEL = ["", "la fille%s", "la petite-fille%s", - "l'arrière-petite-fille%s"] +_daughter_level = [u"", u"la fille%s", u"la petite-fille%s", + u"l'arrière-petite-fille%s"] -_SISTER_LEVEL = ["", "la sœur%s", "la tante%s", "la grand-tante%s", - "l'arrière-grand-tante%s"] +_sister_level = [u"", u"la sœur%s", u"la tante%s", u"la grand-tante%s", + u"l'arrière-grand-tante%s"] -_BROTHER_LEVEL = ["", "le frère%s", "l'oncle%s", "le grand-oncle%s", - "l'arrière-grand-oncle%s"] +_brother_level = [u"", u"le frère%s", u"l'oncle%s", u"le grand-oncle%s", + u"l'arrière-grand-oncle%s"] -_NEPHEW_LEVEL = ["", "le neveu%s", "le petit-neveu%s", - "l'arrière-petit-neveu%s"] +_nephew_level = [u"", u"le neveu%s", u"le petit-neveu%s", + u"l'arrière-petit-neveu%s"] -_NIECE_LEVEL = ["", "la nièce%s", "la petite-nièce%s", - "l'arrière-petite-nièce%s"] +_niece_level = [u"", u"la nièce%s", u"la petite-nièce%s", + u"l'arrière-petite-nièce%s"] # kinship report -_PARENTS_LEVEL = ["", "les parents", "les grands-parents", - "les arrières-grands-parents", "les trisaïeux"] +_parents_level = [u"", u"les parents", u"les grands-parents", + u"les arrières-grands-parents", u"les trisaïeux"] -_CHILDREN_LEVEL = ["", "les enfants", "les petits-enfants", - "les arrières-petits-enfants", - "les arrières-arrières-petits-enfants"] +_children_level = [u"", u"les enfants", u"les petits-enfants", + u"les arrières-petits-enfants", + u"les arrières-arrières-petits-enfants"] -_SIBLINGS_LEVEL = ["", "les frères et les sœurs", - "les oncles et les tantes", - "les grands-oncles et les grands-tantes", - "les arrières-grands-oncles et les arrières-grands-tantes"] +_siblings_level = [u"", u"les frères et les sœurs", + u"les oncles et les tantes", + u"les grands-oncles et les grands-tantes", + u"les arrières-grands-oncles et les arrières-grands-tantes"] -_NEPHEWS_NIECES_LEVEL = ["", "les neveux et les nièces", - "les petits-neveux et les petites-nièces", - "les arrière-petits-neveux et les arrières-petites-nièces"] +_nephews_nieces_level = [u"", u"les neveux et les nièces", + u"les petits-neveux et les petites-nièces", + u"les arrière-petits-neveux et les arrières-petites-nièces"] #------------------------------------------------------------------------- # @@ -171,164 +170,119 @@ _NEPHEWS_NIECES_LEVEL = ["", "les neveux et les nièces", class RelationshipCalculator(Relationship.RelationshipCalculator): - """ - RelationshipCalculator Class - """ - # RelCalc tool - Status Bar - - INLAW = ' (par alliance)' + INLAW = u' (par alliance)' def __init__(self): Relationship.RelationshipCalculator.__init__(self) - # from active person to common ancestor Ga=[level] +# RelCalc tool - Status Bar - def get_cousin(self, 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) +# de la personne active à l'ascendant commun Ga=[level] + + def get_cousin(self, level, removed, dir="", inlaw=""): + if removed == 0 and level < len(_level_name): + return u"le %s cousin%s" % (_removed_level[level - 1], inlaw) elif level < removed: - self.get_uncle(level - 1, inlaw) + rel_str = self.get_uncle(level - 1, inlaw) else: # limitation gen = 29 - return "le cousin lointain, relié à la %s génération" % \ - _LEVEL_NAME[removed] + return u"le cousin lointain, relié à la %s génération" % \ + _level_name[removed] - def get_cousine(self, 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) + def get_cousine(self, level, removed, dir="", inlaw=""): + if removed == 0 and level < len(_level_name): + return u"la %s cousine%s" % (_level_name[level - 1], inlaw) elif level < removed: - self.get_aunt(level - 1, inlaw) + rel_str = self.get_aunt(level - 1, inlaw) else: - return "la cousine lointaine, reliée à la %s génération" % \ - _LEVEL_NAME[removed] + return u"la cousine lointaine, reliée à la %s génération" % \ + _level_name[removed] def get_parents(self, level): - """ - ancestors - """ - if level > len(_PARENTS_LEVEL) - 1: - return "les ascendants lointains, à la %s génération" % \ - _LEVEL_NAME[level] + if level > len(_parents_level) - 1: + return u"les ascendants lointains, à la %s génération" % \ + _level_name[level] else: - return _PARENTS_LEVEL[level] + return _parents_level[level] def get_father(self, level, inlaw=""): - """ - ancestor, gender = male - """ - if level > len(_FATHER_LEVEL) - 1: - return "l'ascendant lointain, à la %s génération" % \ - _LEVEL_NAME[level] + if level > len(_father_level) - 1: + return u"l'ascendant lointain, à la %s génération" % \ + _level_name[level] else: - return _FATHER_LEVEL[level] % inlaw + return _father_level[level] % inlaw def get_mother(self, level, inlaw=""): - """ - ancestor, gender = female - """ - if level > len(_MOTHER_LEVEL) - 1: - return "l'ascendante lointaine, à la %s génération" % \ - _LEVEL_NAME[level] + if level > len(_mother_level) - 1: + return u"l'ascendante lointaine, à la %s génération" % \ + _level_name[level] else: - return _MOTHER_LEVEL[level] % inlaw + return _mother_level[level] % inlaw def get_parent_unknown(self, level, inlaw=""): - """ - unknown parent - """ - if level > len(_LEVEL_NAME) - 1: - return "l'ascendant lointain, à la %s génération" % \ - _LEVEL_NAME[level] + if level > len(_level_name) - 1: + return u"l'ascendant lointain, à la %s génération" % \ + _level_name[level] elif level == 1: - return "un parent%s" % inlaw + return u"un parent%s" % inlaw else: - return "un parent lointain%s" % inlaw + return u"un parent lointain%s" % inlaw def get_son(self, level, inlaw=""): - """ - descendant, gender = male - """ - if level > len(_SON_LEVEL) - 1: - return "le descendant lointain, à la %s génération" % \ - _LEVEL_NAME[level + 1] + if level > len(_son_level) - 1: + return u"le descendant lointain, à la %s génération" % \ + _level_name[level + 1] else: - return _SON_LEVEL[level] % inlaw + return _son_level[level] % inlaw def get_daughter(self, level, inlaw=""): - """ - descendant, gender = female - """ - if level > len(_DAUGHTER_LEVEL) - 1: - return "la descendante lointaine, à la %s génération" % \ - _LEVEL_NAME[level + 1] + if level > len(_daughter_level) - 1: + return u"la descendante lointaine, à la %s génération" % \ + _level_name[level + 1] else: - return _DAUGHTER_LEVEL[level] % inlaw + return _daughter_level[level] % inlaw def get_child_unknown(self, level, inlaw=""): - """ - descendant, gender = unknown - """ - if level > len(_LEVEL_NAME) - 1: - return "le descendant lointain, à la %s génération" % \ - _LEVEL_NAME[level + 1] + if level > len(_level_name) - 1: + return u"le descendant lointain, à la %s génération" % \ + _level_name[level + 1] elif level == 1: - return "un enfant%s" % inlaw + return u"un enfant%s" % inlaw else: - return "un descendant lointain%s" % inlaw + return u"un descendant lointain%s" % inlaw - def get_sibling_unknown(self, inlaw=""): - """ - sibling of an ancestor, gender = unknown - """ - return "un parent lointain%s" % inlaw + def get_sibling_unknown(self, level, inlaw=""): + return u"un parent lointain%s" % inlaw def get_uncle(self, level, inlaw=""): - """ - sibling of an ancestor, gender = male - """ - if level > len(_BROTHER_LEVEL) - 1: - return "l'oncle lointain, relié à la %s génération" % \ - _LEVEL_NAME[level] + if level > len(_brother_level) - 1: + return u"l'oncle lointain, relié à la %s génération" % \ + _level_name[level] else: - return _BROTHER_LEVEL[level] % inlaw + return _brother_level[level] % inlaw def get_aunt(self, level, inlaw=""): - """ - sibling of an ancestor, gender = female - """ - if level > len(_SISTER_LEVEL) - 1: - return "la tante lointaine, reliée à la %s génération" % \ - _LEVEL_NAME[level] + if level > len(_sister_level) - 1: + return u"la tante lointaine, reliée à la %s génération" % \ + _level_name[level] else: - return _SISTER_LEVEL[level] % inlaw + return _sister_level[level] % inlaw def get_nephew(self, level, inlaw=""): - """ - cousin of a descendant, gender = male - """ - if level > len(_NEPHEW_LEVEL) - 1: - return "le neveu lointain, à la %s génération" % _LEVEL_NAME[level] + if level > len(_nephew_level) - 1: + return u"le neveu lointain, à la %s génération" % _level_name[level] else: - return _NEPHEW_LEVEL[level] % inlaw + return _nephew_level[level] % inlaw def get_niece(self, level, inlaw=""): - """ - cousin of a descendant, gender = female - """ - if level > len(_NIECE_LEVEL) - 1: - return "la nièce lointaine, à la %s génération" % \ - _LEVEL_NAME[level] + if level > len(_niece_level) - 1: + return u"la nièce lointaine, à la %s génération" % \ + _level_name[level] else: - return _NIECE_LEVEL[level] % inlaw + return _niece_level[level] % inlaw # kinship report @@ -337,61 +291,61 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): voir Relationship.py """ - rel_str = "des parents lointains" - atgen = " à la %sème génération" - bygen = " par la %sème génération" - cmt = " (frères ou sœurs d'un ascendant" + atgen % Ga + ")" + rel_str = u"des parents lointains" + gen = u" à la %sème génération" + bygen = u" par la %sème génération" + cmt = u" (frères ou sœurs d'un ascendant" + gen % Ga + ")" if Ga == 0: # These are descendants - if Gb < len(_CHILDREN_LEVEL): - rel_str = _CHILDREN_LEVEL[Gb] + if Gb < len(_children_level): + rel_str = _children_level[Gb] else: - rel_str = "les descendants" + atgen % (Gb + 1) + rel_str = u"les descendants" + gen % (Gb + 1) elif Gb == 0: # These are parents/grand parents - if Ga < len(_PARENTS_LEVEL): - rel_str = _PARENTS_LEVEL[Ga] + if Ga < len(_parents_level): + rel_str = _parents_level[Ga] else: - rel_str = "les ascendants" + atgen % (Ga + 1) + rel_str = u"les ascendants" + gen % (Ga + 1) elif Gb == 1: # These are siblings/aunts/uncles - if Ga < len(_SIBLINGS_LEVEL): - rel_str = _SIBLINGS_LEVEL[Ga] + if Ga < len(_siblings_level): + rel_str = _siblings_level[Ga] else: - rel_str = "Les enfants d'un ascendant" + atgen % (Ga + 1) + \ + rel_str = u"Les enfants d'un ascendant" + gen % (Ga + 1) + \ cmt elif Ga == 1: # These are nieces/nephews - if Gb < len(_NEPHEWS_NIECES_LEVEL): - rel_str = _NEPHEWS_NIECES_LEVEL[Gb - 1] + if Gb < len(_nephews_nieces_level): + rel_str = _nephews_nieces_level[Gb - 1] else: - rel_str = "les neveux et les nièces" + atgen % Gb + rel_str = u"les neveux et les nièces" + gen % Gb elif Ga > 1 and Ga == Gb: # These are cousins in the same generation # use custom level for latin words if Ga == 2: - rel_str = "les cousins germains et cousines germaines" - elif Ga <= len(_LEVEL_NAME): + rel_str = u"les cousins germains et cousines germaines" + elif Ga <= len(_level_name): # %ss for plural - rel_str = "les %ss cousins et cousines" % _LEVEL_NAME[Ga - + rel_str = u"les %ss cousins et cousines" % _level_name[Ga - 2] else: # security - rel_str = "les cousins et cousines" + rel_str = u"les cousins et cousines" elif Ga > 1 and Ga > Gb: # These are cousins in different generations with the second person @@ -400,18 +354,18 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # use custom level for latin words and specific relation if Ga == 3 and Gb == 2: - desc = " (cousins germains d'un parent)" - rel_str = "les oncles et tantes à la mode de Bretagne" + \ + desc = u" (cousins germains d'un parent)" + rel_str = u"les oncles et tantes à la mode de Bretagne" + \ desc - elif Gb <= len(_LEVEL_NAME) and Ga - Gb < len(_REMOVED_LEVEL) and \ - Ga + Gb + 1 < len(_REMOVED_LEVEL): - can = " du %s au %s degré (canon)" % (_REMOVED_LEVEL[Gb], - _REMOVED_LEVEL[Ga]) - civ = " et au %s degré (civil)" % _REMOVED_LEVEL[Ga + Gb + + elif Gb <= len(_level_name) and Ga - Gb < len(_removed_level) and \ + Ga + Gb + 1 < len(_removed_level): + can = u" du %s au %s degré (canon)" % (_removed_level[Gb], + _removed_level[Ga]) + civ = u" et au %s degré (civil)" % _removed_level[Ga + Gb + 1] - rel_str = "les oncles et tantes" + can + civ - elif Ga < len(_LEVEL_NAME): - rel_str = "les grands-oncles et grands-tantes" + bygen % \ + rel_str = u"les oncles et tantes" + can + civ + elif Ga < len(_level_name): + rel_str = u"les grands-oncles et grands-tantes" + bygen % \ (Ga + 1) else: return rel_str @@ -423,18 +377,18 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # use custom level for latin words and specific relation if Ga == 2 and Gb == 3: - info = " (cousins issus d'un germain)" - rel_str = "les neveux et nièces à la mode de Bretagne" + \ + info = u" (cousins issus d'un germain)" + rel_str = u"les neveux et nièces à la mode de Bretagne" + \ info - elif Ga <= len(_LEVEL_NAME) and Gb - Ga < len(_REMOVED_LEVEL) and \ - Ga + Gb + 1 < len(_REMOVED_LEVEL): - can = " du %s au %s degré (canon)" % (_REMOVED_LEVEL[Gb], - _REMOVED_LEVEL[Ga]) - civ = " et au %s degré (civil)" % _REMOVED_LEVEL[Ga + Gb + + elif Ga <= len(_level_name) and Gb - Ga < len(_removed_level) and \ + Ga + Gb + 1 < len(_removed_level): + can = u" du %s au %s degré (canon)" % (_removed_level[Gb], + _removed_level[Ga]) + civ = u" et au %s degré (civil)" % _removed_level[Ga + Gb + 1] - rel_str = "les neveux et nièces" + can + civ - elif Ga < len(_LEVEL_NAME): - rel_str = "les neveux et nièces" + bygen % Gb + rel_str = u"les neveux et nièces" + can + civ + elif Ga < len(_level_name): + rel_str = u"les neveux et nièces" + bygen % Gb else: return rel_str return rel_str @@ -465,40 +419,40 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if in_law_a or in_law_b: inlaw = self.INLAW else: - inlaw = "" + inlaw = u"" - rel_str = "un parent lointains%s" % inlaw - bygen = " par la %sème génération" + rel_str = u"un parent lointains%s" % inlaw + bygen = u" par la %sème génération" if Ga == 0: # b is descendant of a if Gb == 0: - rel_str = 'le même individu' - elif gender_b == gen.lib.Person.MALE and Gb < len(_SON_LEVEL): + rel_str = u"le même individu" + elif gender_b == gen.lib.Person.MALE and Gb < len(_son_level): # spouse of daughter if inlaw and Gb == 1 and not step: - rel_str = "le gendre" + rel_str = u"le gendre" else: rel_str = self.get_son(Gb) - elif gender_b == gen.lib.Person.FEMALE and Gb < len(_DAUGHTER_LEVEL): + elif gender_b == gen.lib.Person.FEMALE and Gb < len(_daughter_level): # spouse of son if inlaw and Gb == 1 and not step: - rel_str = "la bru" + rel_str = u"la bru" else: rel_str = self.get_daughter(Gb) - elif Gb < len(_LEVEL_NAME) and gender_b == gen.lib.Person.MALE: + elif Gb < len(_level_name) and gender_b == gen.lib.Person.MALE: # don't display inlaw - rel_str = "le descendant lointain (%dème génération)" % \ + rel_str = u"le descendant lointain (%dème génération)" % \ (Gb + 1) - elif Gb < len(_LEVEL_NAME) and gender_b == gen.lib.Person.FEMALE: - rel_str = "la descendante lointaine (%dème génération)" % \ + elif Gb < len(_level_name) and gender_b == gen.lib.Person.FEMALE: + rel_str = u"la descendante lointaine (%dème génération)" % \ (Gb + 1) else: return self.get_child_unknown(Gb) @@ -506,37 +460,37 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # b is parents/grand parent of a - if gender_b == gen.lib.Person.MALE and Ga < len(_FATHER_LEVEL): + if gender_b == gen.lib.Person.MALE and Ga < len(_father_level): # other spouse of father (new parent) if Ga == 1 and inlaw and self.STEP_SIB: - rel_str = "le beau-père" + rel_str = u"le beau-père" elif Ga == 1 and inlaw: # father of spouse (family of spouse) - rel_str = "le père du conjoint" + rel_str = u"le père du conjoint" else: rel_str = self.get_father(Ga, inlaw) - elif gender_b == gen.lib.Person.FEMALE and Ga < len(_MOTHER_LEVEL): + elif gender_b == gen.lib.Person.FEMALE and Ga < len(_mother_level): # other spouse of mother (new parent) if Ga == 1 and inlaw and self.STEP_SIB: - rel_str = "la belle-mère" + rel_str = u"la belle-mère" elif Ga == 1 and inlaw: # mother of spouse (family of spouse) - rel_str = "la mère du conjoint" + rel_str = u"la mère du conjoint" else: rel_str = self.get_mother(Ga, inlaw) - elif Ga < len(_LEVEL_NAME) and gender_b == gen.lib.Person.MALE: - rel_str = "l'ascendant lointain%s (%dème génération)" % \ + 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) - elif Ga < len(_LEVEL_NAME) and gender_b == gen.lib.Person.FEMALE: - rel_str = "l'ascendante lointaine%s (%dème génération)" % \ + elif Ga < len(_level_name) and gender_b == gen.lib.Person.FEMALE: + rel_str = u"l'ascendante lointaine%s (%dème génération)" % \ (inlaw, Ga + 1) else: return self.get_parent_unknown(Ga, inlaw) @@ -544,39 +498,39 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # b is sibling/aunt/uncle of a - if gender_b == gen.lib.Person.MALE and Ga < len(_BROTHER_LEVEL): + if gender_b == gen.lib.Person.MALE and Ga < len(_brother_level): rel_str = self.get_uncle(Ga, inlaw) - elif gender_b == gen.lib.Person.FEMALE and Ga < len(_SISTER_LEVEL): + elif gender_b == gen.lib.Person.FEMALE and Ga < len(_sister_level): rel_str = self.get_aunt(Ga, inlaw) else: # don't display inlaw if gender_b == gen.lib.Person.MALE: - rel_str = "l'oncle lointain" + bygen % (Ga + 1) + rel_str = u"l'oncle lointain" + bygen % (Ga + 1) elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la tante lointaine" + bygen % (Ga + 1) + 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 = self.get_sibling_unknown(Ga, inlaw) else: return rel_str elif Ga == 1: # b is niece/nephew of a - if gender_b == gen.lib.Person.MALE and Gb < len(_NEPHEW_LEVEL): + if gender_b == gen.lib.Person.MALE and Gb < len(_nephew_level): rel_str = self.get_nephew(Gb - 1, inlaw) - elif gender_b == gen.lib.Person.FEMALE and Gb < len(_NIECE_LEVEL): + elif gender_b == gen.lib.Person.FEMALE and Gb < len(_niece_level): rel_str = self.get_niece(Gb - 1, inlaw) else: if gender_b == gen.lib.Person.MALE: - rel_str = "le neveu lointain%s (%dème génération)" % \ + rel_str = u"le neveu lointain%s (%dème génération)" % \ (inlaw, Gb) elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la nièce lointaine%s (%dème génération)" % \ + 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 = self.get_sibling_unknown(Ga, inlaw) else: return rel_str elif Ga == Gb: @@ -584,12 +538,12 @@ 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 = self.get_cousin(Ga - 1, 0, dir="", inlaw=inlaw) elif gender_b == gen.lib.Person.FEMALE: - rel_str = self.get_cousine(Ga - 1, 0, inlaw= + rel_str = self.get_cousine(Ga - 1, 0, dir="", inlaw= inlaw) elif gender_b == gen.lib.Person.UNKNOWN: - rel_str = self.get_sibling_unknown(inlaw) + rel_str = self.get_sibling_unknown(Ga - 1, inlaw) else: return rel_str elif Ga > 1 and Ga > Gb: @@ -600,25 +554,25 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): if Ga == 3 and Gb == 2: if gender_b == gen.lib.Person.MALE: - desc = " (cousin germain d'un parent)" - rel_str = "l'oncle à la mode de Bretagne" + desc + desc = u" (cousin germain d'un parent)" + rel_str = u"l'oncle à la mode de Bretagne" + desc elif gender_b == gen.lib.Person.FEMALE: - desc = " (cousine germaine d'un parent)" - rel_str = "la tante à la mode de Bretagne" + desc + 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) else: return rel_str - elif Gb <= len(_LEVEL_NAME) and Ga - Gb < len(_REMOVED_LEVEL) and \ - Ga + Gb + 1 < len(_REMOVED_LEVEL): - can = " du %s au %s degré (canon)" % (_REMOVED_LEVEL[Gb], - _REMOVED_LEVEL[Ga]) - civ = " et au %s degré (civil)" % _REMOVED_LEVEL[Ga + Gb + + elif Gb <= len(_level_name) and Ga - Gb < len(_removed_level) and \ + Ga + Gb + 1 < len(_removed_level): + can = u" du %s au %s degré (canon)" % (_removed_level[Gb], + _removed_level[Ga]) + civ = u" et au %s degré (civil)" % _removed_level[Ga + Gb + 1] if gender_b == gen.lib.Person.MALE: - rel_str = "l'oncle" + can + civ + rel_str = u"l'oncle" + can + civ elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la tante" + can + civ + rel_str = u"la tante" + can + civ elif gender_b == gen.lib.Person.UNKNOWN: rel_str = self.get_sibling_unknown(Ga, inlaw) else: @@ -639,30 +593,30 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # first person. if Ga == 2 and Gb == 3: - info = " (cousins issus d'un germain)" + info = u" (cousins issus d'un germain)" if gender_b == gen.lib.Person.MALE: - rel_str = "le neveu à la mode de Bretagne" + info + rel_str = u"le neveu à la mode de Bretagne" + info elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la nièce à la mode de Bretagne" + info + 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) else: return rel_str - elif Ga <= len(_LEVEL_NAME) and Gb - Ga < len(_REMOVED_LEVEL) and \ - Ga + Gb + 1 < len(_REMOVED_LEVEL): - can = " du %s au %s degré (canon)" % (_REMOVED_LEVEL[Gb], - _REMOVED_LEVEL[Ga]) - civ = " et au %s degré (civil)" % _REMOVED_LEVEL[Ga + Gb + + elif Ga <= len(_level_name) and Gb - Ga < len(_removed_level) and \ + Ga + Gb + 1 < len(_removed_level): + can = u" du %s au %s degré (canon)" % (_removed_level[Gb], + _removed_level[Ga]) + civ = u" et au %s degré (civil)" % _removed_level[Ga + Gb + 1] if gender_b == gen.lib.Person.MALE: - rel_str = "le neveu" + can + civ + rel_str = u"le neveu" + can + civ if gender_b == gen.lib.Person.FEMALE: - rel_str = "la nièce" + can + civ + rel_str = u"la nièce" + can + civ elif gender_b == gen.lib.Person.UNKNOWN: rel_str = self.get_sibling_unknown(Ga, inlaw) else: return rel_str - elif Ga > len(_LEVEL_NAME): + elif Ga > len(_level_name): return rel_str else: if gender_b == gen.lib.Person.MALE: @@ -679,72 +633,69 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): def get_sibling_relationship_string(self, sib_type, gender_a, gender_b, in_law_a=False, in_law_b=False): - """ - voir Relationship.py - """ if in_law_a or in_law_b: inlaw = self.INLAW else: - inlaw = "" + inlaw = u"" if sib_type == self.NORM_SIB: if not inlaw: if gender_b == gen.lib.Person.MALE: - rel_str = 'le frère (germain)' + rel_str = u"le frère (germain)" elif gender_b == gen.lib.Person.FEMALE: - rel_str = 'la sœur (germaine)' + rel_str = u"la sœur (germaine)" else: - rel_str = 'le frère ou la sœur germain(e)' + rel_str = u"le frère ou la sœur germain(e)" else: if gender_b == gen.lib.Person.MALE: - rel_str = "le beau-frère" + rel_str = u"le beau-frère" elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la belle-sœur" + rel_str = u"la belle-sœur" else: - rel_str = "le beau-frère ou la belle-sœur" + rel_str = u"le beau-frère ou la belle-sœur" elif sib_type == self.UNKNOWN_SIB: if not inlaw: if gender_b == gen.lib.Person.MALE: - rel_str = 'le frère' + rel_str = u"le frère" elif gender_b == gen.lib.Person.FEMALE: - rel_str = 'la sœur' + rel_str = u"la sœur" else: - rel_str = 'le frère ou la sœur' + rel_str = u"le frère ou la sœur" else: if gender_b == gen.lib.Person.MALE: - rel_str = "le beau-frère" + rel_str = u"le beau-frère" elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la belle-sœur" + rel_str = u"la belle-sœur" else: - rel_str = "le beau-frère ou la belle-sœur" + rel_str = u"le beau-frère ou la belle-sœur" elif sib_type == self.HALF_SIB_MOTHER: - # for descendants the "half" logic is reversed ! + # Logique inversée ! Pourquoi ? if gender_b == gen.lib.Person.MALE: - rel_str = "le demi-frère consanguin" + rel_str = u"le demi-frère consanguin" elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la demi-sœur consanguine" + rel_str = u"la demi-sœur consanguine" else: - rel_str = "le demi-frère ou la demi-sœur consanguin(e)" + rel_str = u"le demi-frère ou la demi-sœur consanguin(e)" elif sib_type == self.HALF_SIB_FATHER: - # for descendants the "half" logic is reversed ! + # Logique inversée ! Pourquoi ? if gender_b == gen.lib.Person.MALE: - rel_str = "le demi-frère utérin" + rel_str = u"le demi-frère utérin" elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la demi-sœur utérine" + rel_str = u"la demi-sœur utérine" else: - rel_str = "le demi-frère ou la demi-sœur utérin(e)" + rel_str = u"le demi-frère ou la demi-sœur utérin(e)" elif sib_type == self.STEP_SIB: if gender_b == gen.lib.Person.MALE: - rel_str = "le demi-frère" + rel_str = u"le demi-frère" elif gender_b == gen.lib.Person.FEMALE: - rel_str = "la demi-sœur" + rel_str = u"la demi-sœur" else: - rel_str = "le demi-frère ou la demi-sœur" + rel_str = u"le demi-frère ou la demi-sœur" return rel_str if __name__ == "__main__": @@ -752,12 +703,12 @@ if __name__ == "__main__": # Test function. Call it as follows from the command line (so as to find # imported modules): # export PYTHONPATH=/path/to/gramps/src - # python src/plugins/rel_fr.py + # python src/plugins/rel/rel_fr.py # (Above not needed here) """TRANSLATORS, copy this if statement at the bottom of your rel_xx.py module, and test your work with: - python src/plugins/rel_xx.py + python src/plugins/rel/rel_xx.py """ from Relationship import test RC = RelationshipCalculator() diff --git a/src/plugins/rel/rel_hu.py b/src/plugins/rel/rel_hu.py index 4e9bededa..f4526b611 100644 --- a/src/plugins/rel/rel_hu.py +++ b/src/plugins/rel/rel_hu.py @@ -344,3 +344,19 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_male_cousin(firstRel-1), common) else: return (self.get_female_cousin(firstRel-1), common) + +if __name__ == "__main__": + + # Test function. Call it as follows from the command line (so as to find + # imported modules): + # export PYTHONPATH=/path/to/gramps/src + # python src/plugins/rel/rel_hu.py + # (Above not needed here) + + """TRANSLATORS, copy this if statement at the bottom of your + rel_xx.py module, and test your work with: + python src/plugins/rel/rel_xx.py + """ + from Relationship import test + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_no.py b/src/plugins/rel/rel_no.py index e43e0f045..64ed7b6bf 100644 --- a/src/plugins/rel/rel_no.py +++ b/src/plugins/rel/rel_no.py @@ -263,3 +263,19 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_ancestors_cousin(other_person,secondRel,firstRel),common) else: return (self.get_cousins_descendant(other_person,firstRel,secondRel),common) + +if __name__ == "__main__": + + # Test function. Call it as follows from the command line (so as to find + # imported modules): + # export PYTHONPATH=/path/to/gramps/src + # python src/plugins/rel/rel_no.py + # (Above not needed here) + + """TRANSLATORS, copy this if statement at the bottom of your + rel_xx.py module, and test your work with: + python src/plugins/rel/rel_xx.py + """ + from Relationship import test + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_pt.py b/src/plugins/rel/rel_pt.py index f67b27e27..7645fae71 100644 --- a/src/plugins/rel/rel_pt.py +++ b/src/plugins/rel/rel_pt.py @@ -318,3 +318,19 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_male_relative(firstRel,secondRel),common) else: return (self.get_female_relative(firstRel,secondRel),common) + +if __name__ == "__main__": + + # Test function. Call it as follows from the command line (so as to find + # imported modules): + # export PYTHONPATH=/path/to/gramps/src + # python src/plugins/rel/rel_pt.py + # (Above not needed here) + + """TRANSLATORS, copy this if statement at the bottom of your + rel_xx.py module, and test your work with: + python src/plugins/rel/rel_xx.py + """ + from Relationship import test + RC = RelationshipCalculator() + test(RC, True)