6817: Enhancements for testing localized Relationship handlers (contribution by Fedir)

svn: r22538
This commit is contained in:
Jérôme Rapinat 2013-06-20 14:36:32 +00:00
parent dadd00f200
commit 37f3183c3b
2 changed files with 435 additions and 331 deletions

View File

@ -1859,7 +1859,7 @@ def get_relationship_calculator(reinit=False):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def _test(rc, onlybirth, inlawa, inlawb, printrelstr): def _test(rc, onlybirth, inlawa, inlawb, printrelstr, testNum = None):
""" 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__ !
""" """
@ -1871,7 +1871,7 @@ def _test(rc, onlybirth, inlawa, inlawb, printrelstr):
return 'f' return 'f'
else: else:
return 'm' return 'm'
def _rand_relstr(len, endstr): def _rand_relstr(len, endstr):
if len == 0: if len == 0:
return '' return ''
@ -1880,295 +1880,337 @@ def _test(rc, onlybirth, inlawa, inlawb, printrelstr):
for i in range(len-1): for i in range(len-1):
relstr += _rand_f_m() relstr += _rand_f_m()
return relstr + endstr return relstr + endstr
FMT = '%+50s' FMT = '%+50s'
MAX = 30 MAX = 30
#rc = RelationshipCalculator() if testNum == None:
print("""
print '\ntesting sons (Enter to start)\n' Select a test:
sys.stdin.readline() 0 - all tests
for i in range(MAX) : 1 - testing sons
relstr = _rand_relstr(i,'f') 2 - testing daughters
rel = FMT % rc.get_single_relationship_string(0, i, 3 - testing unknown children
MALE, 4 - testing grandfathers
MALE, 5 - testing grandmothers
'', relstr, 6 - testing unknown parents
only_birth=onlybirth, 7 - testing nieces
in_law_a=inlawa, 8 - testing nephews
in_law_b=inlawb) 9 - testing unknown nephews/nieces
if printrelstr : 10 - testing uncles
print rel + ' |info:', relstr 11 - testing aunts
else: 12 - testing unknown uncles/aunts
print rel 13 - testing male cousins same generation
print '\n\ntesting daughters\n' 14 - testing female cousins same generation
sys.stdin.readline() 15 - testing unknown cousins same generation
for i in range(MAX) : 16 - testing some cousins up
relstr = _rand_relstr(i,'m') 17 - testing some cousins down
rel = FMT % rc.get_single_relationship_string(0, i,
MALE, Please enter a test number and press Enter for continue:
FEMALE, """)
'', relstr, testNum = sys.stdin.readline().strip()
only_birth=onlybirth, testNum = int(testNum)
in_law_a=inlawa, in_law_b=inlawb)
if printrelstr : if testNum == 0 or testNum == 1:
print rel + ' |info:', relstr print('\ntesting sons')
else: #sys.stdin.readline()
print rel for i in range(MAX) :
print '\n\ntesting unknown children\n' relstr = _rand_relstr(i,'f')
sys.stdin.readline() rel = FMT % rc.get_single_relationship_string(0, i,
for i in range(MAX) : MALE,
relstr = _rand_relstr(i,'f') MALE,
rel = FMT % rc.get_single_relationship_string(0, i, '', relstr,
MALE, only_birth=onlybirth,
UNKNOWN, in_law_a=inlawa,
'', relstr, in_law_b=inlawb)
only_birth=onlybirth, if printrelstr :
in_law_a=inlawa, in_law_b=inlawb) print(rel + ' |info:', relstr)
if printrelstr : else:
print rel + ' |info:', relstr print(rel)
else: if testNum == 0 or testNum == 2:
print rel print('\ntesting daughters\n')
print '\n\ntesting grandfathers\n' #sys.stdin.readline()
sys.stdin.readline() for i in range(MAX) :
for i in range(MAX) : relstr = _rand_relstr(i,'m')
relstr = _rand_relstr(i,'f') rel = FMT % rc.get_single_relationship_string(0, i,
rel = FMT % rc.get_single_relationship_string(i, 0, MALE,
FEMALE, FEMALE,
MALE, '', relstr,
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 :
if printrelstr : print(rel + ' |info:', relstr)
print rel + ' |info:', relstr else:
else: print(rel)
print rel if testNum == 0 or testNum == 3:
print '\n\ntesting grandmothers\n' print('\ntesting unknown children\n')
sys.stdin.readline() #sys.stdin.readline()
for i in range(MAX) : for i in range(MAX) :
relstr = _rand_relstr(i,'m') relstr = _rand_relstr(i,'f')
rel = FMT % rc.get_single_relationship_string(i, 0, rel = FMT % rc.get_single_relationship_string(0, i,
FEMALE, MALE,
FEMALE, UNKNOWN,
relstr, '', '', 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 : if printrelstr :
print rel + ' |info:', relstr print(rel + ' |info:', relstr)
else: else:
print rel print(rel)
print '\n\ntesting unknown parents\n' if testNum == 0 or testNum == 4:
sys.stdin.readline() print('\ntesting grandfathers\n')
for i in range(MAX) : #sys.stdin.readline()
relstr = _rand_relstr(i,'f') for i in range(MAX) :
rel = FMT % rc.get_single_relationship_string(i, 0, relstr = _rand_relstr(i,'f')
FEMALE, rel = FMT % rc.get_single_relationship_string(i, 0,
UNKNOWN, FEMALE,
relstr, '', MALE,
only_birth=onlybirth, relstr, '',
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 if printrelstr :
else: print(rel + ' |info:', relstr)
print rel else:
print '\n\ntesting nieces\n' print(rel)
sys.stdin.readline() if testNum == 0 or testNum == 5:
for i in range(1, MAX) : print('\ntesting grandmothers\n')
relstr = _rand_relstr(i,'m') #sys.stdin.readline()
rel = FMT % rc.get_single_relationship_string(1, i, for i in range(MAX) :
FEMALE, relstr = _rand_relstr(i,'m')
FEMALE, rel = FMT % rc.get_single_relationship_string(i, 0,
'm', relstr, FEMALE,
only_birth=onlybirth, FEMALE,
in_law_a=inlawa, in_law_b=inlawb) relstr, '',
if printrelstr : only_birth=onlybirth,
print rel + ' |info:', relstr in_law_a=inlawa, in_law_b=inlawb)
else: if printrelstr :
print rel print(rel + ' |info:', relstr)
print '\n\ntesting nephews\n' else:
sys.stdin.readline() print(rel)
for i in range(1, MAX) : if testNum == 0 or testNum == 6:
relstr = _rand_relstr(i,'f') print('\ntesting unknown parents\n')
rel = FMT % rc.get_single_relationship_string(1, i, #sys.stdin.readline()
FEMALE, for i in range(MAX) :
MALE, relstr = _rand_relstr(i,'f')
'f', relstr, rel = FMT % rc.get_single_relationship_string(i, 0,
only_birth=onlybirth, FEMALE,
in_law_a=inlawa, in_law_b=inlawb) UNKNOWN,
if printrelstr : relstr, '',
print rel + ' |info:', relstr only_birth=onlybirth,
else: in_law_a=inlawa, in_law_b=inlawb)
print rel if printrelstr :
print '\n\ntesting unknown nephews/nieces\n' print(rel + ' |info:', relstr)
sys.stdin.readline() else:
for i in range(1, MAX) : print(rel)
relstr = _rand_relstr(i,'f') if testNum == 0 or testNum == 7:
rel = FMT % rc.get_single_relationship_string(1, i, print('\ntesting nieces\n')
FEMALE, #sys.stdin.readline()
UNKNOWN, for i in range(1, MAX) :
'f', relstr, relstr = _rand_relstr(i,'m')
only_birth=onlybirth, rel = FMT % rc.get_single_relationship_string(1, i,
in_law_a=inlawa, in_law_b=inlawb) FEMALE,
if printrelstr : FEMALE,
print rel + ' |info:', relstr 'm', relstr,
else: only_birth=onlybirth,
print rel in_law_a=inlawa, in_law_b=inlawb)
print '\n\ntesting uncles\n' if printrelstr :
sys.stdin.readline() print(rel + ' |info:', relstr)
for i in range(1, MAX) : else:
relstr = _rand_relstr(i,'f') print(rel)
rel = FMT % rc.get_single_relationship_string(i, 1, if testNum == 0 or testNum == 8:
FEMALE, print('\ntesting nephews\n')
MALE, #sys.stdin.readline()
relstr, 'f', for i in range(1, MAX) :
only_birth=onlybirth, relstr = _rand_relstr(i,'f')
in_law_a=inlawa, in_law_b=inlawb) rel = FMT % rc.get_single_relationship_string(1, i,
if printrelstr : FEMALE,
print rel + ' |info:', relstr MALE,
else: 'f', relstr,
print rel only_birth=onlybirth,
print '\n\ntesting aunts\n' in_law_a=inlawa, in_law_b=inlawb)
sys.stdin.readline() if printrelstr :
for i in range(1, MAX) : print(rel + ' |info:', relstr)
relstr = _rand_relstr(i,'f') else:
rel = FMT % rc.get_single_relationship_string(i, 1, print(rel)
MALE, if testNum == 0 or testNum == 9:
FEMALE, print('\ntesting unknown nephews/nieces\n')
relstr, 'f', #sys.stdin.readline()
only_birth=onlybirth, for i in range(1, MAX) :
in_law_a=inlawa, in_law_b=inlawb) relstr = _rand_relstr(i,'f')
if printrelstr : rel = FMT % rc.get_single_relationship_string(1, i,
print rel + ' |info:', relstr FEMALE,
else: UNKNOWN,
print rel 'f', relstr,
print '\n\ntesting unknown uncles/aunts\n' only_birth=onlybirth,
sys.stdin.readline() in_law_a=inlawa, in_law_b=inlawb)
for i in range(1, MAX) : if printrelstr :
relstr = _rand_relstr(i,'m') print(rel + ' |info:', relstr)
rel = FMT % rc.get_single_relationship_string(i, 1, else:
MALE, print(rel)
UNKNOWN, if testNum == 0 or testNum == 10:
relstr, 'm', print('\ntesting uncles\n')
only_birth=onlybirth, #sys.stdin.readline()
in_law_a=inlawa, in_law_b=inlawb) for i in range(1, MAX) :
if printrelstr : relstr = _rand_relstr(i,'f')
print rel + ' |info:', relstr rel = FMT % rc.get_single_relationship_string(i, 1,
else: FEMALE,
print rel MALE,
print '\n\ntesting male cousins same generation\n' relstr, 'f',
sys.stdin.readline() only_birth=onlybirth,
for i in range(1, MAX) : in_law_a=inlawa, in_law_b=inlawb)
relstra = _rand_relstr(i,'f') if printrelstr :
relstrb = _rand_relstr(i,'f') print(rel + ' |info:', relstr)
rel = FMT % rc.get_single_relationship_string(i, i, else:
MALE, print(rel)
MALE, if testNum == 0 or testNum == 11:
relstra, print('\ntesting aunts\n')
relstrb, #sys.stdin.readline()
only_birth=onlybirth, for i in range(1, MAX) :
in_law_a=inlawa, in_law_b=inlawb) relstr = _rand_relstr(i,'f')
if printrelstr : rel = FMT % rc.get_single_relationship_string(i, 1,
print rel + ' |info:', relstra, relstrb MALE,
else: FEMALE,
print rel relstr, 'f',
print '\n\ntesting female cousins same generation\n' only_birth=onlybirth,
sys.stdin.readline() in_law_a=inlawa, in_law_b=inlawb)
for i in range(1, MAX) : if printrelstr :
relstra = _rand_relstr(i,'m') print(rel + ' |info:', relstr)
relstrb = _rand_relstr(i,'m') else:
rel = FMT % rc.get_single_relationship_string(i, i, print(rel)
MALE, if testNum == 0 or testNum == 12:
FEMALE, print('\ntesting unknown uncles/aunts\n')
relstra, #sys.stdin.readline()
relstrb, for i in range(1, MAX) :
only_birth=onlybirth, relstr = _rand_relstr(i,'m')
in_law_a=inlawa, in_law_b=inlawb) rel = FMT % rc.get_single_relationship_string(i, 1,
if printrelstr : MALE,
print rel + ' |info:', relstra, relstrb UNKNOWN,
else: relstr, 'm',
print rel only_birth=onlybirth,
print '\n\ntesting unknown cousins same generation\n' in_law_a=inlawa, in_law_b=inlawb)
sys.stdin.readline() if printrelstr :
for i in range(1, MAX) : print(rel + ' |info:', relstr)
relstra = _rand_relstr(i,'m') else:
relstrb = _rand_relstr(i,'m') print(rel)
rel = FMT % rc.get_single_relationship_string(i, i, if testNum == 0 or testNum == 13:
MALE, print('\ntesting male cousins same generation\n')
UNKNOWN, #sys.stdin.readline()
relstra, for i in range(1, MAX) :
relstrb, relstra = _rand_relstr(i,'f')
only_birth=onlybirth, relstrb = _rand_relstr(i,'f')
in_law_a=inlawa, in_law_b=inlawb) rel = FMT % rc.get_single_relationship_string(i, i,
if printrelstr : MALE,
print rel + ' |info:', relstra, relstrb MALE,
else: relstra,
print rel relstrb,
print '\n\ntesting some cousins up\n' only_birth=onlybirth,
sys.stdin.readline() in_law_a=inlawa, in_law_b=inlawb)
import random if printrelstr :
random.seed() print(rel + ' |info:', relstra, relstrb)
for i in range(1, MAX) : else:
for j in range (i, MAX) : print(rel)
rnd = random.randint(0, 100) if testNum == 0 or testNum == 14:
if rnd < 10 : print('\ntesting female cousins same generation\n')
relstra = _rand_relstr(j,'f') #sys.stdin.readline()
relstrb = _rand_relstr(i,'f') for i in range(1, MAX) :
if rnd < 5 : relstra = _rand_relstr(i,'m')
rel = (FMT + ' |info: female, Ga=%2d, Gb=%2d') % ( relstrb = _rand_relstr(i,'m')
rc.get_single_relationship_string(j, i, rel = FMT % rc.get_single_relationship_string(i, i,
MALE, MALE,
FEMALE, FEMALE,
relstra, relstrb, relstra,
only_birth=onlybirth, relstrb,
in_law_a=inlawa, in_law_b=inlawb), j, i ) only_birth=onlybirth,
if printrelstr : in_law_a=inlawa, in_law_b=inlawb)
print rel + ' |info:', relstra, relstrb if printrelstr :
print(rel + ' |info:', relstra, relstrb)
else:
print(rel)
if testNum == 0 or testNum == 15:
print('\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,
MALE,
UNKNOWN,
relstra,
relstrb,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb)
if printrelstr :
print(rel + ' |info:', relstra, relstrb)
else:
print(rel)
if testNum == 0 or testNum == 16:
print('\ntesting some cousins up\n')
#sys.stdin.readline()
import random
random.seed()
for i in range(1, MAX) :
for j in range (i, MAX) :
rnd = random.randint(0, 100)
if rnd < 10 :
relstra = _rand_relstr(j,'f')
relstrb = _rand_relstr(i,'f')
if rnd < 5 :
rel = (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
rc.get_single_relationship_string(j, i,
MALE,
FEMALE,
relstra, relstrb,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb), j, i )
if printrelstr :
print(rel + ' |info:', relstra, relstrb)
else:
print(rel)
else: else:
print rel rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
else: rc.get_single_relationship_string(j, i,
rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % ( MALE,
rc.get_single_relationship_string(j, i, MALE,
MALE, relstra, relstrb,
MALE, only_birth=onlybirth,
relstra, relstrb, in_law_a=inlawa, in_law_b=inlawb), j, i )
only_birth=onlybirth, if printrelstr :
in_law_a=inlawa, in_law_b=inlawb), j, i ) print(rel + ' |info:', relstra, relstrb)
if printrelstr : else:
print rel + ' |info:', relstra, relstrb print(rel)
if testNum == 0 or testNum == 17:
print('\ntesting some cousins down\n')
#sys.stdin.readline()
for i in range(1, MAX) :
for j in range (i, MAX) :
rnd = random.randint(0, 100)
if rnd < 10 :
relstra = _rand_relstr(i,'f')
relstrb = _rand_relstr(j,'f')
if rnd < 5 :
rel = (FMT + ' |info: female, Ga=%2d, Gb=%2d') % (
rc.get_single_relationship_string(i, j,
MALE,
FEMALE,
relstra, relstrb,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb), i, j)
if printrelstr :
print(rel + ' |info:', relstra, relstrb)
else:
print(rel)
else: else:
print rel rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
print '\n\ntesting some cousins down\n' rc.get_single_relationship_string(i, j,
sys.stdin.readline() MALE,
for i in range(1, MAX) : MALE,
for j in range (i, MAX) : relstra, relstrb,
rnd = random.randint(0, 100) only_birth=onlybirth,
if rnd < 10 : in_law_a=inlawa, in_law_b=inlawb), i, j)
relstra = _rand_relstr(i,'f') if printrelstr :
relstrb = _rand_relstr(j,'f') print(rel + ' |info:', relstra, relstrb)
if rnd < 5 : else:
rel = (FMT + ' |info: female, Ga=%2d, Gb=%2d') % ( print(rel)
rc.get_single_relationship_string(i, j,
MALE,
FEMALE,
relstra, relstrb,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb), i, j)
if printrelstr :
print rel + ' |info:', relstra, relstrb
else:
print rel
else:
rel = (FMT + ' |info: male, Ga=%2d, Gb=%2d') % (
rc.get_single_relationship_string(i, j,
MALE,
MALE,
relstra, relstrb,
only_birth=onlybirth,
in_law_a=inlawa, in_law_b=inlawb), i, j)
if printrelstr :
print rel + ' |info:', relstr
else:
print rel
def _testsibling(rc): def _testsibling(rc):
vals = [(rc.NORM_SIB, 'sibling'), vals = [(rc.NORM_SIB, 'sibling'),
@ -2181,9 +2223,9 @@ def _testsibling(rc):
(UNKNOWN, 'unknown')]: (UNKNOWN, 'unknown')]:
for inlaw in [False, True]: for inlaw in [False, True]:
for sibt, str in vals: for sibt, str in vals:
print FMT % rc.get_sibling_relationship_string( print(FMT % rc.get_sibling_relationship_string(
sibt, MALE, gendr, sibt, MALE, gendr,
in_law_a = inlaw) + ' |info:', str, strgen in_law_a = inlaw) + ' |info:', str, strgen)
def _test_spouse(rc): def _test_spouse(rc):
FMT = '%+50s' FMT = '%+50s'
@ -2199,41 +2241,63 @@ def _test_spouse(rc):
(FEMALE, 'female'), (FEMALE, 'female'),
(UNKNOWN, 'unknown')] : (UNKNOWN, 'unknown')] :
for spouse_type, str in vals: for spouse_type, str in vals:
print FMT % rc.get_partner_relationship_string( print(FMT % rc.get_partner_relationship_string(
spouse_type, MALE, gender) + \ spouse_type, MALE, gender) + \
' |info: gender='+strgen+', rel='+str ' |info: gender='+strgen+', rel='+str)
def test(rc, printrelstr): def test(rc, 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.
""" """
import sys import sys
import argparse
print '\nType y to do a test\n\n'
print 'Test normal relations?' parser = argparse.ArgumentParser(description='Test the Relationship Calculator')
data = sys.stdin.readline() parser.add_argument('-r', type=int, help = 'type of the relations test')
if data == 'y\n': parser.add_argument('-s', type=int, help = 'type of the singular relationship test')
_test(rc, True, False, False, printrelstr)
print '\n\nTest step relations?' args = parser.parse_args()
data = sys.stdin.readline() testNum = args.r
if data == 'y\n':
_test(rc, False, False, False, printrelstr) if testNum == None:
print '\n\nTest in-law relations (first pers)?' print("""
data = sys.stdin.readline() Select a test:
if data == 'y\n': 0 - all tests
_test(rc, True, True, False, printrelstr) 1 - Test normal relations
print '\n\nTest step and in-law relations?' 2 - Test step relations
data = sys.stdin.readline() 3 - Test in-law relations (first pers)
if data == 'y\n': 4 - Test step and in-law relations
_test(rc, False, True, False, printrelstr) 5 - Test sibling types
print '\n\nTest sibling types?' 6 - Test partner types
data = sys.stdin.readline()
if data == 'y\n': Please enter a test number and press Enter for continue:
""")
testNum = sys.stdin.readline().strip()
testNum = int(testNum)
if testNum == 0 or testNum == 1:
print('\n\n=== Test normal relations ===')
_test(rc, True, False, False, printrelstr, args.s)
if testNum == 0 or testNum == 2:
print('\n\n=== Test step relations ===')
_test(rc, False, False, False, printrelstr, args.s)
if testNum == 0 or testNum == 3:
print('\n\n=== Test in-law relations (first pers) ===')
_test(rc, True, True, False, printrelstr, args.s)
if testNum == 0 or testNum == 4:
print('\n\n=== Test step and in-law relations ===')
_test(rc, False, True, False, printrelstr, args.s)
if testNum == 0 or testNum == 5:
print('\n\n=== Test sibling types ===')
_testsibling(rc) _testsibling(rc)
print '\n\nTest partner types?'
data = sys.stdin.readline() if testNum == 0 or testNum == 6:
if data == 'y\n': print('\n\n=== Test partner types ===')
_test_spouse(rc) _test_spouse(rc)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -57,6 +57,7 @@ import DateHandler
import gen.lib import gen.lib
import Utils import Utils
import ThumbNails import ThumbNails
import Relationship
from gen.utils import get_birth_or_fallback, get_death_or_fallback from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -121,7 +122,11 @@ class RelGraphReport(Report):
menu = options.menu menu = options.menu
get_option_by_name = options.menu.get_option_by_name get_option_by_name = options.menu.get_option_by_name
get_value = lambda name: get_option_by_name(name).get_value() get_value = lambda name: get_option_by_name(name).get_value()
self.center_person = database.get_person_from_gramps_id(get_value('pid'))
self.increlname = get_value('increlname')
self.advrelinfo = get_value('advrelinfo')
self.includeid = get_value('incid') self.includeid = get_value('incid')
self.includedates = get_value('incdate') self.includedates = get_value('incdate')
self.includeurl = get_value('url') self.includeurl = get_value('url')
@ -157,6 +162,10 @@ class RelGraphReport(Report):
self.arrowtailstyle = 'none' self.arrowtailstyle = 'none'
filter_option = get_option_by_name('filter') filter_option = get_option_by_name('filter')
self._filter = filter_option.get_filter() self._filter = filter_option.get_filter()
if self.increlname :
# init Relationship Calcilator
self.relationship = Relationship.get_relationship_calculator()
def write_report(self): def write_report(self):
self.person_handles = self._filter.apply(self.database, self.person_handles = self._filter.apply(self.database,
@ -326,6 +335,9 @@ class RelGraphReport(Report):
elif gender == person.UNKNOWN: elif gender == person.UNKNOWN:
shape = "hexagon" shape = "hexagon"
if person == self.center_person and self.increlname:
shape = "octagon"
if self.colorize == 'colored': if self.colorize == 'colored':
if gender == person.MALE: if gender == person.MALE:
color = self.colors['male'] color = self.colors['male']
@ -401,12 +413,28 @@ class RelGraphReport(Report):
if self.includedates: if self.includedates:
birth, death = self.get_date_strings(person) birth, death = self.get_date_strings(person)
label = label + '%s(%s - %s)' % (lineDelimiter, birth, death) label = label + '%s(%s - %s)' % (lineDelimiter, birth, death)
if self.increlname :
# Display Relationship info
if self.advrelinfo:
(relation, Ga, Gb) = self.relationship.get_one_relationship(self.database, self.center_person, person, True)
else:
relation = self.relationship.get_one_relationship(self.database, self.center_person, person)
if self.bUseHtmlOutput:
label += '<BR/>' + relation
if self.advrelinfo:
label += '<BR/>Ga=%d Gb=%d' % (Ga, Gb)
else:
label += "%s%s" % (lineDelimiter, relation)
if self.advrelinfo:
label += "%sGa=%d Gb=%d" % (lineDelimiter, Ga, Gb)
# see if we have a table that needs to be terminated # see if we have a table that needs to be terminated
if self.bUseHtmlOutput: if self.bUseHtmlOutput:
label += '</TD></TR></TABLE>' label += '</TD></TR></TABLE>'
return label return label
else : else:
# non html label is enclosed by "" so escape other " # non html label is enclosed by "" so escape other "
return label.replace('"', '\\\"') return label.replace('"', '\\\"')
@ -477,7 +505,7 @@ class RelGraphOptions(MenuReportOptions):
self.__filter.set_help( self.__filter.set_help(
_("Determines what people are included in the graph")) _("Determines what people are included in the graph"))
add_option("filter", self.__filter) add_option("filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed) #self.__filter.connect('value-changed', self.__filter_changed)
self.__pid = PersonOption(_("Filter Person")) self.__pid = PersonOption(_("Filter Person"))
self.__pid.set_help(_("The center person for the filter")) self.__pid.set_help(_("The center person for the filter"))
@ -486,6 +514,18 @@ class RelGraphOptions(MenuReportOptions):
self.__update_filters() self.__update_filters()
self.__include_relname = BooleanOption(
_("Include Relationships"), True)
self.__include_relname.set_help(_("Include the Relationships"
"names, for display relations to the center person"))
add_option("increlname", self.__include_relname)
self.__include_advrelinfo = BooleanOption(
_("Advanced Relationships info"), False)
self.__include_advrelinfo.set_help(_("Include Ga and Gb info,"
" useful for debug the Relationship calculator"))
add_option("advrelinfo", self.__include_advrelinfo)
self.incdate = BooleanOption( self.incdate = BooleanOption(
_("Include Birth, Marriage and Death dates"), True) _("Include Birth, Marriage and Death dates"), True)
self.incdate.set_help(_("Include the dates that the individual was " self.incdate.set_help(_("Include the dates that the individual was "
@ -604,18 +644,18 @@ class RelGraphOptions(MenuReportOptions):
else: else:
self.justyears.set_available(False) self.justyears.set_available(False)
def __filter_changed(self): #def __filter_changed(self):
""" #"""
Handle filter change. If the filter is not specific to a person, #Handle filter change. If the filter is not specific to a person,
disable the person option #disable the person option
""" #"""
filter_value = self.__filter.get_value() #filter_value = self.__filter.get_value()
if filter_value in [1, 2, 3, 4]: #if filter_value in [1, 2, 3, 4]:
# Filters 1, 2, 3 and 4 rely on the center person ## Filters 1, 2, 3 and 4 rely on the center person
self.__pid.set_available(True) #self.__pid.set_available(True)
else: #else:
# The rest don't ## The rest don't
self.__pid.set_available(False) #self.__pid.set_available(False)
def __image_changed(self): def __image_changed(self):
""" """