PythonTidy (PEP-8 format)

svn: r11791
This commit is contained in:
Jérôme Rapinat 2009-02-01 17:25:12 +00:00
parent 248002b819
commit ea96136bf9
2 changed files with 551 additions and 387 deletions

View File

@ -1,3 +1,4 @@
#!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
@ -21,15 +22,16 @@
# $Id$ # $Id$
"""
French-specific classes for parsing and displaying dates.
"""
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Python modules # Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
"""
French-specific classes for parsing and displaying dates.
"""
import re import re
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -37,6 +39,7 @@ import re
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.lib import Date from gen.lib import Date
from _DateParser import DateParser from _DateParser import DateParser
from _DateDisplay import DateDisplay from _DateDisplay import DateDisplay
@ -47,10 +50,14 @@ from _DateHandler import register_datehandler
# French parser # French parser
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class DateParserFR(DateParser): class DateParserFR(DateParser):
month_to_int = DateParser.month_to_int month_to_int = DateParser.month_to_int
# Add common value # Add common value
month_to_int[u"bluviose"] = 1 month_to_int[u"bluviose"] = 1
month_to_int[u"vendose"] = 2 month_to_int[u"vendose"] = 2
month_to_int[u"7bre"] = 9 month_to_int[u"7bre"] = 9
@ -58,7 +65,9 @@ class DateParserFR(DateParser):
month_to_int[u"9bre"] = 11 month_to_int[u"9bre"] = 11
month_to_int[u"10bre"] = 12 month_to_int[u"10bre"] = 12
month_to_int[u"xbre"] = 12 month_to_int[u"xbre"] = 12
# Add common latin # Add common latin
month_to_int[u"januaris"] = 1 month_to_int[u"januaris"] = 1
month_to_int[u"januarii"] = 1 month_to_int[u"januarii"] = 1
month_to_int[u"januarius"] = 1 month_to_int[u"januarius"] = 1
@ -89,8 +98,10 @@ class DateParserFR(DateParser):
month_to_int[u"10bris"] = 12 month_to_int[u"10bris"] = 12
month_to_int[u"xbris"] = 12 month_to_int[u"xbris"] = 12
month_to_int[u"december"] = 12 month_to_int[u"december"] = 12
#local and historical variants #local and historical variants
# Add common on east france # Add common on east france
month_to_int[u"janer"] = 1 month_to_int[u"janer"] = 1
month_to_int[u"jenner"] = 1 month_to_int[u"jenner"] = 1
month_to_int[u"hartmonat"] = 1 month_to_int[u"hartmonat"] = 1
@ -114,94 +125,110 @@ class DateParserFR(DateParser):
month_to_int[u"julmond"] = 12 month_to_int[u"julmond"] = 12
modifier_to_int = { modifier_to_int = {
u'avant' : Date.MOD_BEFORE, u'avant': Date.MOD_BEFORE,
u'av.' : Date.MOD_BEFORE, u'av.': Date.MOD_BEFORE,
u'après' : Date.MOD_AFTER, u'après': Date.MOD_AFTER,
u'ap.' : Date.MOD_AFTER, u'ap.': Date.MOD_AFTER,
u'ap' : Date.MOD_AFTER, u'ap': Date.MOD_AFTER,
u'env.' : Date.MOD_ABOUT, u'env.': Date.MOD_ABOUT,
u'env' : Date.MOD_ABOUT, u'env': Date.MOD_ABOUT,
u'environ': Date.MOD_ABOUT, u'environ': Date.MOD_ABOUT,
u'circa' : Date.MOD_ABOUT, u'circa': Date.MOD_ABOUT,
u'c.' : Date.MOD_ABOUT, u'c.': Date.MOD_ABOUT,
u'ca' : Date.MOD_ABOUT, u'ca': Date.MOD_ABOUT,
u'ca.' : Date.MOD_ABOUT, u'ca.': Date.MOD_ABOUT,
u'vers' : Date.MOD_ABOUT, u'vers': Date.MOD_ABOUT,
u'~' : Date.MOD_ABOUT, u'~': Date.MOD_ABOUT,
} }
calendar_to_int = { calendar_to_int = {
u'grégorien' : Date.CAL_GREGORIAN, u'grégorien': Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN, u'g': Date.CAL_GREGORIAN,
u'julien' : Date.CAL_JULIAN, u'julien': Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN, u'j': Date.CAL_JULIAN,
u'hébreu' : Date.CAL_HEBREW, u'hébreu': Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW, u'h': Date.CAL_HEBREW,
u'islamique' : Date.CAL_ISLAMIC, u'islamique': Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC, u'i': Date.CAL_ISLAMIC,
u'révolutionnaire' : Date.CAL_FRENCH, u'révolutionnaire': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH, u'r': Date.CAL_FRENCH,
u'perse' : Date.CAL_PERSIAN, u'perse': Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN, u'p': Date.CAL_PERSIAN,
u'suédois' : Date.CAL_SWEDISH, u'suédois': Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH, u's': Date.CAL_SWEDISH,
} }
quality_to_int = { quality_to_int = {
u'estimée' : Date.QUAL_ESTIMATED, u'estimée': Date.QUAL_ESTIMATED,
u'est.' : Date.QUAL_ESTIMATED, u'est.': Date.QUAL_ESTIMATED,
u'est' : Date.QUAL_ESTIMATED, u'est': Date.QUAL_ESTIMATED,
u'calculée' : Date.QUAL_CALCULATED, u'calculée': Date.QUAL_CALCULATED,
u'calc.' : Date.QUAL_CALCULATED, u'calc.': Date.QUAL_CALCULATED,
u'calc' : Date.QUAL_CALCULATED, u'calc': Date.QUAL_CALCULATED,
u'comptée' : Date.QUAL_CALCULATED, u'comptée': Date.QUAL_CALCULATED,
u'compt' : Date.QUAL_CALCULATED, u'compt': Date.QUAL_CALCULATED,
u'compt.' : Date.QUAL_CALCULATED, u'compt.': Date.QUAL_CALCULATED,
} }
bce = [u"avant le calendrier", u"avant notre ère", bce = [u"avant le calendrier", u"avant notre ère", u"avant JC",
u"avant JC", u"avant J.C"] + DateParser.bce u"avant J.C"] + DateParser.bce
def init_strings(self): def init_strings(self):
DateParser.init_strings(self) DateParser.init_strings(self)
# This self._numeric is different from the base # This self._numeric is different from the base
# avoid bug gregorian / french calendar conversion (+/-10 days) # avoid bug gregorian / french calendar conversion (+/-10 days)
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\s*$") self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\s*$")
self._span = re.compile(u"(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)", re.IGNORECASE) self._span = re.compile(u"(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)",
self._range = re.compile(u"(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)", re.IGNORECASE) re.IGNORECASE)
self._range = re.compile(u"(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)",
re.IGNORECASE)
# This self._text are different from the base # This self._text are different from the base
# by adding ".?" after the first date and removing "\s*$" at the end # by adding ".?" after the first date and removing "\s*$" at the end
#gregorian and julian #gregorian and julian
self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str,
re.IGNORECASE) self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
self._mon_str, re.IGNORECASE)
#hebrew #hebrew
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._jmon_str,
re.IGNORECASE) self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
self._jmon_str, re.IGNORECASE)
#french #french
self._ftext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._fmon_str,
re.IGNORECASE) self._ftext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
self._fmon_str, re.IGNORECASE)
#persian #persian
self._ptext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._pmon_str,
re.IGNORECASE) self._ptext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
self._pmon_str, re.IGNORECASE)
#islamic #islamic
self._itext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._imon_str,
re.IGNORECASE) self._itext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
self._imon_str, re.IGNORECASE)
#swedish #swedish
self._stext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._smon_str,
re.IGNORECASE) self._stext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
self._smon_str, re.IGNORECASE)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# French display # French display
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class DateDisplayFR(DateDisplay): class DateDisplayFR(DateDisplay):
calendar = ( calendar = ("", u" (Julien)", u" (Hébreu)", u" (Révolutionnaire)",
"", u" (Julien)", u" (Hébreu)", u" (Perse)", u" (Islamique)", u" (Suédois)")
u" (Révolutionnaire)", u" (Perse)", u" (Islamique)",
u" (Suédois)"
)
_mod_str = ("", u"avant ", u"après ", u"vers ", "", "", "") _mod_str = ("", u"avant ", u"après ", u"vers ", "", "", "")
@ -209,10 +236,8 @@ class DateDisplayFR(DateDisplay):
_bce_str = u"%s avant le calendrier" _bce_str = u"%s avant le calendrier"
formats = ( formats = ("AAAA-MM-JJ (ISO)", "Numérique", "Mois Jour, Année",
"AAAA-MM-JJ (ISO)", "Numérique", "Mois Jour, Année", "MOI Jour, Année", "Jour. Mois Année", "Jour. MOI Année")
"MOI Jour, Année", "Jour. Mois Année", "Jour. MOI Année"
)
def _display_gregorian(self, date_val): def _display_gregorian(self, date_val):
year = self._slash_year(date_val[2], date_val[3]) year = self._slash_year(date_val[2], date_val[3])
@ -227,82 +252,101 @@ class DateDisplayFR(DateDisplay):
else: else:
value = self._tformat.replace('%m', str(date_val[1])) value = self._tformat.replace('%m', str(date_val[1]))
value = value.replace('%d', str(date_val[0])) value = value.replace('%d', str(date_val[0]))
# base_display : # base_display :
# value = value.replace('%Y', str(abs(date_val[2]))) # value = value.replace('%Y', str(abs(date_val[2])))
# value = value.replace('-', '/') # value = value.replace('-', '/')
value = value.replace('%Y', str(date_val[2])) value = value.replace('%Y', str(date_val[2]))
elif self.format == 2: elif self.format == 2:
# Month Day, Year # Month Day, Year
if date_val[0] == 0: if date_val[0] == 0:
if date_val[1] == 0: if date_val[1] == 0:
value = year value = year
else: else:
value = "%s %s" % (self._months[date_val[1]], year) value = "%s %s" % ((self._months)[date_val[1]], year)
else: else:
value = "%s %d, %s" % (self._months[date_val[1]], date_val[0], year) value = "%s %d, %s" % ((self._months)[date_val[1]],
date_val[0], year)
elif self.format == 3: elif self.format == 3:
# MON Day, Year # MON Day, Year
if date_val[0] == 0: if date_val[0] == 0:
if date_val[1] == 0: if date_val[1] == 0:
value = year value = year
else: else:
value = "%s %s" % (self.MONS[date_val[1]], year) value = "%s %s" % ((self.MONS)[date_val[1]], year)
else: else:
value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year) value = "%s %d, %s" % ((self.MONS)[date_val[1]],
date_val[0], year)
elif self.format == 4: elif self.format == 4:
# Day. Month Year # Day. Month Year
if date_val[0] == 0: if date_val[0] == 0:
if date_val[1] == 0: if date_val[1] == 0:
value = year value = year
else: else:
value = "%s %s" % (self._months[date_val[1]], year) value = "%s %s" % ((self._months)[date_val[1]], year)
else: else:
# base_display : # base_display :
# value = "%d %s %s" % (date_val[0], self._months[date_val[1]], year) # value = "%d %s %s" % (date_val[0], self._months[date_val[1]], year)
value = "%d. %s %s" % (date_val[0], self._months[date_val[1]], year)
value = "%d. %s %s" % (date_val[0], (self._months)[date_val[1]],
year)
else: else:
# Day. MON Year # Day. MON Year
if date_val[0] == 0: if date_val[0] == 0:
if date_val[1] == 0: if date_val[1] == 0:
value = year value = year
else: else:
value = "%s %s" % (self.MONS[date_val[1]], year) value = "%s %s" % ((self.MONS)[date_val[1]], year)
else: else:
# base_display : # base_display :
# value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year) # value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
value = "%d. %s %s" % (date_val[0], self.MONS[date_val[1]], year)
value = "%d. %s %s" % (date_val[0], (self.MONS)[date_val[1]],
year)
if date_val[2] < 0: if date_val[2] < 0:
return self._bce_str % value return self._bce_str % value
else: else:
return value return value
def display(self, date): def display(self, date):
""" """
Return a text string representing the date. Return a text string representing the date.
""" """
mod = date.get_modifier() mod = date.get_modifier()
cal = date.get_calendar() cal = date.get_calendar()
qual = date.get_quality() qual = date.get_quality()
start = date.get_start_date() start = date.get_start_date()
qual_str = self._qual_str[qual] qual_str = (self._qual_str)[qual]
if mod == Date.MOD_TEXTONLY: if mod == Date.MOD_TEXTONLY:
return date.get_text() return date.get_text()
elif start == Date.EMPTY: elif start == Date.EMPTY:
return "" return ""
elif mod == Date.MOD_SPAN: elif mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start) d1 = (self.display_cal)[cal](start)
d2 = self.display_cal[cal](date.get_stop_date()) d2 = (self.display_cal)[cal](date.get_stop_date())
return "%s%s %s %s %s%s" % (qual_str, u'de', d1, u'à', d2, self.calendar[cal]) return "%s%s %s %s %s%s" % (qual_str, u'de', d1, u'à', d2, (self.calendar)[cal])
elif mod == Date.MOD_RANGE: elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start) d1 = (self.display_cal)[cal](start)
d2 = self.display_cal[cal](date.get_stop_date()) d2 = (self.display_cal)[cal](date.get_stop_date())
return "%s%s %s %s %s%s" % (qual_str, u'entre', d1, u'et', d2, self.calendar[cal]) return "%s%s %s %s %s%s" % (qual_str, u'entre', d1, u'et',
d2, (self.calendar)[cal])
else: else:
text = self.display_cal[date.get_calendar()](start) text = (self.display_cal)[date.get_calendar()](start)
return "%s%s%s%s" % (qual_str, self._mod_str[mod], text, self.calendar[cal]) return "%s%s%s%s" % (qual_str, (self._mod_str)[mod], text, (self.calendar)[cal])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -310,6 +354,6 @@ class DateDisplayFR(DateDisplay):
# Register classes # Register classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
register_datehandler(
('fr_FR', 'fr', 'french', 'French', 'fr_CA', 'fr_BE', 'fr_CH'), register_datehandler(('fr_FR', 'fr', 'french', 'French', 'fr_CA',
DateParserFR, DateDisplayFR) 'fr_BE', 'fr_CH'), DateParserFR, DateDisplayFR)

View File

@ -1,3 +1,4 @@
#!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
@ -20,8 +21,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -41,82 +40,129 @@ from gen.plug import PluginManager
# level est utilisé pour trouver/afficher le niveau de la génération : # level est utilisé pour trouver/afficher le niveau de la génération :
# à la %sème génération # à la %sème génération
_level_name = [ "première", "deuxième", "troisième", "quatrième", _level_name = [
"cinquième", "sixième", "septième", "huitième", "première",
"neuvième", "dixième", "onzième", "douzième", "deuxième",
"treizième", "quatorzième", "quinzième", "troisième",
"seizième", "dix-septième", "dix-huitième", "quatrième",
"dix-neuvième", "vingtième", "vingt-et-unième", "cinquième",
"vingt-deuxième", "vingt-troisième", "sixième",
"vingt-quatrième", "vingt-cinquième", "septième",
"vingt-sixième", "vingt-septième", "huitième",
"vingt-huitième", "vingt-neuvième", "neuvième",
"trentiè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",
]
# pour le degrè (canon et civil), limitation 20+20 ainsi que pour # pour le degrè (canon et civil), limitation 20+20 ainsi que pour
# LE [premier] cousin # LE [premier] cousin
_removed_level = [ "premier", "deuxième", "troisième", "quatrième", _removed_level = [
"cinquième", "sixième", "septième", "huitième", "premier",
"neuvième", "dixième", "onzième", "douzième", "deuxième",
"treizième", "quatorzième", "quinzième", "troisième",
"seizième", "dix-septième", "dix-huitième", "quatrième",
"dix-neuvième", "vingtième", "vingt-et-unième", "cinquième",
"vingt-deuxième", "vingt-troisième", "sixième",
"vingt-quatrième", "vingt-cinquième", "septième",
"vingt-sixième", "vingt-septième", "huitième",
"vingt-huitième", "vingt-neuvième", "neuvième",
"trentième", "trente-et-unième", "dixième",
"trente-deuxième", "trente-troisième", "onzième",
"trente-quatrième", "trente-cinquième", "douzième",
"trente-sixième", "trente-septième", "treizième",
"trente-huitième", "trente-neuvième", "quatorzième",
"quarantième", "quanrante-et-uniè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",
]
# listes volontairement limitées | 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", _father_level = ["", "le père%s", "le grand-père%s",
"l'arrière-grand-père%s", "le trisaïeul%s", ] "l'arrière-grand-père%s", "le trisaïeul%s"]
_mother_level = [ "", "la mère%s", "la grand-mère%s", _mother_level = ["", "la mère%s", "la grand-mère%s",
"l'arrière-grand-mère%s", "la trisaïeule%s", ] "l'arrière-grand-mère%s", "la trisaïeule%s"]
_son_level = [ "", "le fils%s", "le petit-fils%s", "l'arrière-petit-fils%s", ] _son_level = ["", "le fils%s", "le petit-fils%s",
"l'arrière-petit-fils%s"]
_daughter_level = [ "", "la fille%s", "la petite-fille%s", _daughter_level = ["", "la fille%s", "la petite-fille%s",
"l'arrière-petite-fille%s", ] "l'arrière-petite-fille%s"]
_sister_level = [ "", "la sœur%s", "la tante%s", "la grand-tante%s", _sister_level = ["", "la sœur%s", "la tante%s", "la grand-tante%s",
"l'arrière-grand-tante%s", ] "l'arrière-grand-tante%s"]
_brother_level = [ "", "le frère%s", "l'oncle%s", "le grand-oncle%s", _brother_level = ["", "le frère%s", "l'oncle%s", "le grand-oncle%s",
"l'arrière-grand-oncle%s", ] "l'arrière-grand-oncle%s"]
_nephew_level = [ "", "le neveu%s", "le petit-neveu%s", _nephew_level = ["", "le neveu%s", "le petit-neveu%s",
"l'arrière-petit-neveu%s", ] "l'arrière-petit-neveu%s"]
_niece_level = [ "", "la nièce%s", "la petite-nièce%s", _niece_level = ["", "la nièce%s", "la petite-nièce%s",
"l'arrière-petite-nièce%s", ] "l'arrière-petite-nièce%s"]
# kinship report # kinship report
_parents_level = [ "", "les parents", "les grands-parents", _parents_level = ["", "les parents", "les grands-parents",
"les arrières-grands-parents", "les trisaïeux", ] "les arrières-grands-parents", "les trisaïeux"]
_children_level = [ "", "les enfants", "les petits-enfants", _children_level = ["", "les enfants", "les petits-enfants",
"les arrières-petits-enfants", "les arrières-petits-enfants",
"les arrières-arrières-petits-enfants", ] "les arrières-arrières-petits-enfants"]
_siblings_level = [ "", "les frères et les sœurs", _siblings_level = ["", "les frères et les sœurs",
"les oncles et les tantes", "les oncles et les tantes",
"les grands-oncles et les grands-tantes", "les grands-oncles et les grands-tantes",
"les arrières-grands-oncles et les arrières-grands-tantes", "les arrières-grands-oncles et les arrières-grands-tantes"]
]
_nephews_nieces_level = [ "", "les neveux et les nièces", _nephews_nieces_level = ["", "les neveux et les nièces",
"les petits-neveux et les petites-nièces", "les petits-neveux et les petites-nièces",
"les arrière-petits-neveux et les arrières-petites-nièces", "les arrière-petits-neveux et les arrières-petites-nièces"]
]
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -124,11 +170,11 @@ _nephews_nieces_level = [ "", "les neveux et les nièces",
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator): class RelationshipCalculator(Relationship.RelationshipCalculator):
INLAW = ' (par alliance)' INLAW = ' (par alliance)'
def __init__(self): def __init__(self):
Relationship.RelationshipCalculator.__init__(self) Relationship.RelationshipCalculator.__init__(self)
@ -136,111 +182,109 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
# de la personne active à l'ascendant commun Ga=[level] # de la personne active à l'ascendant commun Ga=[level]
def get_cousin(self, level, removed, dir = '', inlaw=''): def get_cousin(self, level, removed, dir="", inlaw=""):
if removed == 0 and level < len(_level_name): if removed == 0 and level < len(_level_name):
return "le %s cousin%s" % (_removed_level[level-1], return "le %s cousin%s" % (_removed_level[level - 1], inlaw)
inlaw) elif level < removed:
elif (level) < (removed): rel_str = self.get_uncle(level - 1, inlaw)
rel_str = self.get_uncle(level-1, inlaw)
else: else:
# limitation gen = 29
return "le cousin lointain, relié à la %s génération" % (
_level_name[removed])
def get_cousine(self, level, removed, dir = '', inlaw=''): # limitation gen = 29
return "le cousin lointain, relié à la %s génération" % \
_level_name[removed]
def get_cousine(self, level, removed, dir="", inlaw=""):
if removed == 0 and level < len(_level_name): if removed == 0 and level < len(_level_name):
return "la %s cousine%s" % (_level_name[level-1], return "la %s cousine%s" % (_level_name[level - 1], inlaw)
inlaw) elif level < removed:
elif (level) < (removed): rel_str = self.get_aunt(level - 1, inlaw)
rel_str = self.get_aunt(level-1, inlaw)
else: else:
return "la cousine lointaine, reliée à la %s génération" % ( return "la cousine lointaine, reliée à la %s génération" % \
_level_name[removed]) _level_name[removed]
def get_parents(self, level): def get_parents(self, level):
if level > len(_parents_level)-1: if level > len(_parents_level) - 1:
return "les ascendants lointains, à la %s génération" % ( return "les ascendants lointains, à la %s génération" % \
_level_name[level]) _level_name[level]
else: else:
return _parents_level[level] return _parents_level[level]
def get_father(self, level, inlaw=''): def get_father(self, level, inlaw=""):
if level > len(_father_level)-1: if level > len(_father_level) - 1:
return "l'ascendant lointain, à la %s génération" % ( return "l'ascendant lointain, à la %s génération" % \
_level_name[level]) _level_name[level]
else: else:
return _father_level[level] % inlaw return _father_level[level] % inlaw
def get_mother(self, level, inlaw=''): def get_mother(self, level, inlaw=""):
if level > len(_mother_level)-1: if level > len(_mother_level) - 1:
return "l'ascendante lointaine, à la %s génération" % ( return "l'ascendante lointaine, à la %s génération" % \
_level_name[level]) _level_name[level]
else: else:
return _mother_level[level] % inlaw return _mother_level[level] % inlaw
def get_parent_unknown(self, level, inlaw=''): def get_parent_unknown(self, level, inlaw=""):
if level > len(_level_name)-1: if level > len(_level_name) - 1:
return "l'ascendant lointain, à la %s génération" % ( return "l'ascendant lointain, à la %s génération" % \
_level_name[level]) _level_name[level]
elif level == 1: elif level == 1:
return "un parent%s" % (inlaw) return "un parent%s" % inlaw
else: else:
return "un parent lointain%s" % (inlaw) return "un parent lointain%s" % inlaw
def get_son(self, level, inlaw=''): def get_son(self, level, inlaw=""):
if level > len(_son_level)-1: if level > len(_son_level) - 1:
return "le descendant lointain, à la %s génération" % ( return "le descendant lointain, à la %s génération" % \
_level_name[level+1]) _level_name[level + 1]
else: else:
return _son_level[level] % (inlaw) return _son_level[level] % inlaw
def get_daughter(self, level, inlaw=''): def get_daughter(self, level, inlaw=""):
if level > len(_daughter_level)-1: if level > len(_daughter_level) - 1:
return "la descendante lointaine, à la %s génération" % ( return "la descendante lointaine, à la %s génération" % \
_level_name[level+1]) _level_name[level + 1]
else: else:
return _daughter_level[level] % (inlaw) return _daughter_level[level] % inlaw
def get_child_unknown(self, level, inlaw=''): def get_child_unknown(self, level, inlaw=""):
if level > len(_level_name)-1: if level > len(_level_name) - 1:
return "le descendant lointain, à la %s génération" % ( return "le descendant lointain, à la %s génération" % \
_level_name[level+1]) _level_name[level + 1]
elif level == 1: elif level == 1:
return "un enfant%s" % (inlaw) return "un enfant%s" % inlaw
else: else:
return "un descendant lointain%s" % (inlaw) return "un descendant lointain%s" % inlaw
def get_sibling_unknown(self, level, inlaw=''): def get_sibling_unknown(self, level, inlaw=""):
return "un parent lointain%s" % (inlaw) return "un parent lointain%s" % inlaw
def get_uncle(self, level, inlaw=''): def get_uncle(self, level, inlaw=""):
if level > len(_brother_level)-1: if level > len(_brother_level) - 1:
return "l'oncle lointain, relié à la %s génération" % ( return "l'oncle lointain, relié à la %s génération" % \
_level_name[level]) _level_name[level]
else: else:
return _brother_level[level] % (inlaw) return _brother_level[level] % inlaw
def get_aunt(self, level, inlaw=''): def get_aunt(self, level, inlaw=""):
if level > len(_sister_level)-1: if level > len(_sister_level) - 1:
return "la tante lointaine, reliée à la %s génération" % ( return "la tante lointaine, reliée à la %s génération" % \
_level_name[level]) _level_name[level]
else: else:
return _sister_level[level] % (inlaw) return _sister_level[level] % inlaw
def get_nephew(self, level, inlaw=''): def get_nephew(self, level, inlaw=""):
if level > len(_nephew_level)-1: if level > len(_nephew_level) - 1:
return "le neveu lointain, à la %s génération" % ( return "le neveu lointain, à la %s génération" % _level_name[level]
_level_name[level])
else: else:
return _nephew_level[level] % (inlaw) return _nephew_level[level] % inlaw
def get_niece(self, level, inlaw=''): def get_niece(self, level, inlaw=""):
if level > len(_niece_level)-1: if level > len(_niece_level) - 1:
return "la nièce lointaine, à la %s génération" % ( return "la nièce lointaine, à la %s génération" % \
_level_name[level]) _level_name[level]
else: else:
return _niece_level[level] % (inlaw) return _niece_level[level] % inlaw
# kinship report # kinship report
@ -248,215 +292,268 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
""" """
voir Relationship.py voir Relationship.py
""" """
rel_str = "des parents lointains" rel_str = "des parents lointains"
gen = " à la %sème génération" gen = " à la %sème génération"
bygen = " par la %sème génération" bygen = " par la %sème génération"
cmt = " (frères ou sœurs d'un ascendant" + gen % ( cmt = " (frères ou sœurs d'un ascendant" + gen % Ga + ")"
Ga) + ")"
if Ga == 0: if Ga == 0:
# These are descendants # These are descendants
if Gb < len(_children_level): if Gb < len(_children_level):
rel_str = _children_level[Gb] rel_str = _children_level[Gb]
else: else:
rel_str = "les descendants" + gen % ( rel_str = "les descendants" + gen % (Gb + 1)
Gb+1)
elif Gb == 0: elif Gb == 0:
# These are parents/grand parents # These are parents/grand parents
if Ga < len(_parents_level): if Ga < len(_parents_level):
rel_str = _parents_level[Ga] rel_str = _parents_level[Ga]
else: else:
rel_str = "les ascendants" + gen % ( rel_str = "les ascendants" + gen % (Ga + 1)
Ga+1)
elif Gb == 1: elif Gb == 1:
# These are siblings/aunts/uncles # These are siblings/aunts/uncles
if Ga < len(_siblings_level): if Ga < len(_siblings_level):
rel_str = _siblings_level[Ga] rel_str = _siblings_level[Ga]
else: else:
rel_str = "Les enfants d'un ascendant" + gen % ( rel_str = "Les enfants d'un ascendant" + gen % (Ga + 1) + \
Ga+1) + cmt cmt
elif Ga == 1: elif Ga == 1:
# These are nieces/nephews # These are nieces/nephews
if Gb < len(_nephews_nieces_level): if Gb < len(_nephews_nieces_level):
rel_str = _nephews_nieces_level[Gb-1] rel_str = _nephews_nieces_level[Gb - 1]
else: else:
rel_str = "les neveux et les nièces" + gen % ( rel_str = "les neveux et les nièces" + gen % Gb
Gb)
elif Ga > 1 and Ga == Gb: elif Ga > 1 and Ga == Gb:
# These are cousins in the same generation # These are cousins in the same generation
# use custom level for latin words # use custom level for latin words
if Ga == 2: if Ga == 2:
rel_str = "les cousins germains et cousines germaines" rel_str = "les cousins germains et cousines germaines"
elif Ga <= len(_level_name): elif Ga <= len(_level_name):
# %ss for plural # %ss for plural
rel_str = "les %ss cousins et cousines" % _level_name[Ga-2]
# security rel_str = "les %ss cousins et cousines" % _level_name[Ga -
2]
else: else:
# security
rel_str = "les cousins et cousines" rel_str = "les cousins et cousines"
elif Ga > 1 and Ga > Gb: elif Ga > 1 and Ga > Gb:
# These are cousins in different generations with the second person # These are cousins in different generations with the second person
# 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.
# use custom level for latin words and specific relation # use custom level for latin words and specific relation
if Ga == 3 and Gb == 2: if Ga == 3 and Gb == 2:
desc = " (cousins germains d'un parent)" desc = " (cousins germains d'un parent)"
rel_str = "les oncles et tantes à la mode de Bretagne" + desc rel_str = "les oncles et tantes à la mode de Bretagne" + \
elif Gb <= len(_level_name) and (Ga-Gb) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level): desc
can = " du %s au %s degré (canon)" % ( elif Gb <= len(_level_name) and Ga - Gb < len(_removed_level) and \
_removed_level[Gb], _removed_level[Ga] ) Ga + Gb + 1 < len(_removed_level):
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] ) can = " du %s au %s degré (canon)" % (_removed_level[Gb],
_removed_level[Ga])
civ = " et au %s degré (civil)" % _removed_level[Ga + Gb +
1]
rel_str = "les oncles et tantes" + can + civ rel_str = "les oncles et tantes" + can + civ
elif Ga < len(_level_name): elif Ga < len(_level_name):
rel_str = "les grands-oncles et grands-tantes" + bygen % ( rel_str = "les grands-oncles et grands-tantes" + bygen % \
Ga+1) (Ga + 1)
else: else:
return rel_str return rel_str
elif Gb > 1 and Gb > Ga: elif Gb > 1 and Gb > Ga:
# These are cousins in different generations with the second person # These are cousins in different generations with the second person
# 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.
# use custom level for latin words and specific relation # use custom level for latin words and specific relation
if Ga == 2 and Gb == 3: if Ga == 2 and Gb == 3:
info = " (cousins issus d'un germain)" info = " (cousins issus d'un germain)"
rel_str = "les neveux et nièces à la mode de Bretagne" + info rel_str = "les neveux et nièces à la mode de Bretagne" + \
elif Ga <= len(_level_name) and (Gb-Ga) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level): info
can = " du %s au %s degré (canon)" % ( elif Ga <= len(_level_name) and Gb - Ga < len(_removed_level) and \
_removed_level[Gb], _removed_level[Ga] ) Ga + Gb + 1 < len(_removed_level):
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] ) can = " du %s au %s degré (canon)" % (_removed_level[Gb],
_removed_level[Ga])
civ = " et au %s degré (civil)" % _removed_level[Ga + Gb +
1]
rel_str = "les neveux et nièces" + can + civ rel_str = "les neveux et nièces" + can + civ
elif Ga < len(_level_name): elif Ga < len(_level_name):
rel_str = "les neveux et nièces" + bygen % ( rel_str = "les neveux et nièces" + bygen % Gb
Gb)
else: else:
return rel_str return rel_str
return rel_str return rel_str
# quick report (missing on RelCalc tool - Status Bar) # quick report (missing on RelCalc tool - Status Bar)
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b, def get_single_relationship_string(
reltocommon_a, reltocommon_b, self,
Ga,
Gb,
gender_a,
gender_b,
reltocommon_a,
reltocommon_b,
only_birth=True, only_birth=True,
in_law_a=False, in_law_b=False): in_law_a=False,
in_law_b=False,
):
""" """
voir Relationship.py voir Relationship.py
""" """
if only_birth: if only_birth:
step = '' step = ""
else: else:
step = self.STEP step = self.STEP
if in_law_a or in_law_b : if in_law_a or in_law_b:
inlaw = self.INLAW inlaw = self.INLAW
else: else:
inlaw = '' inlaw = ""
rel_str = "un parent lointains%s" % inlaw
rel_str = "un parent lointains%s" % (inlaw)
bygen = " par la %sème génération" bygen = " par la %sème génération"
if Ga == 0: if Ga == 0:
# b is descendant of a # b is descendant of a
if Gb == 0 :
if Gb == 0:
rel_str = 'le même individu' rel_str = 'le même individu'
elif gender_b == gen.lib.Person.MALE and Gb < len(_son_level): elif gender_b == gen.lib.Person.MALE and Gb < len(_son_level):
# spouse of daughter # spouse of daughter
if inlaw and Gb == 1 and not step: if inlaw and Gb == 1 and not step:
rel_str = "le gendre" rel_str = "le gendre"
else: else:
rel_str = self.get_son(Gb) 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 # spouse of son
if inlaw and Gb == 1 and not step: if inlaw and Gb == 1 and not step:
rel_str = "la bru" rel_str = "la bru"
else: else:
rel_str = self.get_daughter(Gb) rel_str = self.get_daughter(Gb)
# don't display inlaw
elif Gb < len(_level_name) and gender_b == gen.lib.Person.MALE: elif Gb < len(_level_name) and gender_b == gen.lib.Person.MALE:
rel_str = "le descendant lointain (%dème génération)" % (
Gb+1) # don't display inlaw
rel_str = "le descendant lointain (%dème génération)" % \
(Gb + 1)
elif Gb < len(_level_name) and gender_b == gen.lib.Person.FEMALE: elif Gb < len(_level_name) and gender_b == gen.lib.Person.FEMALE:
rel_str = "la descendante lointaine (%dème génération)" % ( rel_str = "la descendante lointaine (%dème génération)" % \
Gb+1) (Gb + 1)
else: else:
return self.get_child_unknown(Gb) return self.get_child_unknown(Gb)
elif Gb == 0: elif Gb == 0:
# b is parents/grand parent of a # 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) # other spouse of father (new parent)
if Ga == 1 and inlaw and self.STEP_SIB: if Ga == 1 and inlaw and self.STEP_SIB:
rel_str = "le beau-père" rel_str = "le beau-père"
# father of spouse (family of spouse)
elif Ga == 1 and inlaw: elif Ga == 1 and inlaw:
# father of spouse (family of spouse)
rel_str = "le père du conjoint" rel_str = "le père du conjoint"
else: else:
rel_str = self.get_father(Ga, inlaw) 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) # other spouse of mother (new parent)
if Ga == 1 and inlaw and self.STEP_SIB: if Ga == 1 and inlaw and self.STEP_SIB:
rel_str = "la belle-mère" rel_str = "la belle-mère"
# mother of spouse (family of spouse)
elif Ga == 1 and inlaw: elif Ga == 1 and inlaw:
# mother of spouse (family of spouse)
rel_str = "la mère du conjoint" rel_str = "la mère du conjoint"
else: else:
rel_str = self.get_mother(Ga, inlaw) rel_str = self.get_mother(Ga, inlaw)
elif Ga < len(_level_name) and gender_b == gen.lib.Person.MALE: elif Ga < len(_level_name) and gender_b == gen.lib.Person.MALE:
rel_str = "l'ascendant lointain%s (%dème génération)" % ( rel_str = "l'ascendant lointain%s (%dème génération)" % \
inlaw, Ga+1) (inlaw, Ga + 1)
elif Ga < len(_level_name) and gender_b == gen.lib.Person.FEMALE: elif Ga < len(_level_name) and gender_b == gen.lib.Person.FEMALE:
rel_str = "l'ascendante lointaine%s (%dème génération)" % ( rel_str = "l'ascendante lointaine%s (%dème génération)" % \
inlaw, Ga+1) (inlaw, Ga + 1)
else: else:
return self.get_parent_unknown(Ga, inlaw) return self.get_parent_unknown(Ga, inlaw)
elif Gb == 1: elif Gb == 1:
# b is sibling/aunt/uncle of a # 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) 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) rel_str = self.get_aunt(Ga, inlaw)
else: else:
# don't display inlaw # don't display inlaw
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = "l'oncle lointain" + bygen % ( rel_str = "l'oncle lointain" + bygen % (Ga + 1)
Ga+1)
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la tante lointaine" + bygen % ( rel_str = "la tante lointaine" + bygen % (Ga + 1)
Ga+1)
elif gender_b == gen.lib.Person.UNKNOWN: elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw) rel_str = self.get_sibling_unknown(Ga, inlaw)
else: else:
return rel_str return rel_str
elif Ga == 1: elif Ga == 1:
# b is niece/nephew of a # 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) 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) rel_str = self.get_niece(Gb - 1, inlaw)
else: else:
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = "le neveu lointain%s (%dème génération)" % ( rel_str = "le neveu lointain%s (%dème génération)" % \
inlaw, Gb) (inlaw, Gb)
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la nièce lointaine%s (%dème génération)" % ( rel_str = "la nièce lointaine%s (%dème génération)" % \
inlaw, Gb) (inlaw, Gb)
elif gender_b == gen.lib.Person.UNKNOWN: elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw) rel_str = self.get_sibling_unknown(Ga, inlaw)
else: else:
return rel_str return rel_str
elif Ga == Gb: elif Ga == Gb:
# a and b cousins in the same generation # a and b cousins in the same generation
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = self.get_cousin(Ga-1, 0, dir = '', rel_str = self.get_cousin(Ga - 1, 0, dir="", inlaw=inlaw)
inlaw=inlaw)
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_cousine(Ga-1, 0, dir = '', rel_str = self.get_cousine(Ga - 1, 0, dir="", inlaw=
inlaw=inlaw) inlaw)
elif gender_b == gen.lib.Person.UNKNOWN: elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga-1, inlaw) rel_str = self.get_sibling_unknown(Ga - 1, inlaw)
else: else:
return rel_str return rel_str
elif Ga > 1 and Ga > Gb: elif Ga > 1 and Ga > Gb:
# These are cousins in different generations with the second person # These are cousins in different generations with the second person
# 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 Ga == 3 and Gb == 2: if Ga == 3 and Gb == 2:
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
desc = " (cousin germain d'un parent)" desc = " (cousin germain d'un parent)"
@ -468,10 +565,12 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
return self.get_sibling_unknown(Ga, inlaw) return self.get_sibling_unknown(Ga, inlaw)
else: else:
return rel_str return rel_str
elif Gb <= len(_level_name) and (Ga-Gb) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level): elif Gb <= len(_level_name) and Ga - Gb < len(_removed_level) and \
can = " du %s au %s degré (canon)" % ( Ga + Gb + 1 < len(_removed_level):
_removed_level[Gb], _removed_level[Ga] ) can = " du %s au %s degré (canon)" % (_removed_level[Gb],
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] ) _removed_level[Ga])
civ = " et au %s degré (civil)" % _removed_level[Ga + Gb +
1]
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = "l'oncle" + can + civ rel_str = "l'oncle" + can + civ
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
@ -490,9 +589,11 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else: else:
return rel_str return rel_str
elif Gb > 1 and Gb > Ga: elif Gb > 1 and Gb > Ga:
# These are cousins in different generations with the second person # These are cousins in different generations with the second person
# 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.
if Ga == 2 and Gb == 3: if Ga == 2 and Gb == 3:
info = " (cousins issus d'un germain)" info = " (cousins issus d'un germain)"
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
@ -503,10 +604,12 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rel_str = self.get_sibling_unknown(Ga, inlaw) rel_str = self.get_sibling_unknown(Ga, inlaw)
else: else:
return rel_str return rel_str
elif Ga <= len(_level_name) and (Gb-Ga) < len(_removed_level) and (Ga+Gb+1) < len(_removed_level): elif Ga <= len(_level_name) and Gb - Ga < len(_removed_level) and \
can = " du %s au %s degré (canon)" % ( Ga + Gb + 1 < len(_removed_level):
_removed_level[Gb], _removed_level[Ga] ) can = " du %s au %s degré (canon)" % (_removed_level[Gb],
civ = " et au %s degré (civil)" % ( _removed_level[Ga+Gb+1] ) _removed_level[Ga])
civ = " et au %s degré (civil)" % _removed_level[Ga + Gb +
1]
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = "le neveu" + can + civ rel_str = "le neveu" + can + civ
if gender_b == gen.lib.Person.FEMALE: if gender_b == gen.lib.Person.FEMALE:
@ -520,7 +623,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else: else:
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = self.get_nephew(Ga, inlaw) rel_str = self.get_nephew(Ga, inlaw)
elif gender_b ==gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_niece(Ga, inlaw) rel_str = self.get_niece(Ga, inlaw)
elif gender_b == gen.lib.Person.UNKNOWN: elif gender_b == gen.lib.Person.UNKNOWN:
rel_str = self.get_sibling_unknown(Ga, inlaw) rel_str = self.get_sibling_unknown(Ga, inlaw)
@ -530,13 +633,13 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
# RelCalc tool - Status Bar # RelCalc tool - Status Bar
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b, def get_sibling_relationship_string(self, sib_type, gender_a,
in_law_a=False, in_law_b=False): gender_b, in_law_a=False, in_law_b=False):
if in_law_a or in_law_b : if in_law_a or in_law_b:
inlaw = self.INLAW inlaw = self.INLAW
else: else:
inlaw = '' inlaw = ""
if sib_type == self.NORM_SIB: if sib_type == self.NORM_SIB:
if not inlaw: if not inlaw:
@ -568,16 +671,20 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rel_str = "la belle-sœur" rel_str = "la belle-sœur"
else: else:
rel_str = "le beau-frère ou la belle-sœur" rel_str = "le beau-frère ou la belle-sœur"
# Logique inversée ! Pourquoi ?
elif sib_type == self.HALF_SIB_MOTHER: elif sib_type == self.HALF_SIB_MOTHER:
# Logique inversée ! Pourquoi ?
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = "le demi-frère consanguin" rel_str = "le demi-frère consanguin"
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
rel_str = "la demi-sœur consanguine" rel_str = "la demi-sœur consanguine"
else: else:
rel_str = "le demi-frère ou la demi-sœur consanguin(e)" rel_str = "le demi-frère ou la demi-sœur consanguin(e)"
# Logique inversée ! Pourquoi ?
elif sib_type == self.HALF_SIB_FATHER: elif sib_type == self.HALF_SIB_FATHER:
# Logique inversée ! Pourquoi ?
if gender_b == gen.lib.Person.MALE: if gender_b == gen.lib.Person.MALE:
rel_str = "le demi-frère utérin" rel_str = "le demi-frère utérin"
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
@ -601,13 +708,26 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
pmgr = PluginManager.get_instance() pmgr = PluginManager.get_instance()
pmgr.register_relcalc(RelationshipCalculator, pmgr.register_relcalc(RelationshipCalculator, [
["fr", "FR", "fr_FR", "fr_CA", "francais", "Francais", "fr_FR.UTF8", "fr",
"fr_FR@euro", "fr_FR.UTF8@euro", "FR",
"french","French", "fr_FR.UTF-8", "fr_FR.utf-8", "fr_FR.utf8", "fr_FR",
"fr_CA.UTF-8"]) "fr_CA",
"francais",
"Francais",
"fr_FR.UTF8",
"fr_FR@euro",
"fr_FR.UTF8@euro",
"french",
"French",
"fr_FR.UTF-8",
"fr_FR.utf-8",
"fr_FR.utf8",
"fr_CA.UTF-8",
])
if __name__ == "__main__": if __name__ == "__main__":
# Test function. Call it as follows from the command line (so as to find # Test function. Call it as follows from the command line (so as to find
# imported modules): # imported modules):
# export PYTHONPATH=/path/to/gramps/src # export PYTHONPATH=/path/to/gramps/src