2007-10-27 Benny Malengier <benny.malengier@gramps-project.org>
* src/Relationship.py: finish up step and inlaw, expand test routine Still to add: half-brother recognition, family collapse svn: r9258
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2007-10-27 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
|
* src/Relationship.py: finish up step and inlaw, expand test routine
|
||||||
|
Still to add: half-brother recognition, family collapse
|
||||||
|
|
||||||
2007-10-28 Gary Burton <gary.burton@zen.co.uk>
|
2007-10-28 Gary Burton <gary.burton@zen.co.uk>
|
||||||
* src/DisplayModels/_PeopleModel.py: removed a performance change added
|
* src/DisplayModels/_PeopleModel.py: removed a performance change added
|
||||||
in revision 8734. This was causing issues #1322 & #1324
|
in revision 8734. This was causing issues #1322 & #1324
|
||||||
|
@@ -116,49 +116,53 @@ _daughter_level = [ "", "%sdaughter", "%sgranddaughter", "great %sgranddaughter"
|
|||||||
"seventeenth great %sgranddaughter", "eighteenth great %sgranddaughter",
|
"seventeenth great %sgranddaughter", "eighteenth great %sgranddaughter",
|
||||||
"nineteenth great %sgranddaughter", "twentieth great %sgranddaughter", ]
|
"nineteenth great %sgranddaughter", "twentieth great %sgranddaughter", ]
|
||||||
|
|
||||||
_sister_level = [ "", "sister", "aunt", "grandaunt", "great grandaunt", "second great grandaunt",
|
_sister_level = [ "", "%ssister%s", "%saunt%s", "%sgrandaunt%s",
|
||||||
"third great grandaunt", "fourth great grandaunt",
|
"great %sgrandaunt%s", "second great %sgrandaunt%s",
|
||||||
"fifth great grandaunt", "sixth great grandaunt",
|
"third great %sgrandaunt%s", "fourth great %sgrandaunt%s",
|
||||||
"seventh great grandaunt", "eighth great grandaunt",
|
"fifth great %sgrandaunt%s", "sixth great %sgrandaunt%s",
|
||||||
"ninth great grandaunt", "tenth great grandaunt",
|
"seventh great %sgrandaunt%s", "eighth great %sgrandaunt%s",
|
||||||
"eleventh great grandaunt", "twelfth great grandaunt",
|
"ninth great %sgrandaunt%s", "tenth great %sgrandaunt%s",
|
||||||
"thirteenth great grandaunt", "fourteenth great grandaunt",
|
"eleventh great %sgrandaunt%s", "twelfth great %sgrandaunt%s",
|
||||||
"fifteenth great grandaunt", "sixteenth great grandaunt",
|
"thirteenth great %sgrandaunt%s", "fourteenth great %sgrandaunt%s",
|
||||||
"seventeenth great grandaunt", "eighteenth great grandaunt",
|
"fifteenth great %sgrandaunt%s", "sixteenth great %sgrandaunt%s",
|
||||||
"nineteenth great grandaunt", "twentieth great grandaunt", ]
|
"seventeenth great %sgrandaunt%s", "eighteenth great %sgrandaunt%s",
|
||||||
|
"nineteenth great %sgrandaunt%s", "twentieth great %sgrandaunt%s", ]
|
||||||
|
|
||||||
_brother_level = [ "", "brother", "uncle", "granduncle", "great granduncle", "second great granduncle",
|
_brother_level = [ "", "%sbrother%s", "%suncle%s", "%sgranduncle%s",
|
||||||
"third great granduncle", "fourth great granduncle",
|
"great %sgranduncle%s", "second great %sgranduncle%s",
|
||||||
"fifth great granduncle", "sixth great granduncle",
|
"third great %sgranduncle%s", "fourth great %sgranduncle%s",
|
||||||
"seventh great granduncle", "eighth great granduncle",
|
"fifth great %sgranduncle%s", "sixth great %sgranduncle%s",
|
||||||
"ninth great granduncle", "tenth great granduncle",
|
"seventh great %sgranduncle%s", "eighth great %sgranduncle%s",
|
||||||
"eleventh great granduncle", "twelfth great granduncle",
|
"ninth great %sgranduncle%s", "tenth great %sgranduncle%s",
|
||||||
"thirteenth great granduncle", "fourteenth great granduncle",
|
"eleventh great %sgranduncle%s", "twelfth great %sgranduncle%s",
|
||||||
"fifteenth great granduncle", "sixteenth great granduncle",
|
"thirteenth great %sgranduncle%s", "fourteenth great %sgranduncle%s",
|
||||||
"seventeenth great granduncle", "eighteenth great granduncle",
|
"fifteenth great %sgranduncle%s", "sixteenth great %sgranduncle%s",
|
||||||
"nineteenth great granduncle", "twentieth great granduncle", ]
|
"seventeenth great %sgranduncle%s", "eighteenth great %sgranduncle%s",
|
||||||
|
"nineteenth great %sgranduncle%s", "twentieth great %sgranduncle%s", ]
|
||||||
|
|
||||||
_nephew_level = [ "", "nephew", "grandnephew", "great grandnephew", "second great grandnephew",
|
_nephew_level = [ "", "%snephew%s", "%sgrandnephew%s", "great %sgrandnephew%s",
|
||||||
"third great grandnephew", "fourth great grandnephew",
|
"second great %sgrandnephew%s",
|
||||||
"fifth great grandnephew", "sixth great grandnephew",
|
"third great %sgrandnephew%s", "fourth great %sgrandnephew%s",
|
||||||
"seventh great grandnephew", "eighth great grandnephew",
|
"fifth great %sgrandnephew%s", "sixth great %sgrandnephew%s",
|
||||||
"ninth great grandnephew", "tenth great grandnephew",
|
"seventh great %sgrandnephew%s", "eighth great %sgrandnephew%s",
|
||||||
"eleventh great grandnephew", "twelfth great grandnephew",
|
"ninth great %sgrandnephew%s", "tenth great %sgrandnephew%s",
|
||||||
"thirteenth great grandnephew", "fourteenth great grandnephew",
|
"eleventh great %sgrandnephew%s", "twelfth great %sgrandnephew%s",
|
||||||
"fifteenth great grandnephew", "sixteenth great grandnephew",
|
"thirteenth great %sgrandnephew%s", "fourteenth great %sgrandnephew%s",
|
||||||
"seventeenth great grandnephew", "eighteenth great grandnephew",
|
"fifteenth great %sgrandnephew%s", "sixteenth great %sgrandnephew%s",
|
||||||
"nineteenth great grandnephew", "twentieth great grandnephew", ]
|
"seventeenth great %sgrandnephew%s", "eighteenth great %sgrandnephew%s",
|
||||||
|
"nineteenth great %sgrandnephew%s", "twentieth great %sgrandnephew%s", ]
|
||||||
|
|
||||||
_niece_level = [ "", "niece", "grandniece", "great grandniece", "second great grandniece",
|
_niece_level = [ "", "%sniece%s", "%sgrandniece%s", "great %sgrandniece%s",
|
||||||
"third great grandniece", "fourth great grandniece",
|
"second great %sgrandniece%s",
|
||||||
"fifth great grandniece", "sixth great grandniece",
|
"third great %sgrandniece%s", "fourth great %sgrandniece%s",
|
||||||
"seventh great grandniece", "eighth great grandniece",
|
"fifth great %sgrandniece%s", "sixth great %sgrandniece%s",
|
||||||
"ninth great grandniece", "tenth great grandniece",
|
"seventh great %sgrandniece%s", "eighth great %sgrandniece%s",
|
||||||
"eleventh great grandniece", "twelfth great grandniece",
|
"ninth great %sgrandniece%s", "tenth great %sgrandniece%s",
|
||||||
"thirteenth great grandniece", "fourteenth great grandniece",
|
"eleventh great %sgrandniece%s", "twelfth great %sgrandniece%s",
|
||||||
"fifteenth great grandniece", "sixteenth great grandniece",
|
"thirteenth great %sgrandniece%s", "fourteenth great %sgrandniece%s",
|
||||||
"seventeenth great grandniece", "eighteenth great grandniece",
|
"fifteenth great %sgrandniece%s", "sixteenth great %sgrandniece%s",
|
||||||
"nineteenth great grandniece", "twentieth great grandniece", ]
|
"seventeenth great %sgrandniece%s", "eighteenth great %sgrandniece%s",
|
||||||
|
"nineteenth great %sgrandniece%s", "twentieth great %sgrandniece%s", ]
|
||||||
|
|
||||||
_children_level = [ "",
|
_children_level = [ "",
|
||||||
"children", "grandchildren",
|
"children", "grandchildren",
|
||||||
@@ -188,18 +192,18 @@ _siblings_level = [ "",
|
|||||||
"twentieth great granduncles/aunts", ]
|
"twentieth great granduncles/aunts", ]
|
||||||
|
|
||||||
_sibling_level = [ "",
|
_sibling_level = [ "",
|
||||||
"sibling", "uncle/aunt",
|
"%ssibling%s", "%suncle/aunt%s",
|
||||||
"granduncle/aunt", "great granduncle/aunt",
|
"%sgranduncle/aunt%s", "great %sgranduncle/aunt%s",
|
||||||
"second great granduncle/aunt", "third great granduncle/aunt",
|
"second great %sgranduncle/aunt%s", "third great %sgranduncle/aunt%s",
|
||||||
"fourth great granduncle/aunt", "fifth great granduncle/aunt",
|
"fourth great %sgranduncle/aunt%s", "fifth great %sgranduncle/aunt%s",
|
||||||
"sixth great granduncle/aunt", "seventh great granduncle/aunt",
|
"sixth great %sgranduncle/aunt%s", "seventh great %sgranduncle/aunt%s",
|
||||||
"eighth great granduncle/aunt", "ninth great granduncle/aunt",
|
"eighth great %sgranduncle/aunt%s", "ninth great %sgranduncle/aunt%s",
|
||||||
"tenth great granduncle/aunt", "eleventh great granduncle/aunt",
|
"tenth great %sgranduncle/aunt%s", "eleventh great %sgranduncle/aunt%s",
|
||||||
"twelfth great granduncle/aunt", "thirteenth great granduncle/aunt",
|
"twelfth great %sgranduncle/aunt%s", "thirteenth great %sgranduncle/aunt%s",
|
||||||
"fourteenth great granduncle/aunt", "fifteenth great granduncle/aunt",
|
"fourteenth great %sgranduncle/aunt%s", "fifteenth great %sgranduncle/aunt%s",
|
||||||
"sixteenth great granduncle/aunt", "seventeenth great granduncle/aunt",
|
"sixteenth great %sgranduncle/aunt%s", "seventeenth great %sgranduncle/aunt%s",
|
||||||
"eighteenth great granduncle/aunt", "nineteenth great granduncle/aunt",
|
"eighteenth great %sgranduncle/aunt%s", "nineteenth great %sgranduncle/aunt%s",
|
||||||
"twentieth great granduncle/aunt", ]
|
"twentieth great %sgranduncle/aunt%s", ]
|
||||||
|
|
||||||
_nephews_nieces_level = [ "",
|
_nephews_nieces_level = [ "",
|
||||||
"siblings",
|
"siblings",
|
||||||
@@ -253,13 +257,6 @@ class RelationshipCalculator:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_cousin(self, level, removed):
|
|
||||||
if removed > len(_removed_level)-1 or level>len(_level_name)-1:
|
|
||||||
return "distant relative"
|
|
||||||
else:
|
|
||||||
return "%s cousin%s" % (_level_name[level],
|
|
||||||
_removed_level[removed])
|
|
||||||
|
|
||||||
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 (%d generations)" % level
|
return "distant ancestors (%d generations)" % level
|
||||||
@@ -305,30 +302,47 @@ class RelationshipCalculator:
|
|||||||
else:
|
else:
|
||||||
return "distant %sdescendant (%d generations)" % (step, level)
|
return "distant %sdescendant (%d generations)" % (step, level)
|
||||||
|
|
||||||
def get_aunt(self, level):
|
def get_aunt(self, level, step='', inlaw=''):
|
||||||
if level>len(_sister_level)-1:
|
if level>len(_sister_level)-1:
|
||||||
return "distant aunt"
|
return "distant %saunt%s" % (step, inlaw)
|
||||||
else:
|
else:
|
||||||
return _sister_level[level]
|
return _sister_level[level] % (step, inlaw)
|
||||||
|
|
||||||
def get_uncle(self, level):
|
def get_uncle(self, level, step='', inlaw=''):
|
||||||
if level>len(_brother_level)-1:
|
if level>len(_brother_level)-1:
|
||||||
return "distant uncle"
|
return "distant %suncle%s" % (step, inlaw)
|
||||||
else:
|
else:
|
||||||
return _brother_level[level]
|
return _brother_level[level] % (step, inlaw)
|
||||||
|
|
||||||
def get_nephew(self, level):
|
def get_sibling(self, level, step='', inlaw=''):
|
||||||
|
if level < len(_sibling_level):
|
||||||
|
return _sibling_level[level] % (step, inlaw)
|
||||||
|
else:
|
||||||
|
return "distant %suncle%s/%saunt%s " % (step, inlaw, step, inlaw)
|
||||||
|
|
||||||
|
def get_nephew(self, level, step='', inlaw=''):
|
||||||
if level>len(_nephew_level)-1:
|
if level>len(_nephew_level)-1:
|
||||||
return "distant descendant"
|
return "distant %snephew%s" % (step, inlaw)
|
||||||
else:
|
else:
|
||||||
return _nephew_level[level]
|
return _nephew_level[level] % (step, inlaw)
|
||||||
|
|
||||||
def get_niece(self, level):
|
def get_niece(self, level, step='', inlaw=''):
|
||||||
if level>len(_niece_level)-1:
|
if level>len(_niece_level)-1:
|
||||||
return "distant descendant"
|
return "distant %sniece%s" % (step, inlaw)
|
||||||
else:
|
else:
|
||||||
return _niece_level[level]
|
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 is_spouse(self, db, orig, other):
|
def is_spouse(self, db, orig, other):
|
||||||
for f in orig.get_family_handle_list():
|
for f in orig.get_family_handle_list():
|
||||||
family = db.get_family_from_handle(f)
|
family = db.get_family_from_handle(f)
|
||||||
@@ -1019,7 +1033,6 @@ class RelationshipCalculator:
|
|||||||
@rtype: str
|
@rtype: str
|
||||||
"""
|
"""
|
||||||
## print 'Ga, Gb :', Ga, Gb
|
## print 'Ga, Gb :', Ga, Gb
|
||||||
rel_str = "distant relatives"
|
|
||||||
|
|
||||||
if only_birth:
|
if only_birth:
|
||||||
step = ''
|
step = ''
|
||||||
@@ -1031,6 +1044,8 @@ class RelationshipCalculator:
|
|||||||
else:
|
else:
|
||||||
inlaw = ''
|
inlaw = ''
|
||||||
|
|
||||||
|
rel_str = "distant %srelative%s" % (step, inlaw)
|
||||||
|
|
||||||
if Ga == 0:
|
if Ga == 0:
|
||||||
# b is descendant of a
|
# b is descendant of a
|
||||||
if Gb == 0 :
|
if Gb == 0 :
|
||||||
@@ -1052,230 +1067,355 @@ class RelationshipCalculator:
|
|||||||
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:
|
if gender_b == gen.lib.Person.MALE:
|
||||||
rel_str = self.get_uncle(Ga)
|
rel_str = self.get_uncle(Ga, step, inlaw)
|
||||||
elif gender_b == gen.lib.Person.FEMALE:
|
elif gender_b == gen.lib.Person.FEMALE:
|
||||||
rel_str = self.get_aunt(Ga)
|
rel_str = self.get_aunt(Ga, step, inlaw)
|
||||||
elif Ga < len(_sibling_level):
|
|
||||||
rel_str = _sibling_level[Ga]
|
|
||||||
else:
|
else:
|
||||||
rel_str = "distant uncle/aunt"
|
rel_str = self.get_sibling(Ga, step, inlaw)
|
||||||
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:
|
if gender_b == gen.lib.Person.MALE:
|
||||||
rel_str = self.get_nephew(Gb)
|
rel_str = self.get_nephew(Gb, step, inlaw)
|
||||||
elif gender_b == gen.lib.Person.FEMALE:
|
elif gender_b == gen.lib.Person.FEMALE:
|
||||||
rel_str = self.get_niece(Gb)
|
rel_str = self.get_niece(Gb, step, inlaw)
|
||||||
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" % (self.get_nephew(Gb, step, inlaw),
|
||||||
|
self.get_niece(Gb, step, inlaw))
|
||||||
else:
|
else:
|
||||||
rel_str = "distant nephews/nieces"
|
rel_str = "distant %snephews/nieces%s" % (step, inlaw)
|
||||||
elif Ga > 1 and Ga == Gb:
|
elif Ga == Gb:
|
||||||
# a and b cousins in the same generation
|
# a and b cousins in the same generation
|
||||||
if Ga <= len(_level_name):
|
rel_str = self.get_cousin(Ga-1, 0, dir = '', step=step,
|
||||||
rel_str = "%s cousin" % _level_name[Ga-1]
|
inlaw=inlaw)
|
||||||
else:
|
elif Ga > Gb:
|
||||||
rel_str = "distant cousin"
|
|
||||||
elif Ga > 1 and Ga > Gb:
|
|
||||||
# These are cousins in different generations with the second person
|
# These are cousins in different generations with the second person
|
||||||
# being in a higher generation from the common ancestor than the
|
# being in a higher generation from the common ancestor than the
|
||||||
# first person.
|
# first person.
|
||||||
if Gb <= len(_level_name) and (Ga-Gb) < len(_removed_level):
|
rel_str = self.get_cousin(Gb-1, Ga-Gb, dir = ' (up)',
|
||||||
rel_str = "%s cousin%s (up)" % ( _level_name[Gb-1],
|
step=step, inlaw=inlaw)
|
||||||
_removed_level[Ga-Gb] )
|
elif Gb > Ga:
|
||||||
else:
|
|
||||||
rel_str = "distant cousin"
|
|
||||||
elif Gb > 1 and Gb > Ga:
|
|
||||||
# These are cousins in different generations with the second person
|
# These are cousins in different generations with the second person
|
||||||
# being in a lower generation from the common ancestor than the
|
# being in a lower generation from the common ancestor than the
|
||||||
# first person.
|
# first person.
|
||||||
if Ga <= len(_level_name) and (Gb-Ga) < len(_removed_level):
|
rel_str = self.get_cousin(Ga-1, Gb-Ga, dir = ' (down)',
|
||||||
rel_str = "%s cousin%s (down)" % ( _level_name[Ga-1],
|
step=step, inlaw=inlaw)
|
||||||
_removed_level[Gb-Ga] )
|
|
||||||
else:
|
|
||||||
rel_str = "distant cousin"
|
|
||||||
return rel_str
|
return rel_str
|
||||||
|
|
||||||
def _test(onlybirth, inlawa, inlawb):
|
def _test(onlybirth, inlawa, inlawb, printrelstr):
|
||||||
""" this is a generic test suite for the singular relationship
|
""" this is a generic test suite for the singular relationship
|
||||||
TRANSLATORS: do NOT translate, use __main__ !
|
TRANSLATORS: do NOT translate, use __main__ !
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
import random
|
||||||
|
random.seed()
|
||||||
|
def _rand_f_m():
|
||||||
|
if random.randint(0, 1) == 0 :
|
||||||
|
return 'f'
|
||||||
|
else:
|
||||||
|
return 'm'
|
||||||
|
|
||||||
|
def _rand_relstr(len, endstr):
|
||||||
|
if len == 0:
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
|
relstr = ''
|
||||||
|
for i in range(len-1):
|
||||||
|
relstr += _rand_f_m()
|
||||||
|
return relstr + endstr
|
||||||
|
|
||||||
FMT = '%+50s'
|
FMT = '%+50s'
|
||||||
MAX = 30
|
MAX = 30
|
||||||
|
|
||||||
rc = RelationshipCalculator()
|
rc = RelationshipCalculator()
|
||||||
|
|
||||||
print '\ntesting sons (Enter to start)\n'
|
if inlawa or inlawb :
|
||||||
sys.stdin.readline()
|
print '\nchildren cannot have in-law extension; not testing\n'
|
||||||
for i in range(MAX) :
|
else:
|
||||||
relst = 'f'
|
print '\ntesting sons (Enter to start)\n'
|
||||||
print FMT % rc.get_single_relationship_string(0, i,
|
sys.stdin.readline()
|
||||||
gen.lib.Person.MALE,
|
for i in range(MAX) :
|
||||||
gen.lib.Person.MALE,
|
relstr = _rand_relstr(i,'f')
|
||||||
'', relst * i,
|
rel = FMT % rc.get_single_relationship_string(0, i,
|
||||||
only_birth=onlybirth,
|
gen.lib.Person.MALE,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
gen.lib.Person.MALE,
|
||||||
print '\n\ntesting daughters\n'
|
'', relstr,
|
||||||
sys.stdin.readline()
|
only_birth=onlybirth,
|
||||||
for i in range(MAX) :
|
in_law_a=inlawa,
|
||||||
relst = 'm'
|
in_law_b=inlawb)
|
||||||
print FMT % rc.get_single_relationship_string(0, i,
|
if printrelstr :
|
||||||
gen.lib.Person.MALE,
|
print rel + ' |info:', relstr
|
||||||
gen.lib.Person.FEMALE,
|
else:
|
||||||
'', relst * i,
|
print rel
|
||||||
only_birth=onlybirth,
|
print '\n\ntesting daughters\n'
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
sys.stdin.readline()
|
||||||
print '\n\ntesting unknown children\n'
|
for i in range(MAX) :
|
||||||
sys.stdin.readline()
|
relstr = _rand_relstr(i,'m')
|
||||||
for i in range(MAX) :
|
rel = FMT % rc.get_single_relationship_string(0, i,
|
||||||
relst = 'm'
|
gen.lib.Person.MALE,
|
||||||
print FMT % rc.get_single_relationship_string(0, i,
|
gen.lib.Person.FEMALE,
|
||||||
gen.lib.Person.MALE,
|
'', relstr,
|
||||||
gen.lib.Person.UNKNOWN,
|
only_birth=onlybirth,
|
||||||
'', relst * i,
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
only_birth=onlybirth,
|
if printrelstr :
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
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) :
|
||||||
relst = 'f'
|
relstr = _rand_relstr(i,'f')
|
||||||
print FMT % rc.get_single_relationship_string(i, 0,
|
rel = FMT % rc.get_single_relationship_string(i, 0,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
relst * i, '',
|
relstr, '',
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting grandmothers\n'
|
print '\n\ntesting grandmothers\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(MAX) :
|
for i in range(MAX) :
|
||||||
relst = 'm'
|
relstr = _rand_relstr(i,'m')
|
||||||
print FMT % rc.get_single_relationship_string(i, 0,
|
rel = FMT % rc.get_single_relationship_string(i, 0,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
relst * i, '',
|
relstr, '',
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting unknown parents\n'
|
print '\n\ntesting unknown parents\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(MAX) :
|
for i in range(MAX) :
|
||||||
relst = 'm'
|
relstr = _rand_relstr(i,'f')
|
||||||
print FMT % rc.get_single_relationship_string(i, 0,
|
rel = FMT % rc.get_single_relationship_string(i, 0,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
gen.lib.Person.UNKNOWN,
|
gen.lib.Person.UNKNOWN,
|
||||||
relst * i, '',
|
relstr, '',
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting nieces\n'
|
print '\n\ntesting nieces\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
relst = 'm'
|
relstr = _rand_relstr(i,'m')
|
||||||
print FMT % rc.get_single_relationship_string(1, i,
|
rel = FMT % rc.get_single_relationship_string(1, i,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
'm', relst * i,
|
'm', relstr,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting nephews\n'
|
print '\n\ntesting nephews\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
relst = 'f'
|
relstr = _rand_relstr(i,'f')
|
||||||
print FMT % rc.get_single_relationship_string(1, i,
|
rel = FMT % rc.get_single_relationship_string(1, i,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
'f', relst * i,
|
'f', relstr,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
|
print '\n\ntesting unknown nephews/nieces\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relstr = _rand_relstr(i,'f')
|
||||||
|
rel = FMT % rc.get_single_relationship_string(1, i,
|
||||||
|
gen.lib.Person.FEMALE,
|
||||||
|
gen.lib.Person.UNKNOWN,
|
||||||
|
'f', relstr,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting uncles\n'
|
print '\n\ntesting uncles\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
relst = 'f'
|
relstr = _rand_relstr(i,'f')
|
||||||
print FMT % rc.get_single_relationship_string(i, 1,
|
rel = FMT % rc.get_single_relationship_string(i, 1,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
'f', relst * i,
|
relstr, 'f',
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting aunts\n'
|
print '\n\ntesting aunts\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
relst = 'f'
|
relstr = _rand_relstr(i,'f')
|
||||||
print FMT % rc.get_single_relationship_string(i, 1,
|
rel = FMT % rc.get_single_relationship_string(i, 1,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
'f', relst * i,
|
relstr, 'f',
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
|
print '\n\ntesting unknown uncles/aunts\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relstr = _rand_relstr(i,'m')
|
||||||
|
rel = FMT % rc.get_single_relationship_string(i, 1,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.UNKNOWN,
|
||||||
|
relstr, 'm',
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting male cousins same generation\n'
|
print '\n\ntesting male cousins same generation\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
relst = 'f'
|
relstra = _rand_relstr(i,'f')
|
||||||
print FMT % rc.get_single_relationship_string(i, i,
|
relstrb = _rand_relstr(i,'f')
|
||||||
|
rel = FMT % rc.get_single_relationship_string(i, i,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
relst * i, relst * i,
|
relstra,
|
||||||
|
relstrb,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstra, relstrb
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting female cousins same generation\n'
|
print '\n\ntesting female cousins same generation\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
relst = 'm'
|
relstra = _rand_relstr(i,'m')
|
||||||
print FMT % rc.get_single_relationship_string(i, i,
|
relstrb = _rand_relstr(i,'m')
|
||||||
|
rel = FMT % rc.get_single_relationship_string(i, i,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
relst * i, relst * i,
|
relstra,
|
||||||
|
relstrb,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb)
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstra, relstrb
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
|
print '\n\ntesting unknown cousins same generation\n'
|
||||||
|
sys.stdin.readline()
|
||||||
|
for i in range(1,MAX) :
|
||||||
|
relstra = _rand_relstr(i,'m')
|
||||||
|
relstrb = _rand_relstr(i,'m')
|
||||||
|
rel = FMT % rc.get_single_relationship_string(i, i,
|
||||||
|
gen.lib.Person.MALE,
|
||||||
|
gen.lib.Person.UNKNOWN,
|
||||||
|
relstra,
|
||||||
|
relstrb,
|
||||||
|
only_birth=onlybirth,
|
||||||
|
in_law_a=inlawa, in_law_b=inlawb)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstra, relstrb
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting some cousins up\n'
|
print '\n\ntesting some cousins up\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
import random
|
import random
|
||||||
random.seed()
|
random.seed()
|
||||||
relst = 'm'
|
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
for j in range (i,MAX) :
|
for j in range (i,MAX) :
|
||||||
rnd = random.randint(0, 100)
|
rnd = random.randint(0, 100)
|
||||||
if rnd < 10 :
|
if rnd < 10 :
|
||||||
|
relstra = _rand_relstr(j,'f')
|
||||||
|
relstrb = _rand_relstr(i,'f')
|
||||||
if rnd < 5 :
|
if rnd < 5 :
|
||||||
print (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
|
rel = (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
|
||||||
rc.get_single_relationship_string(j, i,
|
rc.get_single_relationship_string(j, i,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
relst * i, relst * i,
|
relstra, relstrb,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb), j, i )
|
in_law_a=inlawa, in_law_b=inlawb), j, i )
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstra, relstrb
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
else:
|
else:
|
||||||
print (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
|
rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
|
||||||
rc.get_single_relationship_string(j, i,
|
rc.get_single_relationship_string(j, i,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
relst * i, relst * i,
|
relstra, relstrb,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb), j, i )
|
in_law_a=inlawa, in_law_b=inlawb), j, i )
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstra, relstrb
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
print '\n\ntesting some cousins down\n'
|
print '\n\ntesting some cousins down\n'
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
relst = 'm'
|
|
||||||
for i in range(1,MAX) :
|
for i in range(1,MAX) :
|
||||||
for j in range (i,MAX) :
|
for j in range (i,MAX) :
|
||||||
rnd = random.randint(0, 100)
|
rnd = random.randint(0, 100)
|
||||||
if rnd < 10 :
|
if rnd < 10 :
|
||||||
|
relstra = _rand_relstr(i,'f')
|
||||||
|
relstrb = _rand_relstr(j,'f')
|
||||||
if rnd < 5 :
|
if rnd < 5 :
|
||||||
print (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
|
rel = (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
|
||||||
rc.get_single_relationship_string(i, j,
|
rc.get_single_relationship_string(i, j,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
relst * i, relst * i,
|
relstra, relstrb,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb), i, j)
|
in_law_a=inlawa, in_law_b=inlawb), i, j)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstra, relstrb
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
else:
|
else:
|
||||||
print (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
|
rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
|
||||||
rc.get_single_relationship_string(i, j,
|
rc.get_single_relationship_string(i, j,
|
||||||
gen.lib.Person.MALE,
|
gen.lib.Person.MALE,
|
||||||
gen.lib.Person.FEMALE,
|
gen.lib.Person.FEMALE,
|
||||||
relst * i, relst * i,
|
relstra, relstrb,
|
||||||
only_birth=onlybirth,
|
only_birth=onlybirth,
|
||||||
in_law_a=inlawa, in_law_b=inlawb), i, j)
|
in_law_a=inlawa, in_law_b=inlawb), i, j)
|
||||||
|
if printrelstr :
|
||||||
|
print rel + ' |info:', relstr
|
||||||
|
else:
|
||||||
|
print rel
|
||||||
|
|
||||||
def test():
|
def test(printrelstr):
|
||||||
""" this is a generic test suite for the singular relationship
|
""" this is a generic test suite for the singular relationship
|
||||||
TRANSLATORS: do NOT translate, call this from
|
TRANSLATORS: do NOT translate, call this from
|
||||||
__main__ in the rel_xx.py module.
|
__main__ in the rel_xx.py module.
|
||||||
@@ -1286,19 +1426,19 @@ def test():
|
|||||||
print 'Test normal relations?'
|
print 'Test normal relations?'
|
||||||
data = sys.stdin.readline()
|
data = sys.stdin.readline()
|
||||||
if data == 'y\n':
|
if data == 'y\n':
|
||||||
_test(True, False, False)
|
_test(True, False, False, printrelstr)
|
||||||
print '\n\nTest step relations?'
|
print '\n\nTest step relations?'
|
||||||
data = sys.stdin.readline()
|
data = sys.stdin.readline()
|
||||||
if data == 'y\n':
|
if data == 'y\n':
|
||||||
_test(False, False, False)
|
_test(False, False, False, printrelstr)
|
||||||
print '\n\nTest in-law relations (first pers)?'
|
print '\n\nTest in-law relations (first pers)?'
|
||||||
data = sys.stdin.readline()
|
data = sys.stdin.readline()
|
||||||
if data == 'y\n':
|
if data == 'y\n':
|
||||||
_test(True, True, False)
|
_test(True, True, False, printrelstr)
|
||||||
print '\n\nTest step and in-law relations?'
|
print '\n\nTest step and in-law relations?'
|
||||||
data = sys.stdin.readline()
|
data = sys.stdin.readline()
|
||||||
if data == 'y\n':
|
if data == 'y\n':
|
||||||
_test(False, True, False)
|
_test(False, True, False, printrelstr)
|
||||||
|
|
||||||
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
|
||||||
@@ -1310,4 +1450,4 @@ if __name__ == "__main__":
|
|||||||
rel_xx.py module, and test your work with:
|
rel_xx.py module, and test your work with:
|
||||||
python src/plugins/rel_xx.py
|
python src/plugins/rel_xx.py
|
||||||
"""
|
"""
|
||||||
test()
|
test(True)
|
||||||
|
Reference in New Issue
Block a user