fixes contributed by Frederik De Richter and Benny Malengier

svn: r9193
This commit is contained in:
Stéphane Charette 2007-10-16 03:51:36 +00:00
parent 7a81e60adc
commit e3e4075435
2 changed files with 248 additions and 127 deletions

View File

@ -1,3 +1,8 @@
2007-10-15 Stephane Charette <stephanecharette@gmail.com>
* src/plugins/rel_nl.py: fixes contributed by Frederik De
Richter <frederik.de.richter@googlemail.com> and Benny
Malengier <benny.malengier@gramps-project.org>
2007-10-14 Benny Malengier <benny.malengier@gramps-project.org> 2007-10-14 Benny Malengier <benny.malengier@gramps-project.org>
* src/DataViews/_PedigreeView.py: home person action added twice, gives warnings * src/DataViews/_PedigreeView.py: home person action added twice, gives warnings
in new GTK in new GTK

View File

@ -39,84 +39,182 @@ from PluginUtils import register_relcalc
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_level_name = [ "", _removed_level = [ " ",
"eerste", " eerste graad",
"tweede", " tweede graad",
"derde", " derde graad",
"vierde", " vierde graad",
"vijfde", " vijfde graad",
"zesde", " zesde graad",
"zevende", " zevende graad",
"achtste", " achtste",
"negende", " negende",
"tiende", " tiende",
"elfde", " elfde",
"twaalfde", " twaalfde",
"dertiende", " dertiende",
"veertiende", " veertiende",
"vijftiende", " vijftiende",
"zestiende", " zestiende",
"zeventiende", " zeventiende",
"acttiende", " achttiende",
"negentiende", " negentiende",
"twintigste", " twintigste",
"eenentwintigste", " eenentwintigste",
"tweeëntwintigste", " tweeëntwintigste",
"drieëntwingste", " drieëntwingste",
"vierentwingste", " vierentwingste",
"vijfentwintigste", " vijfentwintigste",
"zesentwintigste", " zesentwintigste",
"zevenentwintigste", " zevenentwintigste",
"achtentwintigste", " achtentwintigste",
"negenentwintigste", " negenentwintigste",
"dertigste" ] " dertigste" ]
_parents_level = [ "", _parents_level = [ "",
"ouders", "ouders",
"grootouders", "grootouders",
"overgrootouders", "overgrootouders",
"betovergrootouders", ] "betovergrootouders",
"oudouders",
"oudgrootouders",
"oudovergrootouders",
"oudbetovergrootouders",
"stamouders",
"stamgrootouders",
"stamovergrootouders",
"stambetovergrootouders",
"stamoudouders",
"stamoudgrootouders",
"stamoudovergrootouders",
"stamoudbetovergrootouders",
"edelouders",
"edelgrootoders",
"edelovergrootoudouders",
"edelbetovergrootouders",
"edeloudouders",
"edeloudgrootouders",
"edeloudvergrootouders",
"edeloudbetovergrootouders",
"edelstamouders",
"edelstamgrootouders",
"edelstamovergrootouders",
"edelstambetovergrootouders",
"edelstamoudouders" ]
_father_level = [ "", _father_level = [ "",
"vader", "vader (graad 1)",
"grootvader", "grootvader (graad 2)",
"overgrootvader", "overgrootvader (graad 3)",
"betovergrootvader", ] "betovergrootvader (graad 4)",
"oudvader (graad 5)",
"oudgrootvader (graad 6)",
"oudovergrootvader(graad 7)",
"oudbetovergrootvader (graad 8)",
"stamvader graad 9)",
"stamgrootvader",
"stamovergrootvader",
"stambetovergrootvader",
"stamoudvader",
"stamoudgrootvader",
"stamoudovergrootvader",
"stamoudbetovergrootvader",
"edelvader",
"edelgrootvader",
"edelovergrootoudvader",
"edelbetovergrootvader",
"edeloudvader",
"edeloudgrootvader",
"edeloudvergrootvader",
"edeloudbetovergrootvader",
"edelstamvader",
"edelstamgrootvader",
"edelstamovergrootvader",
"edelstambetovergrootvader",
"edelstamoudvader" ]
_mother_level = [ "", _mother_level = [ "",
"moeder", "moeder (graad 1)",
"grootmoeder", "grootmoeder (graad 2)",
"overgrootmoeder", "overgrootmoeder (graad 3)",
"betovergrootmoeder", ] "betovergrootmoeder (graad 4)",
"oudmoeder",
"oudgrootmoeder",
"oudovergrootmoeder",
"oudbetovergrootmoeder",
"stammoeder",
"stamgrootmoeder",
"stamovergrootmoeder",
"stambetovergrootmoeder",
"stamoudmoeder",
"stamoudgrootmoeder",
"stamoudovergrootmoeder",
"stamoudbetovergrootmoeder",
"edelmoeder",
"edelgrootmoeder",
"edelovergrootoudmoeder",
"edelbetovergrootmoeder",
"edeloudmoeder",
"edeloudgrootmoeder",
"edeloudvergrootmoeder",
"edeloudbetovergrootmoeder",
"edelstammoeder",
"edelstamgrootmoeder",
"edelstamovergrootmoeder",
"edelstambetovergrootmoeder",
"edelstamoudmoeder" ]
_son_level = [ "", _son_level = [ "",
"zoon", "zoon",
"kleinzoon", "kleinzoon",
"achterkleinzoon", ] "achterkleinzoon",
"achterachterkleinzoon",
"achterachterachterkleinzoon"]
_daughter_level = [ "", _daughter_level = [ "",
"dochter", "dochter",
"kleindochter", "kleindochter",
"achterkleindochter", ] "achterkleindochter",
"achterachterkleindochter",
"achterachterachterkleindochter"]
_sister_level = [ "", ##_sister_level = [ "",
"zuster", ## "zuster",
"tante", ## "tante",
"groottante", ] ## "groottante",
## "overgroottante" ,
## "betovergroottante",
## "oudtante"]
_brother_level = [ "", ##_brother_level = [ "",
"broer", ## "broer",
"oom", ## "oom",
"grootoom", ] ## "grootoom",
## "overgrootoom",
## "betovergrootoom",
## "oudoom" ]
_nephew_level = [ "", _nephew_level = [ "",
"neef", "neef",
"achterneef", ] "achterneef",
"achterachterneef" ]
_niece_level = [ "", _niece_level = [ "",
"nicht", "nicht",
"achternicht", ] "achternicht",
"achterachtenicht"]
_aunt_level = [ "",
"tante",
"groottante",
"overgroottante",
"betovergroottante",
"oudtante"]
_uncle_level = [ "",
"oom",
"grootoom",
"overgrootoom",
"betovergrootoom"]
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -127,35 +225,22 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
def __init__(self,db): def __init__(self,db):
Relationship.RelationshipCalculator.__init__(self,db) Relationship.RelationshipCalculator.__init__(self,db)
def get_male_cousin(self,level): def get_parents(self, level):
if level>len(_level_name)-1:
return "le parent lointain"
else:
return "neef in de %s graad" % (_level_name[level])
def get_female_cousin(self,level):
if level>len(_level_name)-1:
return "la parente lointaine"
else:
return "nicht in de %s graad" % (_level_name[level])
def get_parents(self,level):
if level>len(_parents_level)-1: if level>len(_parents_level)-1:
return "verre voorouders" return "verre voorouders"
else: else:
return _parents_level[level] return _parents_level[level]
def get_father(self, level):
def get_father(self,level):
if level>len(_father_level)-1: if level>len(_father_level)-1:
return "verre voorouder" return "verre voorouder"
else: else:
return _father_level[level] return _father_level[level]
def get_son(self,level): def get_son(self, level):
if level>len(_son_level)-1: if level>len(_son_level)-1:
return "verre afstammeling" return "verre afstammeling"
else: else:
return _son_level[level] return _son_level[level]
def get_mother(self,level): def get_mother(self,level):
if level>len(_mother_level)-1: if level>len(_mother_level)-1:
@ -163,46 +248,61 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else: else:
return _mother_level[level] return _mother_level[level]
def get_daughter(self,level): def get_daughter(self, level):
if level>len(_daughter_level)-1: if level>len(_daughter_level)-1:
return "verre afstammelinge" return "verre afstammelinge"
else: else:
return _daughter_level[level] return _daughter_level[level]
def get_aunt(self,level): def get_aunt(self, level, removed):
if level>len(_sister_level)-1: if level>len(_aunt_level)-1 or removed > len(_removed_level) -1:
return "verre voorouder" return "verre voorouder"
else: else:
return _sister_level[level] return _aunt_level[level] + _removed_level[removed]
def get_uncle(self, level, removed):
def get_uncle(self,level): if level>len(_uncle_level)-1 or removed > len(_removed_level) -1:
if level>len(_brother_level)-1:
return "verre voorouder" return "verre voorouder"
else: else:
return _brother_level[level] return _uncle_level[level] + _removed_level[removed]
def get_nephew(self,level): def get_nephew(self,level, removed):
if level>len(_nephew_level)-1: if level>len(_nephew_level)-1 or removed > len(_removed_level) -1:
return "verre afstammelling" return "verre voorouder"
else: else:
return _nephew_level[level] return _nephew_level[level] + _removed_level[removed]
def get_niece(self,level): def get_niece(self,level, removed):
if level>len(_niece_level)-1: if level>len(_niece_level)-1 or removed > len(_removed_level) -1:
return "verre afstammelinge" return "verre afstammelinge"
else: else:
return _niece_level[level] return _niece_level[level] + _removed_level[removed]
def get_male_cousin(self,removed):
if removed>len(_removed_level)-1:
return "verre afstammeling"
elif removed == 0:
return "broer"
else:
return "neef "+_removed_level[removed]
def get_female_cousin(self,removed):
if removed>len(_removed_level)-1:
return "verre afstammelinge"
elif removed == 0:
return " zus"
else:
return "nicht "+ _removed_level[removed]
def get_relationship(self,orig_person,other_person): def get_relationship(self,orig_person,other_person):
""" """
Returns a string representing the relationshp between the two people, Returns a string representing the relationshp between the two peopl
e,
along with a list of common ancestors (typically father,mother) along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse". Special cases: relation strings "", "undefined" and "spouse".
""" """
if orig_person == None: if orig_person == None:
return ("niet bepaalde",[]) return ("niet bepaald",[])
if orig_person.get_handle() == other_person.get_handle(): if orig_person.get_handle() == other_person.get_handle():
return ('', []) return ('', [])
@ -211,9 +311,11 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if is_spouse: if is_spouse:
return (is_spouse,[]) return (is_spouse,[])
(firstRel,secondRel,common) = self.get_relationship_distance(orig_person,other_person) (firstRel,secondRel,common) = self.get_relationship_distance(orig
_person,other_person)
if type(common) == types.StringType or type(common) == types.UnicodeType: if type(common) == types.StringType or type(common) == type
s.UnicodeType:
return (common,[]) return (common,[])
elif common: elif common:
person_handle = common[0] person_handle = common[0]
@ -227,50 +329,61 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if secondRel == 0: if secondRel == 0:
return ('',common) return ('',common)
elif other_person.get_gender() == RelLib.Person.MALE: elif other_person.get_gender() == RelLib.Person.MALE:
return (self.get_father(secondRel),common) return (self.get_father(secondRel), common)
else: else:
return (self.get_mother(secondRel),common) return (self.get_mother(secondRel), common)
elif secondRel == 0: elif secondRel == 0:
if other_person.get_gender() == RelLib.Person.MALE: if other_person.get_gender() == RelLib.Person.MALE:
return (self.get_son(firstRel),common) return (self.get_son(firstRel), common)
else: else:
return (self.get_daughter(firstRel),common) return (self.get_daughter(firstRel), common)
elif firstRel == 1: elif secondRel > firstRel:
if other_person.get_gender() == RelLib.Person.MALE: if other_person.get_gender() == RelLib.Person.MALE:
return (self.get_uncle(secondRel),common) return (self.get_uncle(secondRel - firstRel,firstRel), comm
on)
else: else:
return (self.get_aunt(secondRel),common) return (self.get_aunt(secondRel - firstRel, firstRel), comm
elif secondRel == 1: on)
elif secondRel < firstRel:
if other_person.get_gender() == RelLib.Person.MALE: if other_person.get_gender() == RelLib.Person.MALE:
return (self.get_nephew(firstRel-1),common) return (self.get_nephew(firstRel - secondRel, secondRel), c
ommon)
else: else:
return (self.get_niece(firstRel-1),common) return (self.get_niece(firstRel - secondRel, secondRel), co
elif firstRel == 2 and secondRel == 2: mmon)
if other_person.get_gender() == RelLib.Person.MALE:
return ('le cousin germain',common)
else:
return ('la cousine germaine',common)
elif firstRel == 3 and secondRel == 2:
if other_person.get_gender() == RelLib.Person.MALE:
return ('le neveu à la mode de Bretagne',common)
else:
return ('la nièce à la mode de Bretagne',common)
elif firstRel == 2 and secondRel == 3:
if other_person.get_gender() == RelLib.Person.MALE:
return ('l\'oncle à la mode de Bretagne',common)
else:
return ('la tante à la mode de Bretagne',common)
else: else:
if other_person.get_gender() == RelLib.Person.MALE: if other_person.get_gender() == RelLib.Person.MALE:
if firstRel+secondRel>len(_level_name)-1: return (self.get_male_cousin(firstRel -1), common)
return (self.get_male_cousin(firstRel+secondRel),common)
else: else:
return ('verre neef',common) return (self.get_female_cousin(firstRel -1), common)
else: ## elif firstRel == 2 and secondRel == 2:
if firstRel+secondRel>len(_level_name)-1: ## if other_person.get_gender() == RelLib.Person.MALE:
return (self.get_female_cousin(firstRel+secondRel),common) ## return ('de neef',common)
else: ## else:
return ('verre nicht',common) ## return ('de nicht',common)
## elif firstRel == 3 and secondRel == 2:
## if other_person.get_gender() == RelLib.Person.MALE:
## return ('neef',common)
## else:
## return ('nicht',common)
## elif firstRel == 2 and secondRel == 3:
## if other_person.get_gender() == RelLib.Person.MALE:
## return ('de oom',common)
## else:
## return ('de tante',common)
## else:
## if other_person.get_gender() == RelLib.Person.MALE:
## if firstRel+secondRel>len(_level_name)-1:
## return (self.get_male_cousin(firstRel+secondRel),comm
on)
## else:
## return ('verre neef',common)
## else:
## if firstRel+secondRel>len(_level_name)-1:
## return (self.get_female_cousin(firstRel+secondRel),co
mmon)
## else:
## return ('verre nicht',common)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -278,5 +391,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
register_relcalc(RelationshipCalculator, register_relcalc(RelationshipCalculator,
["nl", "NL", "nl_NL", "nl_BE", "nederlands", "Nederlands", "nl_NL.UTF8", "nl_BE.UTF8","nl_NL@euro", "nl_NL.UTF8@euro","nl_BE@euro", ["nl", "NL", "nl_NL", "nl_BE", "nederlands", "Nederlands", "nl_NL.UTF8"
"dutch","Dutch", "nl_NL.UTF-8", "nl_BE.UTF-8","nl_NL.utf-8", "nl_BE.utf-8","nl_NL.utf8", "nl_BE.UTF-8", "nl_BE.UTF8@euro"]) ,
"nl_BE.UTF8","nl_NL@euro", "nl_NL.UTF8@euro","nl_BE@euro",
"dutch","Dutch", "nl_NL.UTF-8", "nl_BE.UTF-8","nl_NL.utf-8",
"nl_BE.utf-8","nl_NL.utf8", "nl_BE.UTF-8", "nl_BE.UTF8@euro"])