2007-11-10 Benny Malengier <benny.malengier@gramps-project.org>

* src/plugins/rel_nl.py: inlaw children are allowed
	* src/Relationship.py: inlaw children are allowed



svn: r9330
This commit is contained in:
Benny Malengier 2007-11-11 11:32:04 +00:00
parent cb1cb76aa7
commit a2be7edd5b
3 changed files with 139 additions and 162 deletions

View File

@ -1,3 +1,7 @@
2007-11-10 Benny Malengier <benny.malengier@gramps-project.org>
* src/plugins/rel_nl.py: inlaw children are allowed
* src/Relationship.py: inlaw children are allowed
2007-11-10 Jim Sack <jgsack@san.rr.com> 2007-11-10 Jim Sack <jgsack@san.rr.com>
* src/GrampsDbUtils/_WriteGrdb.py: missing parent in import * src/GrampsDbUtils/_WriteGrdb.py: missing parent in import
* src/GrampsDbUtils/test/_GrampsDbWRFactories_test.py: added unittest * src/GrampsDbUtils/test/_GrampsDbWRFactories_test.py: added unittest

View File

@ -121,49 +121,49 @@ _mother_level = [ "", "%(step)smother%(inlaw)s",
"nineteenth great %(step)sgrandmother%(inlaw)s", "nineteenth great %(step)sgrandmother%(inlaw)s",
"twentieth great %(step)sgrandmother%(inlaw)s", ] "twentieth great %(step)sgrandmother%(inlaw)s", ]
_son_level = [ "", "%(step)sson", "%(step)sgrandson", _son_level = [ "", "%(step)sson%(inlaw)s", "%(step)sgrandson%(inlaw)s",
"great %(step)sgrandson", "great %(step)sgrandson%(inlaw)s",
"second great %(step)sgrandson", "second great %(step)sgrandson%(inlaw)s",
"third great %(step)sgrandson", "third great %(step)sgrandson%(inlaw)s",
"fourth great %(step)sgrandson", "fourth great %(step)sgrandson%(inlaw)s",
"fifth great %(step)sgrandson", "fifth great %(step)sgrandson%(inlaw)s",
"sixth great %(step)sgrandson", "sixth great %(step)sgrandson%(inlaw)s",
"seventh great %(step)sgrandson", "seventh great %(step)sgrandson%(inlaw)s",
"eighth great %(step)sgrandson", "eighth great %(step)sgrandson%(inlaw)s",
"ninth great %(step)sgrandson", "ninth great %(step)sgrandson%(inlaw)s",
"tenth great %(step)sgrandson", "tenth great %(step)sgrandson%(inlaw)s",
"eleventh great %(step)sgrandson", "eleventh great %(step)sgrandson%(inlaw)s",
"twelfth great %(step)sgrandson", "twelfth great %(step)sgrandson%(inlaw)s",
"thirteenth great %(step)sgrandson", "thirteenth great %(step)sgrandson%(inlaw)s",
"fourteenth great %(step)sgrandson", "fourteenth great %(step)sgrandson%(inlaw)s",
"fifteenth great %(step)sgrandson", "fifteenth great %(step)sgrandson%(inlaw)s",
"sixteenth great %(step)sgrandson", "sixteenth great %(step)sgrandson%(inlaw)s",
"seventeenth great %(step)sgrandson", "seventeenth great %(step)sgrandson%(inlaw)s",
"eighteenth great %(step)sgrandson", "eighteenth great %(step)sgrandson%(inlaw)s",
"nineteenth great %(step)sgrandson", "nineteenth great %(step)sgrandson%(inlaw)s",
"twentieth great %(step)sgrandson", ] "twentieth great %(step)sgrandson%(inlaw)s", ]
_daughter_level = [ "", "%(step)sdaughter", "%(step)sgranddaughter", _daughter_level = [ "", "%(step)sdaughter%(inlaw)s", "%(step)sgranddaughter%(inlaw)s",
"great %(step)sgranddaughter", "great %(step)sgranddaughter%(inlaw)s",
"second great %(step)sgranddaughter", "second great %(step)sgranddaughter%(inlaw)s",
"third great %(step)sgranddaughter", "third great %(step)sgranddaughter%(inlaw)s",
"fourth great %(step)sgranddaughter", "fourth great %(step)sgranddaughter%(inlaw)s",
"fifth great %(step)sgranddaughter", "fifth great %(step)sgranddaughter%(inlaw)s",
"sixth great %(step)sgranddaughter", "sixth great %(step)sgranddaughter%(inlaw)s",
"seventh great %(step)sgranddaughter", "seventh great %(step)sgranddaughter%(inlaw)s",
"eighth great %(step)sgranddaughter", "eighth great %(step)sgranddaughter%(inlaw)s",
"ninth great %(step)sgranddaughter", "ninth great %(step)sgranddaughter%(inlaw)s",
"tenth great %(step)sgranddaughter", "tenth great %(step)sgranddaughter%(inlaw)s",
"eleventh great %(step)sgranddaughter", "eleventh great %(step)sgranddaughter%(inlaw)s",
"twelfth great %(step)sgranddaughter", "twelfth great %(step)sgranddaughter%(inlaw)s",
"thirteenth great %(step)sgranddaughter", "thirteenth great %(step)sgranddaughter%(inlaw)s",
"fourteenth great %(step)sgranddaughter", "fourteenth great %(step)sgranddaughter%(inlaw)s",
"fifteenth great %(step)sgranddaughter", "fifteenth great %(step)sgranddaughter%(inlaw)s",
"sixteenth great %(step)sgranddaughter", "sixteenth great %(step)sgranddaughter%(inlaw)s",
"seventeenth great %(step)sgranddaughter", "seventeenth great %(step)sgranddaughter%(inlaw)s",
"eighteenth great %(step)sgranddaughter", "eighteenth great %(step)sgranddaughter%(inlaw)s",
"nineteenth great %(step)sgranddaughter", "nineteenth great %(step)sgranddaughter%(inlaw)s",
"twentieth great %(step)sgranddaughter", ] "twentieth great %(step)sgranddaughter%(inlaw)s", ]
_sister_level = [ "", "%(step)ssister%(inlaw)s", "%(step)saunt%(inlaw)s", _sister_level = [ "", "%(step)ssister%(inlaw)s", "%(step)saunt%(inlaw)s",
"%(step)sgrandaunt%(inlaw)s", "%(step)sgrandaunt%(inlaw)s",
@ -397,15 +397,16 @@ class RelationshipCalculator:
else: else:
return _father_level[level] % {'step': step, 'inlaw': inlaw} return _father_level[level] % {'step': step, 'inlaw': inlaw}
DIST_SON = "distant %(step)sdescendant (%(level)d generations)" DIST_SON = "distant %(step)sdescendant%(inlaw)s (%(level)d generations)"
def _get_son(self, level, step=''): def _get_son(self, level, step='', inlaw=''):
"""Internal english method to create relation string """Internal english method to create relation string
""" """
if level>len(_son_level)-1: if level>len(_son_level)-1:
return self.DIST_SON % {'step': step, 'level': level} return self.DIST_SON % {'step': step, 'inlaw': inlaw,
'level': level}
else: else:
return _son_level[level] % {'step': step} return _son_level[level] % {'step': step, 'inlaw': inlaw}
DIST_MOTHER = "distant %(step)sancestor%(inlaw)s (%(level)d generations)" DIST_MOTHER = "distant %(step)sancestor%(inlaw)s (%(level)d generations)"
@ -418,15 +419,16 @@ class RelationshipCalculator:
else: else:
return _mother_level[level] % {'step': step, 'inlaw': inlaw} return _mother_level[level] % {'step': step, 'inlaw': inlaw}
DIST_DAUGHTER = "distant %(step)sdescendant (%(level)d generations)" DIST_DAUGHTER = "distant %(step)sdescendant%(inlaw)s (%(level)d generations)"
def _get_daughter(self, level, step=''): def _get_daughter(self, level, step='', inlaw=''):
"""Internal english method to create relation string """Internal english method to create relation string
""" """
if level>len(_daughter_level)-1: if level>len(_daughter_level)-1:
return self.DIST_DAUGHTER % {'step': step, 'level': level} return self.DIST_DAUGHTER % {'step': step, 'inlaw': inlaw,
'level': level}
else: else:
return _daughter_level[level] % {'step': step} return _daughter_level[level] % {'step': step, 'inlaw': inlaw}
def _get_parent_unknown(self, level, step='', inlaw=''): def _get_parent_unknown(self, level, step='', inlaw=''):
"""Internal english method to create relation string """Internal english method to create relation string
@ -439,11 +441,12 @@ class RelationshipCalculator:
DIST_CHILD = "distant %(step)sdescendant (%(level)d generations)" DIST_CHILD = "distant %(step)sdescendant (%(level)d generations)"
def _get_child_unknown(self, level, step=''): def _get_child_unknown(self, level, step='', inlaw=''):
"""Internal english method to create relation string """Internal english method to create relation string
""" """
if level < len(_level_name): if level < len(_level_name):
return _level_name[level] + ' ' + '%sdescendant' % step return _level_name[level] + ' ' + '%(step)sdescendant%(inlaw)s' % {
'step': step, 'inlaw': inlaw}
else: else:
return self.DIST_CHILD % {'step': step, 'level': level} return self.DIST_CHILD % {'step': step, 'level': level}
@ -1478,20 +1481,12 @@ class RelationshipCalculator:
# b is descendant of a # b is descendant of a
if Gb == 0 : if Gb == 0 :
rel_str = 'same person' rel_str = 'same person'
elif Gb == 1 and inlaw:
#inlaw children only exist up to first level:
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_son(Gb, step)+inlaw
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_daughter(Gb, step)+inlaw
else:
rel_str = self._get_child_unknown(Gb, step)+inlaw
elif gender_b == gen.lib.Person.MALE: elif gender_b == gen.lib.Person.MALE:
rel_str = self._get_son(Gb, step) rel_str = self._get_son(Gb, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_daughter(Gb, step) rel_str = self._get_daughter(Gb, step, inlaw)
else: else:
rel_str = self._get_child_unknown(Gb, step) rel_str = self._get_child_unknown(Gb, step, inlaw)
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: if gender_b == gen.lib.Person.MALE:
@ -1669,74 +1664,49 @@ def _test(rc, onlybirth, inlawa, inlawb, printrelstr):
#rc = RelationshipCalculator() #rc = RelationshipCalculator()
if inlawa or inlawb : print '\ntesting sons (Enter to start)\n'
print '\ngrandchildren cannot have in-law extension; only testing'\ sys.stdin.readline()
'children\n' for i in range(MAX) :
print FMT % rc.get_single_relationship_string(0, 1, relstr = _rand_relstr(i,'f')
gen.lib.Person.MALE, rel = FMT % rc.get_single_relationship_string(0, i,
gen.lib.Person.MALE, gen.lib.Person.MALE,
'', 'f', gen.lib.Person.MALE,
only_birth=onlybirth, '', relstr,
in_law_a=inlawa, only_birth=onlybirth,
in_law_b=inlawb) in_law_a=inlawa,
print FMT % rc.get_single_relationship_string(0, 1, in_law_b=inlawb)
gen.lib.Person.MALE, if printrelstr :
gen.lib.Person.FEMALE, print rel + ' |info:', relstr
'', 'f', else:
only_birth=onlybirth, print rel
in_law_a=inlawa, print '\n\ntesting daughters\n'
in_law_b=inlawb) sys.stdin.readline()
print FMT % rc.get_single_relationship_string(0, 1, for i in range(MAX) :
gen.lib.Person.MALE, relstr = _rand_relstr(i,'m')
gen.lib.Person.UNKNOWN, rel = FMT % rc.get_single_relationship_string(0, i,
'', 'f', gen.lib.Person.MALE,
only_birth=onlybirth, gen.lib.Person.FEMALE,
in_law_a=inlawa, '', relstr,
in_law_b=inlawb) only_birth=onlybirth,
else: in_law_a=inlawa, in_law_b=inlawb)
print '\ntesting sons (Enter to start)\n' if printrelstr :
sys.stdin.readline() print rel + ' |info:', relstr
for i in range(MAX) : else:
relstr = _rand_relstr(i,'f') print rel
rel = FMT % rc.get_single_relationship_string(0, i, print '\n\ntesting unknown children\n'
gen.lib.Person.MALE, sys.stdin.readline()
gen.lib.Person.MALE, for i in range(MAX) :
'', relstr, relstr = _rand_relstr(i,'f')
only_birth=onlybirth, rel = FMT % rc.get_single_relationship_string(0, i,
in_law_a=inlawa, gen.lib.Person.MALE,
in_law_b=inlawb) gen.lib.Person.UNKNOWN,
if printrelstr : '', relstr,
print rel + ' |info:', relstr only_birth=onlybirth,
else: in_law_a=inlawa, in_law_b=inlawb)
print rel if printrelstr :
print '\n\ntesting daughters\n' print rel + ' |info:', relstr
sys.stdin.readline() else:
for i in range(MAX) : print rel
relstr = _rand_relstr(i,'m')
rel = FMT % rc.get_single_relationship_string(0, i,
gen.lib.Person.MALE,
gen.lib.Person.FEMALE,
'', relstr,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb)
if printrelstr :
print rel + ' |info:', relstr
else:
print rel
print '\n\ntesting unknown children\n'
sys.stdin.readline()
for i in range(MAX) :
relstr = _rand_relstr(i,'f')
rel = FMT % rc.get_single_relationship_string(0, i,
gen.lib.Person.MALE,
gen.lib.Person.UNKNOWN,
'', relstr,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb)
if printrelstr :
print rel + ' |info:', relstr
else:
print rel
print '\n\ntesting grandfathers\n' print '\n\ntesting grandfathers\n'
sys.stdin.readline() sys.stdin.readline()
for i in range(MAX) : for i in range(MAX) :

View File

@ -196,25 +196,25 @@ _ouder_level = [ "",
"%s%sedelstamoudouder (generatie 29)" ] "%s%sedelstamoudouder (generatie 29)" ]
_son_level = [ "", _son_level = [ "",
"%szoon", "%s%szoon",
"%skleinzoon", "%s%skleinzoon",
"%sachterkleinzoon", "%s%sachterkleinzoon",
"%sachterachterkleinzoon", "%s%sachterachterkleinzoon",
"%sachterachterachterkleinzoon"] "%s%sachterachterachterkleinzoon"]
_daughter_level = [ "", _daughter_level = [ "",
"%sdochter", "%s%sdochter",
"%skleindochter", "%s%skleindochter",
"%sachterkleindochter", "%s%sachterkleindochter",
"%sachterachterkleindochter", "%s%sachterachterkleindochter",
"%sachterachterachterkleindochter"] "%s%sachterachterachterkleindochter"]
_kind_level = [ "", _kind_level = [ "",
"%skind", "%s%skind",
"%skleinkind", "%s%skleinkind",
"%sachterkleinkind", "%s%sachterkleinkind",
"%sachterachterkleinkind", "%s%sachterachterkleinkind",
"%sachterachterachterkleinkind"] "%s%sachterachterachterkleinkind"]
_nephew_level = [ "", _nephew_level = [ "",
"%s%sneef", "%s%sneef",
@ -268,48 +268,51 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else: else:
return _father_level[level] % (inlaw, step) return _father_level[level] % (inlaw, step)
def _get_son(self, level, step=''): def _get_son(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string """Internal Dutch method to create relation string
""" """
if level < len(_son_level): if level < len(_son_level):
return _son_level[level] % step return _son_level[level] % (inlaw, step)
else: else:
return "verre %sachterkleinzoon (%d generaties)" % (step, level) return "verre %s%sachterkleinzoon (%d generaties)" % (inlaw,
step, level)
def _get_mother(self,level, step='', inlaw=''): def _get_mother(self,level, step='', inlaw=''):
"""Internal Dutch method to create relation string """Internal Dutch method to create relation string
""" """
if level > len(_mother_level)-1: if level > len(_mother_level)-1:
return "verre voormoeder (%d generaties)" % (inlaw, step, level) return "verre %s%svoormoeder (%d generaties)" % (inlaw, step, level)
else: else:
return _mother_level[level] % (inlaw, step) return _mother_level[level] % (inlaw, step)
def _get_daughter(self, level, step=''): def _get_daughter(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string """Internal Dutch method to create relation string
""" """
if level > len(_daughter_level)-1: if level > len(_daughter_level)-1:
return "verre %sachterkleindochter (%d generaties)" % (step, level) return "verre %s%sachterkleindochter (%d generaties)" % (inlaw,
step, level)
else: else:
return _daughter_level[level] % step return _daughter_level[level] % (inlaw, step)
def _get_parent_unknown(self, level, step='', inlaw=''): def _get_parent_unknown(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string """Internal Dutch method to create relation string
""" """
if level > len(_ouder_level)-1: if level > len(_ouder_level)-1:
return "verre voorouder (%d generaties)" % (inlaw, step, level) return "verre %s%svoorouder (%d generaties)" % (inlaw, step, level)
elif level == 1: elif level == 1:
return _mother_level[level] % (inlaw, step) + ' of ' + \ return _mother_level[level] % (inlaw, step) + ' of ' + \
_father_level[level] % (inlaw, step) _father_level[level] % (inlaw, step)
else: else:
return _ouder_level[level] % (inlaw, step) return _ouder_level[level] % (inlaw, step)
def _get_child_unknown(self, level, step=''): def _get_child_unknown(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string """Internal Dutch method to create relation string
""" """
if level > len(_kind_level)-1: if level > len(_kind_level)-1:
return "ver %sachterkleinkind (%d generaties)" % (step, level) return "ver %s%sachterkleinkind (%d generaties)" % (inlaw, step,
level)
else: else:
return _kind_level[level] % step return _kind_level[level] % (inlaw, step)
def _get_aunt(self, level, removed, step='', inlaw=''): def _get_aunt(self, level, removed, step='', inlaw=''):
"""Internal Dutch method to create relation string """Internal Dutch method to create relation string
@ -472,11 +475,11 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
else: else:
rel_str = 'aangetrouwde stiefzoon of dochter' rel_str = 'aangetrouwde stiefzoon of dochter'
elif gender_b == gen.lib.Person.MALE: elif gender_b == gen.lib.Person.MALE:
rel_str = self._get_son(Gb, step) rel_str = self._get_son(Gb, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE: elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_daughter(Gb, step) rel_str = self._get_daughter(Gb, step, inlaw)
else: else:
rel_str = self._get_child_unknown(Gb, step) rel_str = self._get_child_unknown(Gb, step, inlaw)
elif Ga > Gb: elif Ga > Gb:
#b is higher in the branch, in english uncle/aunt or #b is higher in the branch, in english uncle/aunt or
#cousin up, in dutch always 'oom/tante' #cousin up, in dutch always 'oom/tante'
@ -550,8 +553,8 @@ register_relcalc(RelationshipCalculator,
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 python # export PYTHONPATH=/path/to/gramps/src
# src/plugins/rel_nl.py # python src/plugins/rel_nl.py
"""TRANSLATORS, copy this if statement at the bottom of your """TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with: rel_xx.py module, and test your work with: