2007-10-27 Benny Malengier <benny.malengier@gramps-project.org>
* src/Relationship.py: begin of extension to step and in-law NOT finished. svn: r9255
This commit is contained in:
parent
7f571e2add
commit
7dbfbc803a
@ -1,3 +1,7 @@
|
|||||||
|
2007-10-27 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
|
* src/Relationship.py: begin of extension to step and in-law
|
||||||
|
NOT finished.
|
||||||
|
|
||||||
2007-10-26 Benny Malengier <benny.malengier@gramps-project.org>
|
2007-10-26 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
* src/Relationship.py: change api get_singular, add docu string
|
* src/Relationship.py: change api get_singular, add docu string
|
||||||
* src/plugins/all_relations.py: call get_singular changed.
|
* src/plugins/all_relations.py: call get_singular changed.
|
||||||
|
@ -36,6 +36,9 @@ from TransUtils import sgettext as _
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
STEP= 'step'
|
||||||
|
INLAW='-in-law'
|
||||||
|
|
||||||
_level_name = [ "", "first", "second", "third", "fourth", "fifth", "sixth",
|
_level_name = [ "", "first", "second", "third", "fourth", "fifth", "sixth",
|
||||||
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth",
|
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth",
|
||||||
"thirteenth", "fourteenth", "fifteenth", "sixteenth",
|
"thirteenth", "fourteenth", "fifteenth", "sixteenth",
|
||||||
@ -45,7 +48,7 @@ _removed_level = [ "", " once removed", " twice removed",
|
|||||||
" three times removed",
|
" three times removed",
|
||||||
" four times removed", " five times removed",
|
" four times removed", " five times removed",
|
||||||
" six times removed",
|
" six times removed",
|
||||||
" sevent times removed", " eight times removed",
|
" seven times removed", " eight times removed",
|
||||||
" nine times removed",
|
" nine times removed",
|
||||||
" ten times removed", " eleven times removed",
|
" ten times removed", " eleven times removed",
|
||||||
" twelve times removed",
|
" twelve times removed",
|
||||||
@ -66,50 +69,52 @@ _parents_level = [ "", "parents", "grandparents", "great grandparents", "second
|
|||||||
"seventeenth great grandparents", "eighteenth great grandparents",
|
"seventeenth great grandparents", "eighteenth great grandparents",
|
||||||
"nineteenth great grandparents", "twentieth great grandparents", ]
|
"nineteenth great grandparents", "twentieth great grandparents", ]
|
||||||
|
|
||||||
_father_level = [ "", "father", "grandfather", "great grandfather", "second great grandfather",
|
_father_level = [ "", "%sfather%s", "%sgrandfather%s", "great %sgrandfather%s",
|
||||||
"third great grandfather", "fourth great grandfather",
|
"second great %sgrandfather%s",
|
||||||
"fifth great grandfather", "sixth great grandfather",
|
"third great %sgrandfather%s", "fourth great %sgrandfather%s",
|
||||||
"seventh great grandfather", "eighth great grandfather",
|
"fifth great %sgrandfather%s", "sixth great %sgrandfather%s",
|
||||||
"ninth great grandfather", "tenth great grandfather",
|
"seventh great %sgrandfather%s", "eighth great %sgrandfather%s",
|
||||||
"eleventh great grandfather", "twelfth great grandfather",
|
"ninth great %sgrandfather%s", "tenth great %sgrandfather%s",
|
||||||
"thirteenth great grandfather", "fourteenth great grandfather",
|
"eleventh great %sgrandfather%s", "twelfth great %sgrandfather%s",
|
||||||
"fifteenth great grandfather", "sixteenth great grandfather",
|
"thirteenth great %sgrandfather%s", "fourteenth great %sgrandfather%s",
|
||||||
"seventeenth great grandfather", "eighteenth great grandfather",
|
"fifteenth great %sgrandfather%s", "sixteenth great %sgrandfather%s",
|
||||||
"nineteenth great grandfather", "twentieth great grandfather", ]
|
"seventeenth great %sgrandfather%s", "eighteenth great %sgrandfather%s",
|
||||||
|
"nineteenth great %sgrandfather%s", "twentieth great %sgrandfather%s", ]
|
||||||
|
|
||||||
_mother_level = [ "", "mother", "grandmother", "great grandmother", "second great grandmother",
|
_mother_level = [ "", "%smother%s", "%sgrandmother%s", "great %sgrandmother%s",
|
||||||
"third great grandmother", "fourth great grandmother",
|
"second great %sgrandmother%s",
|
||||||
"fifth great grandmother", "sixth great grandmother",
|
"third great %sgrandmother%s", "fourth great %sgrandmother%s",
|
||||||
"seventh great grandmother", "eighth great grandmother",
|
"fifth great %sgrandmother%s", "sixth great %sgrandmother%s",
|
||||||
"ninth great grandmother", "tenth great grandmother",
|
"seventh great %sgrandmother%s", "eighth great %sgrandmother%s",
|
||||||
"eleventh great grandmother", "twelfth great grandmother",
|
"ninth great %sgrandmother%s", "tenth great %sgrandmother%s",
|
||||||
"thirteenth great grandmother", "fourteenth great grandmother",
|
"eleventh great %sgrandmother%s", "twelfth great %sgrandmother%s",
|
||||||
"fifteenth great grandmother", "sixteenth great grandmother",
|
"thirteenth great %sgrandmother%s", "fourteenth great %sgrandmother%s",
|
||||||
"seventeenth great grandmother", "eighteenth great grandmother",
|
"fifteenth great %sgrandmother%s", "sixteenth great %sgrandmother%s",
|
||||||
"nineteenth great grandmother", "twentieth great grandmother", ]
|
"seventeenth great %sgrandmother%s", "eighteenth great %sgrandmother%s",
|
||||||
|
"nineteenth great %sgrandmother%s", "twentieth great %sgrandmother%s", ]
|
||||||
|
|
||||||
_son_level = [ "", "son", "grandson", "great grandson", "second great grandson",
|
_son_level = [ "", "%sson", "%sgrandson", "great %sgrandson", "second great %sgrandson",
|
||||||
"third great grandson", "fourth great grandson",
|
"third great %sgrandson", "fourth great %sgrandson",
|
||||||
"fifth great grandson", "sixth great grandson",
|
"fifth great %sgrandson", "sixth great %sgrandson",
|
||||||
"seventh great grandson", "eighth great grandson",
|
"seventh great %sgrandson", "eighth great %sgrandson",
|
||||||
"ninth great grandson", "tenth great grandson",
|
"ninth great %sgrandson", "tenth great %sgrandson",
|
||||||
"eleventh great grandson", "twelfth great grandson",
|
"eleventh great %sgrandson", "twelfth great %sgrandson",
|
||||||
"thirteenth great grandson", "fourteenth great grandson",
|
"thirteenth great %sgrandson", "fourteenth great %sgrandson",
|
||||||
"fifteenth great grandson", "sixteenth great grandson",
|
"fifteenth great %sgrandson", "sixteenth great %sgrandson",
|
||||||
"seventeenth great grandson", "eighteenth great grandson",
|
"seventeenth great %sgrandson", "eighteenth great %sgrandson",
|
||||||
"nineteenth great grandson", "twentieth great grandson", ]
|
"nineteenth great %sgrandson", "twentieth great %sgrandson", ]
|
||||||
|
|
||||||
_daughter_level = [ "", "daughter", "granddaughter", "great granddaughter",
|
_daughter_level = [ "", "%sdaughter", "%sgranddaughter", "great %sgranddaughter",
|
||||||
"second great granddaughter",
|
"second great %sgranddaughter",
|
||||||
"third great granddaughter", "fourth great granddaughter",
|
"third great %sgranddaughter", "fourth great %sgranddaughter",
|
||||||
"fifth great granddaughter", "sixth great granddaughter",
|
"fifth great %sgranddaughter", "sixth great %sgranddaughter",
|
||||||
"seventh great granddaughter", "eighth great granddaughter",
|
"seventh great %sgranddaughter", "eighth great %sgranddaughter",
|
||||||
"ninth great granddaughter", "tenth great granddaughter",
|
"ninth great %sgranddaughter", "tenth great %sgranddaughter",
|
||||||
"eleventh great granddaughter", "twelfth great granddaughter",
|
"eleventh great %sgranddaughter", "twelfth great %sgranddaughter",
|
||||||
"thirteenth great granddaughter", "fourteenth great granddaughter",
|
"thirteenth great %sgranddaughter", "fourteenth great %sgranddaughter",
|
||||||
"fifteenth great granddaughter", "sixteenth great granddaughter",
|
"fifteenth great %sgranddaughter", "sixteenth great %sgranddaughter",
|
||||||
"seventeenth great granddaughter", "eighteenth great granddaughter",
|
"seventeenth great %sgranddaughter", "eighteenth great %sgranddaughter",
|
||||||
"nineteenth great granddaughter", "twentieth great granddaughter", ]
|
"nineteenth great %sgranddaughter", "twentieth great %sgranddaughter", ]
|
||||||
|
|
||||||
_sister_level = [ "", "sister", "aunt", "grandaunt", "great grandaunt", "second great grandaunt",
|
_sister_level = [ "", "sister", "aunt", "grandaunt", "great grandaunt", "second great grandaunt",
|
||||||
"third great grandaunt", "fourth great grandaunt",
|
"third great grandaunt", "fourth great grandaunt",
|
||||||
@ -257,43 +262,58 @@ class RelationshipCalculator:
|
|||||||
|
|
||||||
def get_parents(self, level):
|
def get_parents(self, level):
|
||||||
if level>len(_parents_level)-1:
|
if level>len(_parents_level)-1:
|
||||||
return "distant ancestors"
|
return "distant ancestors (%d generations)" % level
|
||||||
else:
|
else:
|
||||||
return _parents_level[level]
|
return _parents_level[level]
|
||||||
|
|
||||||
def get_father(self, level):
|
def get_father(self, level, step='', inlaw=''):
|
||||||
if level>len(_father_level)-1:
|
if level>len(_father_level)-1:
|
||||||
return "distant ancestor"
|
return "distant %sancestor%s (%d generations)" % (step, inlaw,
|
||||||
|
level)
|
||||||
else:
|
else:
|
||||||
return _father_level[level]
|
return _father_level[level] % (step, inlaw)
|
||||||
|
|
||||||
def get_son(self, level):
|
def get_son(self, level, step=''):
|
||||||
if level>len(_son_level)-1:
|
if level>len(_son_level)-1:
|
||||||
return "distant descendant"
|
return "distant %sdescendant (%d generations)" % (step, level)
|
||||||
else:
|
else:
|
||||||
return _son_level[level]
|
return _son_level[level] % step
|
||||||
|
|
||||||
def get_mother(self, level):
|
def get_mother(self, level, step='', inlaw=''):
|
||||||
if level>len(_mother_level)-1:
|
if level>len(_mother_level)-1:
|
||||||
return "distant ancestor"
|
return "distant %sancestor%s (%d generations)" % (step, inlaw,
|
||||||
|
level)
|
||||||
else:
|
else:
|
||||||
return _mother_level[level]
|
return _mother_level[level] % (step, inlaw)
|
||||||
|
|
||||||
def get_daughter(self, level):
|
def get_daughter(self, level, step=''):
|
||||||
if level>len(_daughter_level)-1:
|
if level>len(_daughter_level)-1:
|
||||||
return "distant descendant"
|
return "distant %sdescendant (%d generations)" % (step, level)
|
||||||
else:
|
else:
|
||||||
return _daughter_level[level]
|
return _daughter_level[level] % step
|
||||||
|
|
||||||
|
def get_parent_unknown(self, level, step='', inlaw=''):
|
||||||
|
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=''):
|
||||||
|
if level < len(_level_name):
|
||||||
|
return _level_name[level] + ' ' + '%sdescendant' % step
|
||||||
|
else:
|
||||||
|
return "distant %sdescendant (%d generations)" % (step, level)
|
||||||
|
|
||||||
def get_aunt(self, level):
|
def get_aunt(self, level):
|
||||||
if level>len(_sister_level)-1:
|
if level>len(_sister_level)-1:
|
||||||
return "distant ancestor"
|
return "distant aunt"
|
||||||
else:
|
else:
|
||||||
return _sister_level[level]
|
return _sister_level[level]
|
||||||
|
|
||||||
def get_uncle(self, level):
|
def get_uncle(self, level):
|
||||||
if level>len(_brother_level)-1:
|
if level>len(_brother_level)-1:
|
||||||
return "distant ancestor"
|
return "distant uncle"
|
||||||
else:
|
else:
|
||||||
return _brother_level[level]
|
return _brother_level[level]
|
||||||
|
|
||||||
@ -823,38 +843,6 @@ class RelationshipCalculator:
|
|||||||
'other_relation': rel_str} , common )
|
'other_relation': rel_str} , common )
|
||||||
else:
|
else:
|
||||||
return (rel_str, common)
|
return (rel_str, common)
|
||||||
## #original programmer did a sick joke here, switching first with other!
|
|
||||||
## firstRel = dist_other
|
|
||||||
## secondRel = dist_orig
|
|
||||||
##
|
|
||||||
## if firstRel == 0: #other is common ancestor, so a father/mother
|
|
||||||
## if secondRel == 0:
|
|
||||||
## return ('',common)
|
|
||||||
## elif other_person.get_gender() == gen.lib.Person.MALE:
|
|
||||||
## return (self.get_father(secondRel),common)
|
|
||||||
## else:
|
|
||||||
## return (self.get_mother(secondRel),common)
|
|
||||||
## elif secondRel == 0: #orig is common ancestor, so other is son/daugh
|
|
||||||
## if other_person.get_gender() == gen.lib.Person.MALE:
|
|
||||||
## return (self.get_son(firstRel),common)
|
|
||||||
## else:
|
|
||||||
## return (self.get_daughter(firstRel),common)
|
|
||||||
## elif firstRel == 1:
|
|
||||||
## if other_person.get_gender() == gen.lib.Person.MALE:
|
|
||||||
## return (self.get_uncle(secondRel),common)
|
|
||||||
## else:
|
|
||||||
## return (self.get_aunt(secondRel),common)
|
|
||||||
## elif secondRel == 1:
|
|
||||||
## if other_person.get_gender() == gen.lib.Person.MALE:
|
|
||||||
## return (self.get_nephew(firstRel-1),common)
|
|
||||||
## else:
|
|
||||||
## return (self.get_niece(firstRel-1),common)
|
|
||||||
## else:
|
|
||||||
## if secondRel > firstRel:
|
|
||||||
## return (self.get_cousin(firstRel-1,secondRel-firstRel),common)
|
|
||||||
## else:
|
|
||||||
## return (self.get_cousin(secondRel-1,firstRel-secondRel),common)
|
|
||||||
|
|
||||||
|
|
||||||
def get_grandparents_string(self,db,orig_person,other_person):
|
def get_grandparents_string(self,db,orig_person,other_person):
|
||||||
"""
|
"""
|
||||||
@ -964,12 +952,12 @@ class RelationshipCalculator:
|
|||||||
"""
|
"""
|
||||||
Provides a string that describes the relationsip between a person, and
|
Provides a string that describes the relationsip between a person, and
|
||||||
another person. E.g. "grandparent" or "child".
|
another person. E.g. "grandparent" or "child".
|
||||||
To be used as: 'person a is the grandparent of b', this will
|
To be used as: 'person b is the grandparent of a', this will
|
||||||
be in translation string :
|
be in translation string :
|
||||||
'person a is the %(relation)s of b'
|
'person b is the %(relation)s of a'
|
||||||
Note that languages with gender should add 'the' inside the
|
Note that languages with gender should add 'the' inside the
|
||||||
translation, so eg in french:
|
translation, so eg in french:
|
||||||
'person a est %(relation)s de b'
|
'person b est %(relation)s de a'
|
||||||
where relation will be here: le grandparent
|
where relation will be here: le grandparent
|
||||||
|
|
||||||
Ga and Gb can be used to mathematically calculate the relationship.
|
Ga and Gb can be used to mathematically calculate the relationship.
|
||||||
@ -1032,44 +1020,51 @@ class RelationshipCalculator:
|
|||||||
"""
|
"""
|
||||||
## print 'Ga, Gb :', Ga, Gb
|
## print 'Ga, Gb :', Ga, Gb
|
||||||
rel_str = "distant relatives"
|
rel_str = "distant relatives"
|
||||||
|
|
||||||
|
if only_birth:
|
||||||
|
step = ''
|
||||||
|
else:
|
||||||
|
step = STEP
|
||||||
|
|
||||||
|
if in_law_a or in_law_b :
|
||||||
|
inlaw = INLAW
|
||||||
|
else:
|
||||||
|
inlaw = ''
|
||||||
|
|
||||||
if Ga == 0:
|
if Ga == 0:
|
||||||
# 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 gender_b == gen.lib.Person.MALE and Gb < len(_son_level):
|
elif gender_b == gen.lib.Person.MALE:
|
||||||
rel_str = _son_level[Gb]
|
rel_str = self.get_son(Gb, step)
|
||||||
elif gender_b == gen.lib.Person.FEMALE and Gb < len(_daughter_level):
|
elif gender_b == gen.lib.Person.FEMALE:
|
||||||
rel_str = _daughter_level[Gb]
|
rel_str = self.get_daughter(Gb, step)
|
||||||
elif Gb < len(_level_name):
|
|
||||||
rel_str = _level_name[Gb] + ' ' + 'descendant'
|
|
||||||
else:
|
else:
|
||||||
rel_str = "distant descendant (%d generations)" % Gb
|
rel_str = self.get_child_unknown(Gb, step)
|
||||||
elif Gb == 0:
|
elif Gb == 0:
|
||||||
# b is parents/grand parent of a
|
# b is parents/grand parent of a
|
||||||
if gender_b == gen.lib.Person.MALE and Ga < len(_father_level):
|
if gender_b == gen.lib.Person.MALE:
|
||||||
rel_str = _father_level[Ga]
|
rel_str = self.get_father(Ga, step, inlaw)
|
||||||
elif gender_b == gen.lib.Person.FEMALE and Gb < len(_mother_level):
|
elif gender_b == gen.lib.Person.FEMALE:
|
||||||
rel_str = _mother_level[Ga]
|
rel_str = self.get_mother(Ga, step, inlaw)
|
||||||
elif Ga < len(_level_name):
|
|
||||||
rel_str = _level_name[Ga] + ' ' + 'ancestor'
|
|
||||||
else:
|
else:
|
||||||
rel_str = "distant ancestor (%d generations)" % Ga
|
rel_str = self.get_parent_unknown(Ga, step, inlaw)
|
||||||
elif Gb == 1:
|
elif Gb == 1:
|
||||||
# b is sibling/aunt/uncle of a
|
# b is sibling/aunt/uncle of a
|
||||||
if gender_b == gen.lib.Person.MALE and Ga < len(_brother_level):
|
if gender_b == gen.lib.Person.MALE:
|
||||||
rel_str = _brother_level[Ga]
|
rel_str = self.get_uncle(Ga)
|
||||||
elif gender_b == gen.lib.Person.FEMALE and Ga < len(_sister_level):
|
elif gender_b == gen.lib.Person.FEMALE:
|
||||||
rel_str = _sister_level[Ga]
|
rel_str = self.get_aunt(Ga)
|
||||||
elif Ga < len(_sibling_level):
|
elif Ga < len(_sibling_level):
|
||||||
rel_str = _sibling_level[Ga]
|
rel_str = _sibling_level[Ga]
|
||||||
else:
|
else:
|
||||||
rel_str = "distant uncle/aunt"
|
rel_str = "distant uncle/aunt"
|
||||||
elif Ga == 1:
|
elif Ga == 1:
|
||||||
# b is niece/nephew of a
|
# b is niece/nephew of a
|
||||||
if gender_b == gen.lib.Person.MALE and Gb < len(_nephew_level):
|
if gender_b == gen.lib.Person.MALE:
|
||||||
rel_str = _nephew_level[Gb]
|
rel_str = self.get_nephew(Gb)
|
||||||
elif gender_b == gen.lib.Person.FEMALE and Gb < len(_niece_level):
|
elif gender_b == gen.lib.Person.FEMALE:
|
||||||
rel_str = _niece_level[Gb]
|
rel_str = self.get_niece(Gb)
|
||||||
elif Gb < len(_niece_level) and Gb < len(_nephew_level):
|
elif Gb < len(_niece_level) and Gb < len(_nephew_level):
|
||||||
rel_str = "%s or %s" %(_nephew_level[Gb], _niece_level[Gb])
|
rel_str = "%s or %s" %(_nephew_level[Gb], _niece_level[Gb])
|
||||||
else:
|
else:
|
||||||
@ -1099,3 +1094,220 @@ class RelationshipCalculator:
|
|||||||
else:
|
else:
|
||||||
rel_str = "distant cousin"
|
rel_str = "distant cousin"
|
||||||
return rel_str
|
return rel_str
|
||||||
|
|
||||||
|
def _test(onlybirth, inlawa, inlawb):
|
||||||
|
""" this is a generic test suite for the singular relationship
|
||||||
|
TRANSLATORS: do NOT translate, use __main__ !
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
|
||||||
|
FMT = '%+50s'
|
||||||
|
MAX = 30
|
||||||
|
|
||||||
|
rc = RelationshipCalculator()
|
||||||
|
|
||||||
|
print '\ntesting sons (Enter to start)\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(MAX) :
|
||||||
|
relst = 'f'
|
||||||
|
print FMT % rc.get_single_relationship_string(0, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
'', relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting daughters\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(MAX) :
|
||||||
|
relst = 'm'
|
||||||
|
print FMT % rc.get_single_relationship_string(0, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
'', relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting unknown children\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(MAX) :
|
||||||
|
relst = 'm'
|
||||||
|
print FMT % rc.get_single_relationship_string(0, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.UNKNOWN,
|
||||||
|
'', relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting grandfathers\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(MAX) :
|
||||||
|
relst = 'f'
|
||||||
|
print FMT % rc.get_single_relationship_string(i, 0,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
relst * i, '',
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting grandmothers\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(MAX) :
|
||||||
|
relst = 'm'
|
||||||
|
print FMT % rc.get_single_relationship_string(i, 0,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
relst * i, '',
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting unknown parents\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(MAX) :
|
||||||
|
relst = 'm'
|
||||||
|
print FMT % rc.get_single_relationship_string(i, 0,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
gen.lib.Person.UNKNOWN,
|
||||||
|
relst * i, '',
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting nieces\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relst = 'm'
|
||||||
|
print FMT % rc.get_single_relationship_string(1, i,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
'm', relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting nephews\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relst = 'f'
|
||||||
|
print FMT % rc.get_single_relationship_string(1, i,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
'f', relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting uncles\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relst = 'f'
|
||||||
|
print FMT % rc.get_single_relationship_string(i, 1,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
'f', relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting aunts\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relst = 'f'
|
||||||
|
print FMT % rc.get_single_relationship_string(i, 1,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
'f', relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting male cousins same generation\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relst = 'f'
|
||||||
|
print FMT % rc.get_single_relationship_string(i, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
relst * i, relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting female cousins same generation\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relst = 'm'
|
||||||
|
print FMT % rc.get_single_relationship_string(i, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
relst * i, relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
print '\n\ntesting some cousins up\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
import random
|
||||||
|
random.seed()
|
||||||
|
relst = 'm'
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
for j in range (i,MAX) :
|
||||||
|
rnd = random.randint(0, 100)
|
||||||
|
if rnd < 10 :
|
||||||
|
if rnd < 5 :
|
||||||
|
print (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
|
||||||
|
rc.get_single_relationship_string(j, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
relst * i, relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb), j, i )
|
||||||
|
else:
|
||||||
|
print (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
|
||||||
|
rc.get_single_relationship_string(j, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
relst * i, relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb), j, i )
|
||||||
|
print '\n\ntesting some cousins down\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
relst = 'm'
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
for j in range (i,MAX) :
|
||||||
|
rnd = random.randint(0, 100)
|
||||||
|
if rnd < 10 :
|
||||||
|
if rnd < 5 :
|
||||||
|
print (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
|
||||||
|
rc.get_single_relationship_string(i, j,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
relst * i, relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb), i, j)
|
||||||
|
else:
|
||||||
|
print (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
|
||||||
|
rc.get_single_relationship_string(i, j,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
relst * i, relst * i,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb), i, j)
|
||||||
|
|
||||||
|
def test():
|
||||||
|
""" this is a generic test suite for the singular relationship
|
||||||
|
TRANSLATORS: do NOT translate, call this from
|
||||||
|
__main__ in the rel_xx.py module.
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
|
||||||
|
print '\nType y to do a test\n\n'
|
||||||
|
print 'Test normal relations?'
|
||||||
|
data = sys.stdin.readline()
|
||||||
|
if data == 'y\n':
|
||||||
|
_test(True, False, False)
|
||||||
|
print '\n\nTest step relations?'
|
||||||
|
data = sys.stdin.readline()
|
||||||
|
if data == 'y\n':
|
||||||
|
_test(False, False, False)
|
||||||
|
print '\n\nTest in-law relations (first pers)?'
|
||||||
|
data = sys.stdin.readline()
|
||||||
|
if data == 'y\n':
|
||||||
|
_test(True, True, False)
|
||||||
|
print '\n\nTest step and in-law relations?'
|
||||||
|
data = sys.stdin.readline()
|
||||||
|
if data == 'y\n':
|
||||||
|
_test(False, True, False)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
"""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
|
||||||
|
"""
|
||||||
|
test()
|
||||||
|
Loading…
Reference in New Issue
Block a user