* src/plugins/all_relations.py: collapse inlaws
	* src/plugins/Ancestors.py: use new calling grandparent string
	* src/plugins/rel_nl.py: change to new API
	* src/plugins/rel_it.py: change comment
	* src/plugins/rel_pl.py: use old filter
	* src/Relationship.py: improvements, protected methods

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


svn: r9325
This commit is contained in:
Benny Malengier
2007-11-10 14:54:29 +00:00
parent 6e329879a4
commit 635ff9e829
7 changed files with 859 additions and 527 deletions

View File

@@ -1,4 +1,12 @@
2007-11-07 Benny Malengier <benny.malengier@gramps-project.org>
2007-11-10 Benny Malengier <benny.malengier@gramps-project.org>
* src/plugins/all_relations.py: collapse inlaws
* src/plugins/Ancestors.py: use new calling grandparent string
* src/plugins/rel_nl.py: change to new API
* src/plugins/rel_it.py: change comment
* src/plugins/rel_pl.py: use old filter
* src/Relationship.py: improvements, protected methods
2007-11-08 Benny Malengier <benny.malengier@gramps-project.org>
* TODO: update
* src/DisplayTabs/_EventEmbedList.py: catch managed window crash

View File

@@ -55,111 +55,205 @@ _removed_level = [ "", " once removed", " twice removed",
" eighteen times removed",
" nineteen times removed", " twenty times removed" ]
_parents_level = [ "", "parents", "grandparents", "great grandparents", "second great grandparents",
"third great grandparents", "fourth great grandparents",
"fifth great grandparents", "sixth great grandparents",
"seventh great grandparents", "eighth great grandparents",
"ninth great grandparents", "tenth great grandparents",
"eleventh great grandparents", "twelfth great grandparents",
"thirteenth great grandparents", "fourteenth great grandparents",
"fifteenth great grandparents", "sixteenth great grandparents",
"seventeenth great grandparents", "eighteenth great grandparents",
"nineteenth great grandparents", "twentieth great grandparents", ]
_parents_level = [ "", "parents", "grandparents", "great grandparents",
"second great grandparents",
"third great grandparents",
"fourth great grandparents",
"fifth great grandparents",
"sixth great grandparents",
"seventh great grandparents",
"eighth great grandparents",
"ninth great grandparents",
"tenth great grandparents",
"eleventh great grandparents",
"twelfth great grandparents",
"thirteenth great grandparents",
"fourteenth great grandparents",
"fifteenth great grandparents",
"sixteenth great grandparents",
"seventeenth great grandparents",
"eighteenth great grandparents",
"nineteenth great grandparents",
"twentieth great grandparents", ]
_father_level = [ "", "%sfather%s", "%sgrandfather%s", "great %sgrandfather%s",
"second great %sgrandfather%s",
"third great %sgrandfather%s", "fourth great %sgrandfather%s",
"fifth great %sgrandfather%s", "sixth great %sgrandfather%s",
"seventh great %sgrandfather%s", "eighth great %sgrandfather%s",
"ninth great %sgrandfather%s", "tenth great %sgrandfather%s",
"eleventh great %sgrandfather%s", "twelfth great %sgrandfather%s",
"thirteenth great %sgrandfather%s", "fourteenth great %sgrandfather%s",
"fifteenth great %sgrandfather%s", "sixteenth great %sgrandfather%s",
"seventeenth great %sgrandfather%s", "eighteenth great %sgrandfather%s",
"nineteenth great %sgrandfather%s", "twentieth great %sgrandfather%s", ]
_father_level = [ "", "%(step)sfather%(inlaw)s", "%(step)sgrandfather%(inlaw)s",
"great %(step)sgrandfather%(inlaw)s",
"second great %(step)sgrandfather%(inlaw)s",
"third great %(step)sgrandfather%(inlaw)s",
"fourth great %(step)sgrandfather%(inlaw)s",
"fifth great %(step)sgrandfather%(inlaw)s",
"sixth great %(step)sgrandfather%(inlaw)s",
"seventh great %(step)sgrandfather%(inlaw)s",
"eighth great %(step)sgrandfather%(inlaw)s",
"ninth great %(step)sgrandfather%(inlaw)s",
"tenth great %(step)sgrandfather%(inlaw)s",
"eleventh great %(step)sgrandfather%(inlaw)s",
"twelfth great %(step)sgrandfather%(inlaw)s",
"thirteenth great %(step)sgrandfather%(inlaw)s",
"fourteenth great %(step)sgrandfather%(inlaw)s",
"fifteenth great %(step)sgrandfather%(inlaw)s",
"sixteenth great %(step)sgrandfather%(inlaw)s",
"seventeenth great %(step)sgrandfather%(inlaw)s",
"eighteenth great %(step)sgrandfather%(inlaw)s",
"nineteenth great %(step)sgrandfather%(inlaw)s",
"twentieth great %(step)sgrandfather%(inlaw)s", ]
_mother_level = [ "", "%smother%s", "%sgrandmother%s", "great %sgrandmother%s",
"second great %sgrandmother%s",
"third great %sgrandmother%s", "fourth great %sgrandmother%s",
"fifth great %sgrandmother%s", "sixth great %sgrandmother%s",
"seventh great %sgrandmother%s", "eighth great %sgrandmother%s",
"ninth great %sgrandmother%s", "tenth great %sgrandmother%s",
"eleventh great %sgrandmother%s", "twelfth great %sgrandmother%s",
"thirteenth great %sgrandmother%s", "fourteenth great %sgrandmother%s",
"fifteenth great %sgrandmother%s", "sixteenth great %sgrandmother%s",
"seventeenth great %sgrandmother%s", "eighteenth great %sgrandmother%s",
"nineteenth great %sgrandmother%s", "twentieth great %sgrandmother%s", ]
_mother_level = [ "", "%(step)smother%(inlaw)s",
"%(step)sgrandmother%(inlaw)s",
"great %(step)sgrandmother%(inlaw)s",
"second great %(step)sgrandmother%(inlaw)s",
"third great %(step)sgrandmother%(inlaw)s",
"fourth great %(step)sgrandmother%(inlaw)s",
"fifth great %(step)sgrandmother%(inlaw)s",
"sixth great %(step)sgrandmother%(inlaw)s",
"seventh great %(step)sgrandmother%(inlaw)s",
"eighth great %(step)sgrandmother%(inlaw)s",
"ninth great %(step)sgrandmother%(inlaw)s",
"tenth great %(step)sgrandmother%(inlaw)s",
"eleventh great %(step)sgrandmother%(inlaw)s",
"twelfth great %(step)sgrandmother%(inlaw)s",
"thirteenth great %(step)sgrandmother%(inlaw)s",
"fourteenth great %(step)sgrandmother%(inlaw)s",
"fifteenth great %(step)sgrandmother%(inlaw)s",
"sixteenth great %(step)sgrandmother%(inlaw)s",
"seventeenth great %(step)sgrandmother%(inlaw)s",
"eighteenth great %(step)sgrandmother%(inlaw)s",
"nineteenth great %(step)sgrandmother%(inlaw)s",
"twentieth great %(step)sgrandmother%(inlaw)s", ]
_son_level = [ "", "%sson", "%sgrandson", "great %sgrandson", "second great %sgrandson",
"third great %sgrandson", "fourth great %sgrandson",
"fifth great %sgrandson", "sixth great %sgrandson",
"seventh great %sgrandson", "eighth great %sgrandson",
"ninth great %sgrandson", "tenth great %sgrandson",
"eleventh great %sgrandson", "twelfth great %sgrandson",
"thirteenth great %sgrandson", "fourteenth great %sgrandson",
"fifteenth great %sgrandson", "sixteenth great %sgrandson",
"seventeenth great %sgrandson", "eighteenth great %sgrandson",
"nineteenth great %sgrandson", "twentieth great %sgrandson", ]
_son_level = [ "", "%(step)sson", "%(step)sgrandson",
"great %(step)sgrandson",
"second great %(step)sgrandson",
"third great %(step)sgrandson",
"fourth great %(step)sgrandson",
"fifth great %(step)sgrandson",
"sixth great %(step)sgrandson",
"seventh great %(step)sgrandson",
"eighth great %(step)sgrandson",
"ninth great %(step)sgrandson",
"tenth great %(step)sgrandson",
"eleventh great %(step)sgrandson",
"twelfth great %(step)sgrandson",
"thirteenth great %(step)sgrandson",
"fourteenth great %(step)sgrandson",
"fifteenth great %(step)sgrandson",
"sixteenth great %(step)sgrandson",
"seventeenth great %(step)sgrandson",
"eighteenth great %(step)sgrandson",
"nineteenth great %(step)sgrandson",
"twentieth great %(step)sgrandson", ]
_daughter_level = [ "", "%sdaughter", "%sgranddaughter", "great %sgranddaughter",
"second great %sgranddaughter",
"third great %sgranddaughter", "fourth great %sgranddaughter",
"fifth great %sgranddaughter", "sixth great %sgranddaughter",
"seventh great %sgranddaughter", "eighth great %sgranddaughter",
"ninth great %sgranddaughter", "tenth great %sgranddaughter",
"eleventh great %sgranddaughter", "twelfth great %sgranddaughter",
"thirteenth great %sgranddaughter", "fourteenth great %sgranddaughter",
"fifteenth great %sgranddaughter", "sixteenth great %sgranddaughter",
"seventeenth great %sgranddaughter", "eighteenth great %sgranddaughter",
"nineteenth great %sgranddaughter", "twentieth great %sgranddaughter", ]
_daughter_level = [ "", "%(step)sdaughter", "%(step)sgranddaughter",
"great %(step)sgranddaughter",
"second great %(step)sgranddaughter",
"third great %(step)sgranddaughter",
"fourth great %(step)sgranddaughter",
"fifth great %(step)sgranddaughter",
"sixth great %(step)sgranddaughter",
"seventh great %(step)sgranddaughter",
"eighth great %(step)sgranddaughter",
"ninth great %(step)sgranddaughter",
"tenth great %(step)sgranddaughter",
"eleventh great %(step)sgranddaughter",
"twelfth great %(step)sgranddaughter",
"thirteenth great %(step)sgranddaughter",
"fourteenth great %(step)sgranddaughter",
"fifteenth great %(step)sgranddaughter",
"sixteenth great %(step)sgranddaughter",
"seventeenth great %(step)sgranddaughter",
"eighteenth great %(step)sgranddaughter",
"nineteenth great %(step)sgranddaughter",
"twentieth great %(step)sgranddaughter", ]
_sister_level = [ "", "%ssister%s", "%saunt%s", "%sgrandaunt%s",
"great %sgrandaunt%s", "second great %sgrandaunt%s",
"third great %sgrandaunt%s", "fourth great %sgrandaunt%s",
"fifth great %sgrandaunt%s", "sixth great %sgrandaunt%s",
"seventh great %sgrandaunt%s", "eighth great %sgrandaunt%s",
"ninth great %sgrandaunt%s", "tenth great %sgrandaunt%s",
"eleventh great %sgrandaunt%s", "twelfth great %sgrandaunt%s",
"thirteenth great %sgrandaunt%s", "fourteenth great %sgrandaunt%s",
"fifteenth great %sgrandaunt%s", "sixteenth great %sgrandaunt%s",
"seventeenth great %sgrandaunt%s", "eighteenth great %sgrandaunt%s",
"nineteenth great %sgrandaunt%s", "twentieth great %sgrandaunt%s", ]
_sister_level = [ "", "%(step)ssister%(inlaw)s", "%(step)saunt%(inlaw)s",
"%(step)sgrandaunt%(inlaw)s",
"great %(step)sgrandaunt%(inlaw)s",
"second great %(step)sgrandaunt%(inlaw)s",
"third great %(step)sgrandaunt%(inlaw)s",
"fourth great %(step)sgrandaunt%(inlaw)s",
"fifth great %(step)sgrandaunt%(inlaw)s",
"sixth great %(step)sgrandaunt%(inlaw)s",
"seventh great %(step)sgrandaunt%(inlaw)s",
"eighth great %(step)sgrandaunt%(inlaw)s",
"ninth great %(step)sgrandaunt%(inlaw)s",
"tenth great %(step)sgrandaunt%(inlaw)s",
"eleventh great %(step)sgrandaunt%(inlaw)s",
"twelfth great %(step)sgrandaunt%(inlaw)s",
"thirteenth great %(step)sgrandaunt%(inlaw)s",
"fourteenth great %(step)sgrandaunt%(inlaw)s",
"fifteenth great %(step)sgrandaunt%(inlaw)s",
"sixteenth great %(step)sgrandaunt%(inlaw)s",
"seventeenth great %(step)sgrandaunt%(inlaw)s",
"eighteenth great %(step)sgrandaunt%(inlaw)s",
"nineteenth great %(step)sgrandaunt%(inlaw)s",
"twentieth great %(step)sgrandaunt%(inlaw)s", ]
_brother_level = [ "", "%sbrother%s", "%suncle%s", "%sgranduncle%s",
"great %sgranduncle%s", "second great %sgranduncle%s",
"third great %sgranduncle%s", "fourth great %sgranduncle%s",
"fifth great %sgranduncle%s", "sixth great %sgranduncle%s",
"seventh great %sgranduncle%s", "eighth great %sgranduncle%s",
"ninth great %sgranduncle%s", "tenth great %sgranduncle%s",
"eleventh great %sgranduncle%s", "twelfth great %sgranduncle%s",
"thirteenth great %sgranduncle%s", "fourteenth great %sgranduncle%s",
"fifteenth great %sgranduncle%s", "sixteenth great %sgranduncle%s",
"seventeenth great %sgranduncle%s", "eighteenth great %sgranduncle%s",
"nineteenth great %sgranduncle%s", "twentieth great %sgranduncle%s", ]
_brother_level = [ "", "%(step)sbrother%(inlaw)s", "%(step)suncle%(inlaw)s",
"%(step)sgranduncle%(inlaw)s",
"great %(step)sgranduncle%(inlaw)s",
"second great %(step)sgranduncle%(inlaw)s",
"third great %(step)sgranduncle%(inlaw)s",
"fourth great %(step)sgranduncle%(inlaw)s",
"fifth great %(step)sgranduncle%(inlaw)s",
"sixth great %(step)sgranduncle%(inlaw)s",
"seventh great %(step)sgranduncle%(inlaw)s",
"eighth great %(step)sgranduncle%(inlaw)s",
"ninth great %(step)sgranduncle%(inlaw)s",
"tenth great %(step)sgranduncle%(inlaw)s",
"eleventh great %(step)sgranduncle%(inlaw)s",
"twelfth great %(step)sgranduncle%(inlaw)s",
"thirteenth great %(step)sgranduncle%(inlaw)s",
"fourteenth great %(step)sgranduncle%(inlaw)s",
"fifteenth great %(step)sgranduncle%(inlaw)s",
"sixteenth great %(step)sgranduncle%(inlaw)s",
"seventeenth great %(step)sgranduncle%(inlaw)s",
"eighteenth great %(step)sgranduncle%(inlaw)s",
"nineteenth great %(step)sgranduncle%(inlaw)s",
"twentieth great %(step)sgranduncle%(inlaw)s", ]
_nephew_level = [ "", "%snephew%s", "%sgrandnephew%s", "great %sgrandnephew%s",
"second great %sgrandnephew%s",
"third great %sgrandnephew%s", "fourth great %sgrandnephew%s",
"fifth great %sgrandnephew%s", "sixth great %sgrandnephew%s",
"seventh great %sgrandnephew%s", "eighth great %sgrandnephew%s",
"ninth great %sgrandnephew%s", "tenth great %sgrandnephew%s",
"eleventh great %sgrandnephew%s", "twelfth great %sgrandnephew%s",
"thirteenth great %sgrandnephew%s", "fourteenth great %sgrandnephew%s",
"fifteenth great %sgrandnephew%s", "sixteenth great %sgrandnephew%s",
"seventeenth great %sgrandnephew%s", "eighteenth great %sgrandnephew%s",
"nineteenth great %sgrandnephew%s", "twentieth great %sgrandnephew%s", ]
_nephew_level = [ "", "%(step)snephew%(inlaw)s", "%(step)sgrandnephew%(inlaw)s",
"great %(step)sgrandnephew%(inlaw)s",
"second great %(step)sgrandnephew%(inlaw)s",
"third great %(step)sgrandnephew%(inlaw)s",
"fourth great %(step)sgrandnephew%(inlaw)s",
"fifth great %(step)sgrandnephew%(inlaw)s",
"sixth great %(step)sgrandnephew%(inlaw)s",
"seventh great %(step)sgrandnephew%(inlaw)s",
"eighth great %(step)sgrandnephew%(inlaw)s",
"ninth great %(step)sgrandnephew%(inlaw)s",
"tenth great %(step)sgrandnephew%(inlaw)s",
"eleventh great %(step)sgrandnephew%(inlaw)s",
"twelfth great %(step)sgrandnephew%(inlaw)s",
"thirteenth great %(step)sgrandnephew%(inlaw)s",
"fourteenth great %(step)sgrandnephew%(inlaw)s",
"fifteenth great %(step)sgrandnephew%(inlaw)s",
"sixteenth great %(step)sgrandnephew%(inlaw)s",
"seventeenth great %(step)sgrandnephew%(inlaw)s",
"eighteenth great %(step)sgrandnephew%(inlaw)s",
"nineteenth great %(step)sgrandnephew%(inlaw)s",
"twentieth great %(step)sgrandnephew%(inlaw)s", ]
_niece_level = [ "", "%sniece%s", "%sgrandniece%s", "great %sgrandniece%s",
"second great %sgrandniece%s",
"third great %sgrandniece%s", "fourth great %sgrandniece%s",
"fifth great %sgrandniece%s", "sixth great %sgrandniece%s",
"seventh great %sgrandniece%s", "eighth great %sgrandniece%s",
"ninth great %sgrandniece%s", "tenth great %sgrandniece%s",
"eleventh great %sgrandniece%s", "twelfth great %sgrandniece%s",
"thirteenth great %sgrandniece%s", "fourteenth great %sgrandniece%s",
"fifteenth great %sgrandniece%s", "sixteenth great %sgrandniece%s",
"seventeenth great %sgrandniece%s", "eighteenth great %sgrandniece%s",
"nineteenth great %sgrandniece%s", "twentieth great %sgrandniece%s", ]
_niece_level = [ "", "%(step)sniece%(inlaw)s", "%(step)sgrandniece%(inlaw)s",
"great %(step)sgrandniece%(inlaw)s",
"second great %(step)sgrandniece%(inlaw)s",
"third great %(step)sgrandniece%(inlaw)s",
"fourth great %(step)sgrandniece%(inlaw)s",
"fifth great %(step)sgrandniece%(inlaw)s",
"sixth great %(step)sgrandniece%(inlaw)s",
"seventh great %(step)sgrandniece%(inlaw)s",
"eighth great %(step)sgrandniece%(inlaw)s",
"ninth great %(step)sgrandniece%(inlaw)s",
"tenth great %(step)sgrandniece%(inlaw)s",
"eleventh great %(step)sgrandniece%(inlaw)s",
"twelfth great %(step)sgrandniece%(inlaw)s",
"thirteenth great %(step)sgrandniece%(inlaw)s",
"fourteenth great %(step)sgrandniece%(inlaw)s",
"fifteenth great %(step)sgrandniece%(inlaw)s",
"sixteenth great %(step)sgrandniece%(inlaw)s",
"seventeenth great %(step)sgrandniece%(inlaw)s",
"eighteenth great %(step)sgrandniece%(inlaw)s",
"nineteenth great %(step)sgrandniece%(inlaw)s",
"twentieth great %(step)sgrandniece%(inlaw)s", ]
_children_level = [ "",
"children", "grandchildren",
@@ -189,18 +283,29 @@ _siblings_level = [ "",
"twentieth great granduncles/aunts", ]
_sibling_level = [ "",
"%ssibling%s", "%suncle/aunt%s",
"%sgranduncle/aunt%s", "great %sgranduncle/aunt%s",
"second great %sgranduncle/aunt%s", "third great %sgranduncle/aunt%s",
"fourth great %sgranduncle/aunt%s", "fifth great %sgranduncle/aunt%s",
"sixth great %sgranduncle/aunt%s", "seventh great %sgranduncle/aunt%s",
"eighth great %sgranduncle/aunt%s", "ninth great %sgranduncle/aunt%s",
"tenth great %sgranduncle/aunt%s", "eleventh great %sgranduncle/aunt%s",
"twelfth great %sgranduncle/aunt%s", "thirteenth great %sgranduncle/aunt%s",
"fourteenth great %sgranduncle/aunt%s", "fifteenth great %sgranduncle/aunt%s",
"sixteenth great %sgranduncle/aunt%s", "seventeenth great %sgranduncle/aunt%s",
"eighteenth great %sgranduncle/aunt%s", "nineteenth great %sgranduncle/aunt%s",
"twentieth great %sgranduncle/aunt%s", ]
"%(step)ssibling%(inlaw)s",
"%(step)suncle/aunt%(inlaw)s",
"%(step)sgranduncle/aunt%(inlaw)s",
"great %(step)sgranduncle/aunt%(inlaw)s",
"second great %(step)sgranduncle/aunt%(inlaw)s",
"third great %(step)sgranduncle/aunt%(inlaw)s",
"fourth great %(step)sgranduncle/aunt%(inlaw)s",
"fifth great %(step)sgranduncle/aunt%(inlaw)s",
"sixth great %(step)sgranduncle/aunt%(inlaw)s",
"seventh great %(step)sgranduncle/aunt%(inlaw)s",
"eighth great %(step)sgranduncle/aunt%(inlaw)s",
"ninth great %(step)sgranduncle/aunt%(inlaw)s",
"tenth great %(step)sgranduncle/aunt%(inlaw)s",
"eleventh great %(step)sgranduncle/aunt%(inlaw)s",
"twelfth great %(step)sgranduncle/aunt%(inlaw)s",
"thirteenth great %(step)sgranduncle/aunt%(inlaw)s",
"fourteenth great %(step)sgranduncle/aunt%(inlaw)s",
"fifteenth great %(step)sgranduncle/aunt%(inlaw)s",
"sixteenth great %(step)sgranduncle/aunt%(inlaw)s",
"seventeenth great %(step)sgranduncle/aunt%(inlaw)s",
"eighteenth great %(step)sgranduncle/aunt%(inlaw)s",
"nineteenth great %(step)sgranduncle/aunt%(inlaw)s",
"twentieth great %(step)sgranduncle/aunt%(inlaw)s", ]
_nephews_nieces_level = [ "",
"siblings",
@@ -258,9 +363,10 @@ class RelationshipCalculator:
#sibling strings
STEP= 'step'
INLAW='-in-law'
HALF = 'half-'
INLAW='-in-law'
#partner types
PARTNER_MARRIED = 1
PARTNER_UNMARRIED = 2
@@ -280,62 +386,129 @@ class RelationshipCalculator:
else:
return _parents_level[level]
def get_father(self, level, step='', inlaw=''):
DIST_FATHER = "distant %(step)sancestor%(inlaw)s (%(level)d generations)"
def _get_father(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level>len(_father_level)-1:
return "distant %sancestor%s (%d generations)" % (step, inlaw,
level)
return self.DIST_FATHER % {'step': step, 'inlaw': inlaw,
'level': level}
else:
return _father_level[level] % (step, inlaw)
return _father_level[level] % {'step': step, 'inlaw': inlaw}
def get_son(self, level, step=''):
DIST_SON = "distant %(step)sdescendant (%(level)d generations)"
def _get_son(self, level, step=''):
"""Internal english method to create relation string
"""
if level>len(_son_level)-1:
return "distant %sdescendant (%d generations)" % (step, level)
return self.DIST_SON % {'step': step, 'level': level}
else:
return _son_level[level] % step
return _son_level[level] % {'step': step}
def get_mother(self, level, step='', inlaw=''):
DIST_MOTHER = "distant %(step)sancestor%(inlaw)s (%(level)d generations)"
def _get_mother(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level>len(_mother_level)-1:
return "distant %sancestor%s (%d generations)" % (step, inlaw,
level)
return self.DIST_MOTHER % {'step': step, 'inlaw': inlaw,
'level': level}
else:
return _mother_level[level] % (step, inlaw)
return _mother_level[level] % {'step': step, 'inlaw': inlaw}
def get_daughter(self, level, step=''):
DIST_DAUGHTER = "distant %(step)sdescendant (%(level)d generations)"
def _get_daughter(self, level, step=''):
"""Internal english method to create relation string
"""
if level>len(_daughter_level)-1:
return "distant %sdescendant (%d generations)" % (step, level)
return self.DIST_DAUGHTER % {'step': step, 'level': level}
else:
return _daughter_level[level] % step
return _daughter_level[level] % {'step': step}
def get_parent_unknown(self, level, step='', inlaw=''):
def _get_parent_unknown(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level < len(_level_name):
return _level_name[level] + ' ' + '%sancestor%s' % (step, inlaw)
else:
return "distant %sancestor%s (%d generations)" % (step, inlaw,
level)
def get_child_unknown(self, level, step=''):
DIST_CHILD = "distant %(step)sdescendant (%(level)d generations)"
def _get_child_unknown(self, level, step=''):
"""Internal english method to create relation string
"""
if level < len(_level_name):
return _level_name[level] + ' ' + '%sdescendant' % step
else:
return "distant %sdescendant (%d generations)" % (step, level)
return self.DIST_CHILD % {'step': step, 'level': level}
def get_aunt(self, level, step='', inlaw=''):
DIST_AUNT = "distant %(step)saunt%(inlaw)s"
def _get_aunt(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level>len(_sister_level)-1:
return "distant %saunt%s" % (step, inlaw)
return self.DIST_AUNT % {'step': step, 'inlaw': inlaw}
else:
return _sister_level[level] % (step, inlaw)
return _sister_level[level] % {'step': step, 'inlaw': inlaw}
def get_uncle(self, level, step='', inlaw=''):
DIST_UNCLE = "distant %(step)suncle%(inlaw)s"
def _get_uncle(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level>len(_brother_level)-1:
return "distant %suncle%s" % (step, inlaw)
return self.DIST_UNCLE % {'step': step, 'inlaw': inlaw}
else:
return _brother_level[level] % (step, inlaw)
return _brother_level[level] % {'step': step, 'inlaw': inlaw}
def get_sibling(self, level, step='', inlaw=''):
if level < len(_sibling_level):
return _sibling_level[level] % (step, inlaw)
DIST_NEPHEW = "distant %(step)snephew%(inlaw)s"
def _get_nephew(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level>len(_nephew_level)-1:
return self.DIST_NEPHEW % {'step': step, 'inlaw': inlaw}
else:
return "distant %suncle%s/%saunt%s " % (step, inlaw, step, inlaw)
return _nephew_level[level] % {'step': step, 'inlaw': inlaw}
DIST_NIECE = "distant %(step)sniece%(inlaw)s"
def _get_niece(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level>len(_niece_level)-1:
return self.DIST_NIECE % {'step': step, 'inlaw': inlaw}
else:
return _niece_level[level] % {'step': step, 'inlaw': inlaw}
def _get_cousin(self, level, removed, dir = '', step='', inlaw=''):
"""Internal english method to create relation string
"""
if removed == 0 and level < len(_level_name):
return "%s %scousin%s" % (_level_name[level],
step, inlaw)
elif removed > len(_removed_level)-1 or level>len(_level_name)-1:
return "distant %srelative%s" % (step, inlaw)
else:
return "%s %scousin%s%s%s" % (_level_name[level],
step, inlaw,
_removed_level[removed], dir)
DIST_SIB = "distant %(step)suncle/aunt%(inlaw)s"
def _get_sibling(self, level, step='', inlaw=''):
"""Internal english method to create relation string
"""
if level < len(_sibling_level):
return _sibling_level[level] % {'step': step, 'inlaw': inlaw}
else:
return self.DIST_SIB % {'step': step, 'inlaw': inlaw}
def get_sibling_type(self, db, orig, other):
""" Translation free determination of type of orig and other as siblings
@@ -379,29 +552,6 @@ class RelationshipCalculator:
break
return (birthmother, birthfather)
def get_nephew(self, level, step='', inlaw=''):
if level>len(_nephew_level)-1:
return "distant %snephew%s" % (step, inlaw)
else:
return _nephew_level[level] % (step, inlaw)
def get_niece(self, level, step='', inlaw=''):
if level>len(_niece_level)-1:
return "distant %sniece%s" % (step, inlaw)
else:
return _niece_level[level] % (step, inlaw)
def get_cousin(self, level, removed, dir = '', step='', inlaw=''):
if removed == 0 and level < len(_level_name):
return "%s %scousin%s" % (_level_name[level],
step, inlaw)
elif removed > len(_removed_level)-1 or level>len(_level_name)-1:
return "distant %srelative%s" % (step, inlaw)
else:
return "%s %scousin%s%s%s" % (_level_name[level],
step, inlaw,
_removed_level[removed], dir)
def get_spouse_type(self, db, orig, other, all_rel = False):
""" Translation free determination if orig and other are partners.
The procedure returns partner types, these can be passed to
@@ -464,59 +614,9 @@ class RelationshipCalculator:
else:
return None
def get_relationship_distance_old(self, db, orig_person, other_person):
def __apply_filter_old(self, db, person, rel_str, plist, pmap, depth=1):
""" DEPRECATED -- DO NOT USE
"""
** DEPRECATED -- USE NEW **
NOTE: CHANGED ORDER OF RETURN, now first is rel to orig, second to other
(as it should, but wasn't !! )
Returns a tuple (firstRel, secondRel, common):
firstRel Number of generations from the orig_person to their
closest common ancestors, as eg 'ffmm'
secondRel Number of generations from the other_person to that
firstRel closest common ancestors, as eg 'ffmm'
common list of all these common ancestors (so same generation
difference with firstRel), no specific order !!
in the Rel, f is father, m is mother
"""
print "get_relationship_distance_old is deprecated, use new instead!"
firstRel = -1
secondRel = -1
common = []
firstMap = {}
firstList = []
secondMap = {}
secondList = []
rank = 9999999
try:
self.__apply_filter(db, orig_person, '', firstList, firstMap)
self.__apply_filter(db, other_person, '', secondList, secondMap)
except RuntimeError:
return (firstRel, secondRel, _("Relationship loop detected"))
for person_handle in firstList:
if person_handle in secondList:
new_rank = len(firstMap[person_handle])
if new_rank < rank:
rank = new_rank
common = [ person_handle ]
elif new_rank == rank:
common.append(person_handle)
if common:
person_handle = common[0]
firstRel = firstMap[person_handle]
secondRel = secondMap[person_handle]
return (firstRel,secondRel,common)
def __apply_filter(self, db, person, rel_str, plist, pmap, depth=1):
if person == None or depth > MAX_DEPTH:
return
depth += 1
@@ -530,12 +630,12 @@ class RelationshipCalculator:
fhandle = family.father_handle
if fhandle:
father = db.get_person_from_handle(fhandle)
self.__apply_filter(db, father, rel_str+'f', plist, pmap,
self.__apply_filter_old(db, father, rel_str+'f', plist, pmap,
depth)
mhandle = family.mother_handle
if mhandle:
mother = db.get_person_from_handle(mhandle)
self.__apply_filter(db, mother, rel_str+'m', plist, pmap,
self.__apply_filter_old(db, mother, rel_str+'m', plist, pmap,
depth)
except:
return
@@ -671,8 +771,8 @@ class RelationshipCalculator:
rank = 9999999
try:
self.__apply_filter_new(db, orig_person, '', [], firstMap)
self.__apply_filter_new(db, other_person, '', [], secondMap,
self.__apply_filter(db, orig_person, '', [], firstMap)
self.__apply_filter(db, other_person, '', [], secondMap,
stoprecursemap = firstMap,
store_all=False)
## print firstMap
@@ -755,7 +855,7 @@ class RelationshipCalculator:
else :
return [(-1,None,'',[],'',[])], self.__msg
def __apply_filter_new(self, db, person, rel_str, rel_fam, pmap,
def __apply_filter(self, db, person, rel_str, rel_fam, pmap,
depth=1, stoprecursemap=None, store_all=True):
'''We recursively add parents of person in pmap with correct rel_str,
if store_all. If store_all false, only store parents if in the
@@ -877,7 +977,7 @@ class RelationshipCalculator:
for handle in parentstodo.keys():
data = parentstodo[handle]
self.__apply_filter_new(db, data[0],
self.__apply_filter(db, data[0],
data[1], data[2],
pmap, depth, stoprecursemap, store_all)
@@ -1021,33 +1121,50 @@ class RelationshipCalculator:
self.REL_FATHER_NOTBIRTH, self.REL_MOTHER_NOTBIRTH])
return only_birth
def get_one_relationship(self, db, orig_person, other_person):
def get_one_relationship(self, db, orig_person, other_person,
extra_info=False):
"""
returns a string representing the most relevant relationship between
the two people
the two people. If extra_info = True, extra information is returned:
(relation_string, distance_common_orig, distance_common_other)
"""
stop = False
if orig_person == None:
return _("undefined")
rel_str = _("undefined")
stop = True
if orig_person.get_handle() == other_person.get_handle():
return ''
if not stop and orig_person.get_handle() == other_person.get_handle():
rel_str = ''
stop = True
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return is_spouse
if not stop:
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
rel_str = is_spouse
stop = True
if stop:
if extra_info:
return (rel_str, -1, -1)
else:
return rel_str
data, msg = self.get_relationship_distance_new(
db, orig_person, other_person,
all_dist=True,
all_families=True, only_birth=False)
if data[0][0] == -1:
return ''
if extra_info:
return ('', -1, -1)
else:
return ''
data = self.collapse_relations(data)
#most relevant relationship is a birth family relation of lowest rank
databest = [data[0]]
rankbest = data[0][0]
for rel in data :
#data is sorted on rank
if rel[0] == rankbest:
databest.append(rel)
rel = databest[0]
@@ -1056,12 +1173,13 @@ class RelationshipCalculator:
if len(databest) == 1:
birth = self.only_birth(rel[2]) and self.only_birth(rel[4])
if dist_orig == 1 and dist_other == 1:
return self.get_sibling_relationship_string(
rel_str = self.get_sibling_relationship_string(
self.get_sibling_type(
db, orig_person, other_person),
orig_person.get_gender(),
other_person.get_gender())
return self.get_single_relationship_string(dist_orig,
else:
rel_str = self.get_single_relationship_string(dist_orig,
dist_other,
orig_person.get_gender(),
other_person.get_gender(),
@@ -1109,12 +1227,13 @@ class RelationshipCalculator:
dist_other= len(rel[4])
birth = self.only_birth(rel[2]) and self.only_birth(rel[4])
if dist_orig == 1 and dist_other == 1:
return self.get_sibling_relationship_string(
rel_str = self.get_sibling_relationship_string(
self.get_sibling_type(
db, orig_person, other_person),
orig_person.get_gender(),
other_person.get_gender())
return self.get_single_relationship_string(dist_orig,
else:
rel_str = self.get_single_relationship_string(dist_orig,
dist_other,
orig_person.get_gender(),
other_person.get_gender(),
@@ -1122,6 +1241,10 @@ class RelationshipCalculator:
only_birth=birth,
in_law_a=False,
in_law_b=False)
if extra_info:
return (rel_str, dist_orig, dist_other)
else:
return rel_str
def get_relationship(self, db, orig_person, other_person):
"""
@@ -1170,33 +1293,17 @@ class RelationshipCalculator:
else:
return (rel_str, common)
def get_grandparents_string(self,db,orig_person,other_person):
def get_grandparents_string(self, db, orig_person, other_person):
"""
returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
returns a string representing the relationship between the two people
if the other_person is a grandparent in general terms and in plural
"""
if orig_person == None:
return ("undefined",[])
(rel_str, dist_orig, dist_other) = self.get_one_relationship(db,
orig_person, other_person,
extra_info = True)
if orig_person == other_person:
return ('', [])
(firstRel,secondRel,common) = \
self.get_relationship_distance(db,orig_person,other_person)
if type(common) == types.StringType or \
type(common) == types.UnicodeType:
return (common,[])
elif common:
person_handle = common[0]
else:
return ("",[])
if len(firstRel) == 0:
if len(secondRel) == 0:
return ('',common)
else:
return (self.get_parents(len(secondRel)),common)
if dist_other == 0:
return self.get_parents(dist_orig)
else:
return None
@@ -1374,59 +1481,59 @@ class RelationshipCalculator:
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
rel_str = self._get_son(Gb, step)+inlaw
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_daughter(Gb, step)+inlaw
rel_str = self._get_daughter(Gb, step)+inlaw
else:
rel_str = self.get_child_unknown(Gb, step)+inlaw
rel_str = self._get_child_unknown(Gb, step)+inlaw
elif gender_b == gen.lib.Person.MALE:
rel_str = self.get_son(Gb, step)
rel_str = self._get_son(Gb, step)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_daughter(Gb, step)
rel_str = self._get_daughter(Gb, step)
else:
rel_str = self.get_child_unknown(Gb, step)
rel_str = self._get_child_unknown(Gb, step)
elif Gb == 0:
# b is parents/grand parent of a
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_father(Ga, step, inlaw)
rel_str = self._get_father(Ga, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_mother(Ga, step, inlaw)
rel_str = self._get_mother(Ga, step, inlaw)
else:
rel_str = self.get_parent_unknown(Ga, step, inlaw)
rel_str = self._get_parent_unknown(Ga, step, inlaw)
elif Gb == 1:
# b is sibling/aunt/uncle of a
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_uncle(Ga, step, inlaw)
rel_str = self._get_uncle(Ga, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_aunt(Ga, step, inlaw)
rel_str = self._get_aunt(Ga, step, inlaw)
else:
rel_str = self.get_sibling(Ga, step, inlaw)
rel_str = self._get_sibling(Ga, step, inlaw)
elif Ga == 1:
# b is niece/nephew of a
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_nephew(Gb-1, step, inlaw)
rel_str = self._get_nephew(Gb-1, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_niece(Gb-1, step, inlaw)
rel_str = self._get_niece(Gb-1, step, inlaw)
elif Gb < len(_niece_level) and Gb < len(_nephew_level):
rel_str = "%s or %s" % (self.get_nephew(Gb-1, step, inlaw),
self.get_niece(Gb-1, step, inlaw))
rel_str = "%s or %s" % (self._get_nephew(Gb-1, step, inlaw),
self._get_niece(Gb-1, step, inlaw))
else:
rel_str = "distant %snephews/nieces%s" % (step, inlaw)
elif Ga == Gb:
# a and b cousins in the same generation
rel_str = self.get_cousin(Ga-1, 0, dir = '', step=step,
rel_str = self._get_cousin(Ga-1, 0, dir = '', step=step,
inlaw=inlaw)
elif Ga > Gb:
# These are cousins in different generations with the second person
# being in a higher generation from the common ancestor than the
# first person.
rel_str = self.get_cousin(Gb-1, Ga-Gb, dir = ' (up)',
rel_str = self._get_cousin(Gb-1, Ga-Gb, dir = ' (up)',
step=step, inlaw=inlaw)
elif Gb > Ga:
# These are cousins in different generations with the second person
# being in a lower generation from the common ancestor than the
# first person.
rel_str = self.get_cousin(Ga-1, Gb-Ga, dir = ' (down)',
rel_str = self._get_cousin(Ga-1, Gb-Ga, dir = ' (down)',
step=step, inlaw=inlaw)
return rel_str
@@ -1454,11 +1561,11 @@ class RelationshipCalculator:
inlaw = ''
if gender_b == gen.lib.Person.MALE:
rel_str = self.get_uncle(1, typestr, inlaw)
rel_str = self._get_uncle(1, typestr, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self.get_aunt(1, typestr, inlaw)
rel_str = self._get_aunt(1, typestr, inlaw)
else:
rel_str = self.get_sibling(1, typestr, inlaw)
rel_str = self._get_sibling(1, typestr, inlaw)
return rel_str
def get_partner_relationship_string(self, spouse_type, gender_a, gender_b):
@@ -1830,7 +1937,7 @@ def _test(rc, onlybirth, inlawa, inlawb, printrelstr):
rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
rc.get_single_relationship_string(j, i,
gen.lib.Person.MALE,
gen.lib.Person.FEMALE,
gen.lib.Person.MALE,
relstra, relstrb,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb), j, i )
@@ -1862,7 +1969,7 @@ def _test(rc, onlybirth, inlawa, inlawb, printrelstr):
rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
rc.get_single_relationship_string(i, j,
gen.lib.Person.MALE,
gen.lib.Person.FEMALE,
gen.lib.Person.MALE,
relstra, relstrb,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb), i, j)

View File

@@ -253,8 +253,9 @@ class ComprehensiveAncestorsReport (Report):
if self.gp:
break
relstring = self.relationship.get_grandparents_string (self.start_person,
self.database.get_person_from_handle(self.gp))[0]
relstring = self.relationship.get_grandparents_string(
self.start_person,
self.database.get_person_from_handle(self.gp))
heading = _("%(name)s's maternal %(grandparents)s") % \
{ 'name': self.first_name_or_nick (self.start_person),
'grandparents': relstring }
@@ -278,8 +279,9 @@ class ComprehensiveAncestorsReport (Report):
if paternal_known:
self.doc.start_paragraph ("AR-Heading")
relstring = self.relationship.get_grandparents_string (self.start_person,
self.database.get_person_from_handle(self.gp))[0]
relstring = self.relationship.get_grandparents_string(
self.start_person,
self.database.get_person_from_handle(self.gp))
if thisgen == 2:
heading = _("%(name)s's %(parents)s") % \
{ 'name': self.first_name_or_nick (self.start_person),

View File

@@ -60,6 +60,7 @@ class AllRelReport():
self.sdb = SimpleAccess(database)
self.sdoc = SimpleDoc(document)
self.rel_class = relationship_class()
self.msg_list = []
def run(self):
#get home_person
@@ -79,13 +80,13 @@ class AllRelReport():
return
#check if not a family too:
is_spouse = self.rel_class.is_spouse(self.database, self.person,
self.home_person)
is_spouse = self.rel_class.is_spouse(self.database, self.home_person,
self.person)
if is_spouse:
rel_string = is_spouse
rstr = _("%(person)s is the %(relationship)s of %(active_person)s."
) % {'person' : p2, 'relationship' : rel_string,
'active_person' : p1 }
) % {'person' : p1, 'relationship' : rel_string,
'active_person' : p2 }
self.sdoc.paragraph(_FMT_VOID % (rstr))
self.sdoc.paragraph("")
@@ -107,13 +108,15 @@ class AllRelReport():
#collapse common so parents of same fam in common are one line
commonnew = self.rel_class.collapse_relations(common)
self.print_details(commonnew, self.home_person, self.person,
first=True)
self.print_details(commonnew, self.home_person, self.person,
first=False)
self.print_details_header(commonnew, self.home_person, self.person,
skip_list_text=None)
self.print_details_path(commonnew, self.home_person, self.person)
self.print_details_path(commonnew, self.home_person, self.person,
first=False)
if not common or common[0][0]== -1 :
self.remarks(self.msg_list)
self.msg_list = []
#check inlaw relation next
else:
#stop
@@ -128,19 +131,23 @@ class AllRelReport():
#remove overlap:
inlaws_home = [x for x in inlaws_home if x not in inlaws_pers]
inlawwritten = False
skiplist = []
commonnew = []
for inlawpers in inlaws_pers:
for inlawhome in inlaws_home:
if (inlawpers, inlawhome) in handles_done :
continue
else:
handles_done.append((inlawpers, inlawhome))
common, self.msg_list = \
common, msg = \
self.rel_class.get_relationship_distance_new(
self.database, inlawpers, inlawhome,
all_families=True,
all_dist=True,
only_birth=False,
max_depth=20)
if msg:
self.msg_list.append(msg)
if common and not common[0][0] == -1:
if not inlawwritten:
rstr = _("%(person)s and %(active_person)s have "
@@ -152,13 +159,29 @@ class AllRelReport():
inlawwritten = True
else:
continue
commonnew = self.rel_class.collapse_relations(common)
inlawb = not inlawpers.handle == self.person.handle
inlawa = not inlawhome.handle == self.home_person.handle
self.print_details(commonnew, inlawhome, inlawpers,
first=True, inlawa = inlawa, inlawb = inlawb)
self.print_details(commonnew, inlawhome, inlawpers,
first=False, inlawa = inlawa, inlawb = inlawb)
commonnew.append((inlawa, inlawb, inlawhome, inlawpers,
self.rel_class.collapse_relations(common)))
skip=[]
skip_text = []
count = 1
for inlawa, inlawb, inlawhome, inlawpers, commonrel in commonnew:
count = self.print_details_header(commonrel,
inlawhome, inlawpers,
inlawa = inlawa, inlawb = inlawb,
count=count,
skip_list=skip, skip_list_text = skip_text)
count = 1
for inlawa, inlawb, inlawhome, inlawpers, commonrel in commonnew:
self.print_details_path(commonrel, inlawhome, inlawpers,
inlawa = inlawa, inlawb = inlawb,
count = count, skip_list = skip)
count = self.print_details_path(commonrel, inlawhome, inlawpers,
inlawa = inlawa, inlawb = inlawb,
count = count, skip_list = skip,
first = False)
self.remarks(self.msg_list)
def get_inlaws(self, person):
inlaws = []
@@ -184,10 +207,50 @@ class AllRelReport():
self.sdoc.title(_("Relationships of %s to %s") % (p1 ,p2))
self.sdoc.paragraph("")
def print_details(self, relations, pers1, pers2,
inlawa=False, inlawb=False, first=True):
def print_details_header(self, relations, pers1, pers2,
inlawa=False, inlawb=False, count=1,
skip_list=[], skip_list_text = []):
if not relations or relations[0][0] == -1:
return
return count
sdoc = self.sdoc
rel_class = self.rel_class
for relation in relations:
birth = self.rel_class.only_birth(relation[2])\
and self.rel_class.only_birth(relation[4])
distorig = len(relation[4])
distother = len(relation[2])
if distorig == 1 and distother == 1 and not inlawa \
and not inlawb:
rel_str = self.rel_class.get_sibling_relationship_string(
self.rel_class.get_sibling_type(
self.database, pers1, pers2),
self.home_person.get_gender(),
self.person.get_gender())
else:
rel_str = self.rel_class.get_single_relationship_string(
distorig, distother,
self.home_person.get_gender(),
self.person.get_gender(),
relation[4], relation[2],
only_birth = birth,
in_law_a = inlawa, in_law_b = inlawb)
if not skip_list_text is None:
if rel_str in skip_list_text:
skip_list.append(count)
else:
skip_list_text.append(rel_str)
sdoc.paragraph(_FMT % (count-len(skip_list), rel_str))
else :
sdoc.paragraph(_FMT % (count, rel_str))
count += 1
return count
def print_details_path(self, relations, pers1, pers2,
inlawa=False, inlawb=False,
count = 1, skip_list = [], first=True):
if not relations or relations[0][0] == -1:
return count
sdoc = self.sdoc
rel_class = self.rel_class
@@ -198,40 +261,18 @@ class AllRelReport():
if first:
pers = p1
inlaw = inlawb
count = 1
for relation in relations:
birth = self.rel_class.only_birth(relation[2])\
and self.rel_class.only_birth(relation[4])
distorig = len(relation[4])
distother = len(relation[2])
if distorig == 1 and distother == 1 and not inlawa \
and not inlawb:
rel_str = self.rel_class.get_sibling_relationship_string(
self.rel_class.get_sibling_type(
self.database, pers1, pers2),
self.home_person.get_gender(),
self.person.get_gender())
else:
rel_str = self.rel_class.get_single_relationship_string(
distorig, distother,
self.home_person.get_gender(),
self.person.get_gender(),
relation[4], relation[2],
only_birth = birth,
in_law_a = inlawa, in_law_b = inlawb)
sdoc.paragraph(_FMT % (count, rel_str))
count += 1
self.remarks(self.msg_list)
sdoc.paragraph("")
sdoc.header1(_("Detailed path from %(person)s to common ancestor"
) % {'person':pers})
sdoc.paragraph("")
sdoc.header2(_FMT_DET1 % (_(' '), _('Name Common ancestor')))
sdoc.header2(_FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
sdoc.paragraph("")
count = 1
for relation in relations:
if count == 1:
sdoc.paragraph("")
sdoc.header1(_("Detailed path from %(person)s to common ancestor"
) % {'person':pers})
sdoc.paragraph("")
sdoc.header2(_FMT_DET1 % (_(' '), _('Name Common ancestor')))
sdoc.header2(_FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
sdoc.paragraph("")
for relation in relations:
if count in skip_list:
continue
counter = str(count)
name = _('Unknown')
if relation[1]:
@@ -281,7 +322,8 @@ class AllRelReport():
counter=''
name = ''
count += 1
return count
def remarks(self, msg_list):
if msg_list :
sdoc = self.sdoc

View File

@@ -211,8 +211,8 @@ register_relcalc(RelationshipCalculator,
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/gen/lib/date.py
# (Above not needed here)
# export PYTHONPATH=/path/to/gramps/src
# python src/plugins/rel_it.py
"""TRANSLATORS, copy this if statement at the bottom of your
rel_xx.py module, and test your work with:

View File

@@ -103,109 +103,153 @@ _parents_level = [ "",
"edelstamoudouders" ]
_father_level = [ "",
"vader",
"grootvader",
"overgrootvader",
"betovergrootvader",
"oudvader (generatie 5)",
"oudgrootvader (generatie 6)",
"oudovergrootvader (generatie 7)",
"oudbetovergrootvader (generatie 8)",
"stamvader (generatie 9)",
"stamgrootvader (generatie 10)",
"stamovergrootvader (generatie 11)",
"stambetovergrootvader (generatie 12)",
"stamoudvader (generatie 13)",
"stamoudgrootvader (generatie 14)",
"stamoudovergrootvader (generatie 15)",
"stamoudbetovergrootvader (generatie 16)",
"edelvader (generatie 17)",
"edelgrootvader (generatie 18)",
"edelovergrootoudvader (generatie 19)",
"edelbetovergrootvader (generatie 20)",
"edeloudvader (generatie 21)",
"edeloudgrootvader (generatie 22)",
"edeloudvergrootvader (generatie 23)",
"edeloudbetovergrootvader (generatie 24)",
"edelstamvader (generatie 25)",
"edelstamgrootvader (generatie 26)",
"edelstamovergrootvader (generatie 27)",
"edelstambetovergrootvader (generatie 28)",
"edelstamoudvader (generatie 29)" ]
"%s%svader",
"%s%sgrootvader",
"%s%sovergrootvader",
"%s%sbetovergrootvader",
"%s%soudvader (generatie 5)",
"%s%soudgrootvader (generatie 6)",
"%s%soudovergrootvader (generatie 7)",
"%s%soudbetovergrootvader (generatie 8)",
"%s%sstamvader (generatie 9)",
"%s%sstamgrootvader (generatie 10)",
"%s%sstamovergrootvader (generatie 11)",
"%s%sstambetovergrootvader (generatie 12)",
"%s%sstamoudvader (generatie 13)",
"%s%sstamoudgrootvader (generatie 14)",
"%s%sstamoudovergrootvader (generatie 15)",
"%s%sstamoudbetovergrootvader (generatie 16)",
"%s%sedelvader (generatie 17)",
"%s%sedelgrootvader (generatie 18)",
"%s%sedelovergrootoudvader (generatie 19)",
"%s%sedelbetovergrootvader (generatie 20)",
"%s%sedeloudvader (generatie 21)",
"%s%sedeloudgrootvader (generatie 22)",
"%s%sedeloudvergrootvader (generatie 23)",
"%s%sedeloudbetovergrootvader (generatie 24)",
"%s%sedelstamvader (generatie 25)",
"%s%sedelstamgrootvader (generatie 26)",
"%s%sedelstamovergrootvader (generatie 27)",
"%s%sedelstambetovergrootvader (generatie 28)",
"%s%sedelstamoudvader (generatie 29)" ]
_mother_level = [ "",
"moeder ",
"grootmoeder",
"overgrootmoeder",
"betovergrootmoeder",
"oudmoeder (generatie 5)",
"oudgrootmoeder (generatie 6)",
"oudovergrootmoeder (generatie 7)",
"oudbetovergrootmoeder (generatie 8)",
"stammoeder (generatie 9)",
"stamgrootmoeder (generatie 10)",
"stamovergrootmoeder (generatie 11)",
"stambetovergrootmoeder (generatie 12)",
"stamoudmoeder (generatie 13)",
"stamoudgrootmoeder (generatie 14)",
"stamoudovergrootmoeder (generatie 15)",
"stamoudbetovergrootmoeder (generatie 16)",
"edelmoeder (generatie 17)",
"edelgrootmoeder (generatie 18)",
"edelovergrootoudmoeder (generatie 19)",
"edelbetovergrootmoeder (generatie 20)",
"edeloudmoeder (generatie 21)",
"edeloudgrootmoeder (generatie 22)",
"edeloudvergrootmoeder (generatie 23)",
"edeloudbetovergrootmoeder (generatie 24)",
"edelstammoeder (generatie 25)",
"edelstamgrootmoeder (generatie 26)",
"edelstamovergrootmoeder (generatie 27)",
"edelstambetovergrootmoeder (generatie 28)",
"edelstamoudmoeder (generatie 29)" ]
"%s%smoeder",
"%s%sgrootmoeder",
"%s%sovergrootmoeder",
"%s%sbetovergrootmoeder",
"%s%soudmoeder (generatie 5)",
"%s%soudgrootmoeder (generatie 6)",
"%s%soudovergrootmoeder (generatie 7)",
"%s%soudbetovergrootmoeder (generatie 8)",
"%s%sstammoeder (generatie 9)",
"%s%sstamgrootmoeder (generatie 10)",
"%s%sstamovergrootmoeder (generatie 11)",
"%s%sstambetovergrootmoeder (generatie 12)",
"%s%sstamoudmoeder (generatie 13)",
"%s%sstamoudgrootmoeder (generatie 14)",
"%s%sstamoudovergrootmoeder (generatie 15)",
"%s%sstamoudbetovergrootmoeder (generatie 16)",
"%s%sedelmoeder (generatie 17)",
"%s%sedelgrootmoeder (generatie 18)",
"%s%sedelovergrootoudmoeder (generatie 19)",
"%s%sedelbetovergrootmoeder (generatie 20)",
"%s%sedeloudmoeder (generatie 21)",
"%s%sedeloudgrootmoeder (generatie 22)",
"%s%sedeloudvergrootmoeder (generatie 23)",
"%s%sedeloudbetovergrootmoeder (generatie 24)",
"%s%sedelstammoeder (generatie 25)",
"%s%sedelstamgrootmoeder (generatie 26)",
"%s%sedelstamovergrootmoeder (generatie 27)",
"%s%sedelstambetovergrootmoeder (generatie 28)",
"%s%sedelstamoudmoeder (generatie 29)" ]
_ouder_level = [ "",
"%s%souder ",
"%s%sgrootouder",
"%s%sovergrootouder",
"%s%sbetovergrootouder",
"%s%soudouder (generatie 5)",
"%s%soudgrootouder (generatie 6)",
"%s%soudovergrootouder (generatie 7)",
"%s%soudbetovergrootouder (generatie 8)",
"%s%sstamouder (generatie 9)",
"%s%sstamgrootouder (generatie 10)",
"%s%sstamovergrootouder (generatie 11)",
"%s%sstambetovergrootouder (generatie 12)",
"%s%sstamoudouder (generatie 13)",
"%s%sstamoudgrootouder (generatie 14)",
"%s%sstamoudovergrootouder (generatie 15)",
"%s%sstamoudbetovergrootouder (generatie 16)",
"%s%sedelouder (generatie 17)",
"%s%sedelgrootouder (generatie 18)",
"%s%sedelovergrootoudouder (generatie 19)",
"%s%sedelbetovergrootouder (generatie 20)",
"%s%sedeloudouder (generatie 21)",
"%s%sedeloudgrootouder (generatie 22)",
"%s%sedeloudvergrootouder (generatie 23)",
"%s%sedeloudbetovergrootouder (generatie 24)",
"%s%sedelstamouder (generatie 25)",
"%s%sedelstamgrootouder (generatie 26)",
"%s%sedelstamovergrootouder (generatie 27)",
"%s%sedelstambetovergrootouder (generatie 28)",
"%s%sedelstamoudouder (generatie 29)" ]
_son_level = [ "",
"zoon",
"kleinzoon",
"achterkleinzoon",
"achterachterkleinzoon",
"achterachterachterkleinzoon"]
"%szoon",
"%skleinzoon",
"%sachterkleinzoon",
"%sachterachterkleinzoon",
"%sachterachterachterkleinzoon"]
_daughter_level = [ "",
"dochter",
"kleindochter",
"achterkleindochter",
"achterachterkleindochter",
"achterachterachterkleindochter"]
"%sdochter",
"%skleindochter",
"%sachterkleindochter",
"%sachterachterkleindochter",
"%sachterachterachterkleindochter"]
_kind_level = [ "",
"%skind",
"%skleinkind",
"%sachterkleinkind",
"%sachterachterkleinkind",
"%sachterachterachterkleinkind"]
_nephew_level = [ "",
"neef",
"achterneef",
"achterachterneef" ]
"%s%sneef",
"%s%sachterneef",
"%s%sachterachterneef" ]
_niece_level = [ "",
"nicht",
"achternicht",
"achterachternicht"]
"%s%snicht",
"%s%sachternicht",
"%s%sachterachternicht"]
_aunt_level = [ "",
"tante",
"groottante",
"overgroottante",
"betovergroottante",
"oudtante (generatie 5)"]
"%s%stante",
"%s%sgroottante",
"%s%sovergroottante",
"%s%sbetovergroottante",
"%s%soudtante"]
_uncle_level = [ "",
"oom",
"grootoom",
"overgrootoom",
"betovergrootoom",
"oudoom (generatie 5)"]
"%s%soom",
"%s%sgrootoom",
"%s%sovergrootoom",
"%s%sbetovergrootoom",
"%s%soudoom"]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
class RelationshipCalculator(Relationship.RelationshipCalculator):
#sibling strings
STEP= 'stief'
HALF = 'half'
INLAW='aangetrouwde '
def __init__(self):
Relationship.RelationshipCalculator.__init__(self)
@@ -214,168 +258,283 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
if level > len(_parents_level)-1:
return "verre voorouders (%d generaties)" % level
else:
return _parents_level[level]
def get_father(self, level):
return _parents_level[level]
def _get_father(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_father_level)-1:
return "verre voorvader (%d generaties)" % level
return "verre %s%svoorvader (%d generaties)" % (inlaw, step, level)
else:
return _father_level[level]
return _father_level[level] % (inlaw, step)
def get_son(self, level):
def _get_son(self, level, step=''):
"""Internal Dutch method to create relation string
"""
if level < len(_son_level):
return _son_level[level]
return _son_level[level] % step
else:
return "verre achterkleinzoon (%d generaties)" % level
return "verre %sachterkleinzoon (%d generaties)" % (step, level)
def get_mother(self,level):
def _get_mother(self,level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_mother_level)-1:
return "verre voormoeder (%d generaties)" % level
return "verre voormoeder (%d generaties)" % (inlaw, step, level)
else:
return _mother_level[level]
return _mother_level[level] % (inlaw, step)
def get_daughter(self, level):
def _get_daughter(self, level, step=''):
"""Internal Dutch method to create relation string
"""
if level > len(_daughter_level)-1:
return "verre achterkleindochter (%d generaties)" % level
return "verre %sachterkleindochter (%d generaties)" % (step, level)
else:
return _daughter_level[level]
return _daughter_level[level] % step
def get_aunt(self, level, removed):
def _get_parent_unknown(self, level, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if level > len(_ouder_level)-1:
return "verre voorouder (%d generaties)" % (inlaw, step, level)
elif level == 1:
return _mother_level[level] % (inlaw, step) + ' of ' + \
_father_level[level] % (inlaw, step)
else:
return _ouder_level[level] % (inlaw, step)
def _get_child_unknown(self, level, step=''):
"""Internal Dutch method to create relation string
"""
if level > len(_kind_level)-1:
return "ver %sachterkleinkind (%d generaties)" % (step, level)
else:
return _kind_level[level] % step
def _get_aunt(self, level, removed, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_aunt_level):
return _aunt_level[level]
elif level > len(_aunt_level)-1 or removed > len(_removed_level) -1:
return "verre tante (%d generaties, %d graden)" % (level, removed)
return _aunt_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%stante (%d generaties)" % (inlaw, step, level)
elif level > len(_aunt_level)-1 and removed > len(_removed_level) -1:
return "verre %s%stante (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_aunt_level)-1:
return "verre tante van de%s graad (%d generaties)" \
% (_removed_level[removed], level)
return "verre %s%stante van de%s graad (%d generaties)" % (inlaw,
step, _removed_level[removed], level)
else:
return _aunt_level[level] + _removed_level[removed] + " graad"
return _aunt_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def get_uncle(self, level, removed):
def _get_uncle(self, level, removed, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_uncle_level):
return _uncle_level[level]
elif level > len(_uncle_level)-1 or removed > len(_removed_level) -1:
return "verre oom (%d generaties, %d graden)" % (level, removed)
return _uncle_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%soom (%d generaties)" % (inlaw, step, level)
elif level > len(_uncle_level)-1 and removed > len(_removed_level) -1:
return "verre %s%soom (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_uncle_level)-1:
return "verre oom van de%s graad (%d generaties)" \
% (_removed_level[removed], level)
return "verre %s%soom van de%s graad (%d generaties)" % (inlaw,
step, _removed_level[removed], level)
else:
return _uncle_level[level] + _removed_level[removed] + " graad"
return _uncle_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def get_nephew(self, level, removed=1):
def _get_sibling(self, level, step='', inlaw=''):
"""overwrite of English method to return unknown gender sibling
"""
assert(level == 1)
return self._get_male_cousin(0, step=step, inlaw=inlaw) + ' of ' \
+ self._get_female_cousin(0, step=step, inlaw=inlaw)
def _get_nephew(self, level, removed=1, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_nephew_level):
return _nephew_level[level]
elif level > len(_nephew_level)-1 or removed > len(_removed_level) -1:
return "verre neef (%d generaties, %d graden)" % (level, removed)
return _nephew_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%sneef (%d generaties)" % (inlaw, step, level)
elif level > len(_nephew_level)-1 and removed > len(_removed_level) -1:
return "verre %s%sneef (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_nephew_level)-1:
return "verre neef van de%s graad (%d generaties)" \
% (_removed_level[removed], level)
return "verre %s%sneef van de%s graad (%d generaties)" % (inlaw, step,
_removed_level[removed], level)
else:
return _nephew_level[level] + _removed_level[removed] + " graad"
return _nephew_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def get_niece(self, level, removed=1):
def _get_niece(self, level, removed=1, step='', inlaw=''):
"""Internal Dutch method to create relation string
"""
if removed == 1 and level < len(_niece_level):
return _niece_level[level]
if level > len(_niece_level)-1 or removed > len(_removed_level) -1:
return "verre nicht (%d generaties, %d graden)" % (level, removed)
return _niece_level[level] % (inlaw, step)
elif removed == 1:
return "verre %s%snicht (%d generaties)" % (inlaw, step, level)
elif level > len(_niece_level)-1 and removed > len(_removed_level) -1:
return "verre %s%snicht (%d generaties, %d graden)" % (inlaw, step,
level, removed)
elif level > len(_niece_level)-1:
return "verre nicht van de%s graad (%d generaties)" \
% (_removed_level[removed], level)
return "verre %s%snicht van de%s graad (%d generaties)"% (inlaw,
step, _removed_level[removed], level)
else:
return _niece_level[level] + _removed_level[removed] + " graad"
return _niece_level[level] % (inlaw, step) \
+ _removed_level[removed] + " graad"
def get_male_cousin(self,removed):
def _get_male_cousin(self, removed, step='', inlaw=''):
"""Specific Dutch thing, the nieces/nephews on same level are called
going sideways in a branch as the nieces/newphews going downward
from your brother/sisters. This used to be called "kozijn"
"""
removed = removed - 1
if removed > len(_removed_level)-1:
return "verre neef (kozijn, %d graden)" % removed
return "verre %s%sneef (kozijn, %d graden)" % (inlaw, step,
removed)
elif removed == 0:
return "broer"
return "%s%sbroer" % (inlaw, step)
else:
return "neef (kozijn)"+_removed_level[removed] + " graad"
return "%s%sneef (kozijn)" % (inlaw, step) \
+_removed_level[removed] + " graad"
def get_female_cousin(self,removed):
def _get_female_cousin(self, removed, step='', inlaw=''):
"""Specific Dutch thing, the nieces/nephews on same level are called
going sideways in a branch as the nieces/newphews going downward
from your brother/sisters. This used to be called "kozijn"
"""
removed = removed - 1
if removed > len(_removed_level)-1:
return "verre nicht (kozijn, %d graden)" % removed
return "verre %s%snicht (kozijn, %d graden)" % (inlaw, step,
removed)
elif removed == 0:
return "zus"
return "%s%szus" % (inlaw, step)
else:
return "nicht (kozijn)"+ _removed_level[removed] + " graad"
return "%s%snicht (kozijn)" % (inlaw, step) \
+ _removed_level[removed] + " graad"
def get_relationship(self, db, orig_person, other_person):
def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b,
reltocommon_a, reltocommon_b,
only_birth=True,
in_law_a=False, in_law_b=False):
"""
Returns a string representing the relationshp between the two people,
along with a list of common ancestors (typically father,mother)
Special cases: relation strings "", "undefined" and "spouse".
Returns a string representing the relationship between the two people,
see english method, eg b is father of a
"""
if orig_person == None:
return ("niet bepaald",[])
if orig_person.get_handle() == other_person.get_handle():
return ('', [])
is_spouse = self.is_spouse(db, orig_person, other_person)
if is_spouse:
return (is_spouse,[])
#get_relationship_distance changed, first data is relation to
#orig person, apperently secondRel in this function
(secondRel,firstRel,common) = self.get_relationship_distance(db,
orig_person,other_person)
if (type(common) == types.StringType or
type(common) == types.UnicodeType):
return (common,[])
elif common:
person_handle = common[0]
if only_birth:
step = ''
else:
return ("",[])
step = self.STEP
firstRel = len(firstRel)
secondRel = len(secondRel)
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
if firstRel == 0:
#other person is ancestor
if secondRel == 0:
return ('',common)
elif other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_father(secondRel), common)
rel_str = "verre %s%sfamilie" % (inlaw, step)
if Gb == 0:
#b is ancestor
if Ga == 0:
rel_str = 'zelfde persoon'
elif Ga == 1 and inlaw and not step:
if gender_b == gen.lib.Person.MALE:
rel_str = 'schoonvader'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'schoonmoeder'
else:
rel_str = 'schoonouder'
elif gender_b == gen.lib.Person.MALE:
rel_str = self._get_father(Ga, step, inlaw)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_mother(Ga, step, inlaw)
else:
return (self.get_mother(secondRel), common)
elif secondRel == 0:
#other person is descendant
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_son(firstRel), common)
rel_str = self._get_parent_unknown(Ga, step, inlaw)
elif Ga == 0:
#a is descendant
if Gb == 1 and inlaw and not step:
#inlaw children only exist up to first level:
if gender_b == gen.lib.Person.MALE:
rel_str = 'schoonzoon'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'schoondochter'
else:
rel_str = 'schoonzoon of -dochter'
elif Gb == 1 and inlaw and step:
#inlaw stepchild
if gender_b == gen.lib.Person.MALE:
rel_str = 'aangetrouwde stiefzoon'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'aangetrouwde stiefdochter'
else:
rel_str = 'aangetrouwde stiefzoon of dochter'
elif gender_b == gen.lib.Person.MALE:
rel_str = self._get_son(Gb, step)
elif gender_b == gen.lib.Person.FEMALE:
rel_str = self._get_daughter(Gb, step)
else:
return (self.get_daughter(firstRel), common)
elif secondRel > firstRel:
#other person is higher in the branch, in english uncle/aunt or
rel_str = self._get_child_unknown(Gb, step)
elif Ga > Gb:
#b is higher in the branch, in english uncle/aunt or
#cousin up, in dutch always 'oom/tante'
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_uncle(secondRel - firstRel,firstRel), common)
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_uncle(Ga - Gb, Gb, step, inlaw)
else:
return (self.get_aunt(secondRel - firstRel, firstRel), common)
elif secondRel < firstRel:
#other person is lower in the branch, in english niece/nephew or
rel_str = self._get_aunt(Ga - Gb, Gb, step, inlaw)
elif Ga < Gb:
#b is lower in the branch, in english niece/nephew or
#cousin down, in dutch always 'neef/nicht'
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_nephew(firstRel - secondRel, secondRel), common)
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_nephew(Gb - Ga, Ga, step, inlaw)
else:
return (self.get_niece(firstRel - secondRel, secondRel), common)
rel_str = self._get_niece(Gb - Ga, Ga, step, inlaw)
else:
# people on the same level secondRel == firstRel
if other_person.get_gender() == gen.lib.Person.MALE:
return (self.get_male_cousin(firstRel), common)
# people on the same level Ga == Gb
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_male_cousin(Ga, step, inlaw)
else:
return (self.get_female_cousin(firstRel), common)
rel_str = self._get_female_cousin(Ga, step, inlaw)
return rel_str
def get_sibling_relationship_string(self, sib_type, gender_a, gender_b,
in_law_a=False, in_law_b=False):
""" Determine the string giving the relation between two siblings of
type sib_type.
Eg: b is the brother of a
Here 'brother' is the string we need to determine
This method gives more details about siblings than
get_single_relationship_string can do.
DIFFERENT HELPER FUNCTIONS THAN ENGLISH
"""
if sib_type == self.NORM_SIB or sib_type == self.UNKNOWN_SIB:
typestr = ''
elif sib_type == self.HALF_SIB:
typestr = self.HALF
elif sib_type == self.STEP_SIB:
typestr = self.STEP
if in_law_a or in_law_b :
inlaw = self.INLAW
else:
inlaw = ''
if inlaw and not typestr:
if gender_b == gen.lib.Person.MALE:
rel_str = 'schoonbroer'
elif gender_b == gen.lib.Person.FEMALE:
rel_str = 'schoonzus'
else:
rel_str = 'schoonzus/broer'
else:
if gender_b == gen.lib.Person.MALE:
rel_str = self._get_male_cousin(1, typestr, inlaw)
else:
rel_str = self._get_female_cousin(1, typestr, inlaw)
return rel_str
#-------------------------------------------------------------------------
#
@@ -387,3 +546,17 @@ register_relcalc(RelationshipCalculator,
"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"])
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_nl.py
"""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
"""
from Relationship import test
rc = RelationshipCalculator()
test(rc, True)

View File

@@ -469,8 +469,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
rank = 9999999
try:
self.__apply_filter(db,orig_person,'',firstList,firstMap)
self.__apply_filter(db,other_person,'',secondList,secondMap)
self.__apply_filter_old(db,orig_person,'',firstList,firstMap)
self.__apply_filter_old(db,other_person,'',secondList,secondMap)
except RuntimeError:
return (firstRel,secondRel,_("Relationship loop detected"))