Added spouses to the child listing in the Detailed Ancestor Report and the Detailed Descendant Report for issues #9926, #8941, and #5698. Also added tests as command line scripts

This commit is contained in:
bertcarnell 2017-02-01 00:06:16 -05:00
parent aee05dc200
commit 010fe736ec
4 changed files with 140 additions and 48 deletions

View File

@ -12,6 +12,7 @@
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2013-2014 Paul Franklin
# Copyright (C) 2014 Gerald Kunzmann <g.kunzmann@arcor.de>
# Copyright (C) 2017 Robert Carnell <bertcarnell_at_gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -96,6 +97,7 @@ class DetAncestorReport(Report):
firstName - Whether to use first names instead of pronouns.
fulldate - Whether to use full dates instead of just year.
listchildren - Whether to list children.
list_children_spouses - Whether to list the spouses of the children
includenotes - Whether to include notes.
incattrs - Whether to include attributes
blankplace - Whether to replace missing Places with ___________.
@ -136,6 +138,7 @@ class DetAncestorReport(Report):
self.fulldate = get_value('fulldates')
use_fulldate = self.fulldate
self.listchildren = get_value('listc')
self.list_children_spouses = get_value('listc_spouses')
self.includenotes = get_value('incnotes')
use_call = get_value('usecall')
blankplace = get_value('repplace')
@ -556,7 +559,10 @@ class DetAncestorReport(Report):
is_first = False
def write_children(self, family):
""" List children.
"""
List children.
:param family: Family
:return:
"""
if not family.get_child_ref_list():
@ -614,6 +620,25 @@ class DetAncestorReport(Report):
self.doc.write_text_citation(
self.__narrator.get_died_string() or
self.__narrator.get_buried_string())
# if the list_children_spouses option is selected:
if self.list_children_spouses:
# get the family of the child that contains the spouse
# of the child. There may be more than one spouse for each
# child
family_handle_list = child.get_family_handle_list()
# for the first spouse, this is true.
# For subsequent spouses, make it false
is_first_family = True
for family_handle in family_handle_list:
child_family = self.database.get_family_from_handle(
family_handle
)
self.doc.write_text_citation(
self.__narrator.get_married_string(
child_family, is_first_family, self._name_display
)
)
is_first_family = False
self.doc.end_paragraph()
def write_family_events(self, family):
@ -692,7 +717,7 @@ class DetAncestorReport(Report):
if self.addimages and len(plist) > 0:
photo = plist[0]
utils.insert_image(self._db, self.doc,
photo, self._user)
photo, self._user)
name = self._nd.display(ind)
if not name:
@ -773,6 +798,9 @@ class DetAncestorOptions(MenuReportOptions):
return _nd.display(person)
def add_menu_options(self, menu):
"""
Add Menu Options
"""
from functools import partial
# Report Options
@ -818,6 +846,11 @@ class DetAncestorOptions(MenuReportOptions):
listc.set_help(_("Whether to list children."))
addopt("listc", listc)
listc_spouses = BooleanOption(_("List Spouses of Children"), False)
listc_spouses.set_help(
_("Whether to list the spouses of the children."))
addopt("listc_spouses", listc_spouses)
computeage = BooleanOption(_("Compute death age"), True)
computeage.set_help(_("Whether to compute a person's age at death."))
addopt("computeage", computeage)

View File

@ -15,6 +15,7 @@
# Copyright (C) 2012 lcc <lcc@6zap.com>
# Copyright (C) 2013-2014 Paul Franklin
# Copyright (C) 2015 Craig J. Anderson
# Copyright (C) 2017 Robert Carnell <bertcarnell_at_gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -98,6 +99,7 @@ class DetDescendantReport(Report):
pageben - Whether to include page break before End Notes.
fulldates - Whether to use full dates instead of just year.
listc - Whether to list children.
list_children_spouses - Whether to list the spouses of the children
incnotes - Whether to include notes.
usecall - Whether to use the call name as the first name.
repplace - Whether to replace missing Places with ___________.
@ -151,6 +153,7 @@ class DetDescendantReport(Report):
self.fulldate = get_value('fulldates')
use_fulldate = self.fulldate
self.listchildren = get_value('listc')
self.list_children_spouses = get_value('listc_spouses')
self.inc_notes = get_value('incnotes')
use_call = get_value('usecall')
blankplace = get_value('repplace')
@ -665,6 +668,8 @@ class DetDescendantReport(Report):
def __write_children(self, family):
"""
List the children for the given family.
:param family: Family
:return:
"""
if not family.get_child_ref_list():
return
@ -724,6 +729,25 @@ class DetDescendantReport(Report):
self.doc.write_text_citation(
self.__narrator.get_died_string() or
self.__narrator.get_buried_string())
# if the list_children_spouses option is selected:
if self.list_children_spouses:
# get the family of the child that contains the spouse
# of the child. There may be more than one spouse for each
# child
family_handle_list = child.get_family_handle_list()
# for the first spouse, this is true.
# For subsequent spouses, make it false
is_first_family = True
for family_handle in family_handle_list:
child_family = self.database.get_family_from_handle(
family_handle
)
self.doc.write_text_citation(
self.__narrator.get_married_string(
child_family, is_first_family, self._name_display
)
)
is_first_family = False
self.doc.end_paragraph()
def __write_family_notes(self, family):
@ -1029,6 +1053,11 @@ class DetDescendantOptions(MenuReportOptions):
listc.set_help(_("Whether to list children."))
add_option("listc", listc)
listc_spouses = BooleanOption(_("List Spouses of Children"), False)
listc_spouses.set_help(
_("Whether to list the spouses of the children."))
add_option("listc_spouses", listc_spouses)
computeage = BooleanOption(_("Compute death age"), True)
computeage.set_help(_("Whether to compute a person's age at death."))
add_option("computeage", computeage)

View File

@ -10,48 +10,50 @@ FMT="txt"
TOP_DIR=`dirname $PWD`
TEST_DIR=$TOP_DIR/test
SRC_DIR=$TOP_DIR/src
PRG="python gramps.py"
SRC_DIR=$TOP_DIR
PRG="python3 Gramps.py"
EXAMPLE_XML=$TOP_DIR/example/gramps/example.gramps
EXAMPLE_GED=$TOP_DIR/example/gedcom/sample.ged
REP_DIR=$TEST_DIR/reports/$REP
mkdir -p $REP_DIR
DATA_DIR=$TEST_DIR/data
mkdir -p $DATA_DIR
if [ -f $DATA_DIR/example.grdb ]; then
rm $DATA_DIR/example.grdb
if [ -f $DATA_DIR/example.gramps ]; then
rm $DATA_DIR/example.gramps
fi
echo ""
echo "+--------------------------------------------------------------"
echo "| Import XML, write GRDB"
echo "| Import XML, write .gramps"
echo "+--------------------------------------------------------------"
OPTS="-i $EXAMPLE_XML -o $DATA_DIR/example.grdb"
OPTS="-i $EXAMPLE_XML -e $DATA_DIR/example.gramps"
(cd $SRC_DIR; $PRG $OPTS)
OPTS="-O $DATA_DIR/example.grdb"
OPTS="-i $DATA_DIR/example.gramps"
echo ""
echo "+--------------------------------------------------------------"
echo "| Export Test Files"
echo "| Text Report: "$REP
echo "| Text Format: "$FMT
echo "+--------------------------------------------------------------"
for desref in {0,1}; do
for incphotos in {0,1}; do
for omitda in {0,1}; do
for incsources in {0,1}; do
for usenick in {0,1}; do
for fulldates in {0,1}; do
for incnotes in {0,1}; do
for repplace in {0,1}; do
for repdate in {0,1}; do
for computeage in {0,1}; do
for incnames in {0,1}; do
for incevents in {0,1}; do
for listc in {0,1}; do
for desref in 'True' 'False'; do
for incphotos in 'True' 'False'; do
for omitda in 'True' 'False'; do
for incsources in 'True' 'False'; do
for usenick in 'True' 'False'; do
for fulldates in 'True' 'False'; do
for incnotes in 'True' 'False'; do
for repplace in 'True' 'False'; do
for repdate in 'True' 'False'; do
for computeage in 'True' 'False'; do
for incnames in 'True' 'False'; do
for incevents in 'True' 'False'; do
for listc in 'True' 'False'; do
output="$desref$incphotos$omitda$incsources$usenick$fulldates$incnotes$repplace$repdate$computeage$incnames$incevents$listc"
action="-a report -p name=$REP,id=I44,off=$FMT,of=$REP_DIR/$output.$FMT,desref=$desref,incphotos=$incphotos,omitda=$omitda,incsources=$incsources,usenick=$usenick,fulldates=$fulldates,incnotes=$incnotes,repplace=$repplace,repdate=$repdate,computeage=$computeage,incnames=$incnames,incevents=$incevents,listc=$listc"
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,desref=$desref,incphotos=$incphotos,omitda=$omitda,incsources=$incsources,usenick=$usenick,fulldates=$fulldates,incnotes=$incnotes,repplace=$repplace,repdate=$repdate,computeage=$computeage,incnames=$incnames,incevents=$incevents,listc=$listc"
(cd $SRC_DIR; $PRG $OPTS $action)
done
done
@ -66,3 +68,20 @@ done
done
done
done
echo "+--------------------------------------------------------------"
echo "| Export file based on sample.ged"
echo "| Text Report: "$REP
echo "| Text Format: "$FMT
echo "+--------------------------------------------------------------"
(cd $SRC_DIR; $PRG -i $EXAMPLE_GED -e $DATA_DIR/example.gramps)
output="NoChildren"
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,listc=False,listc_spouses=False"
(cd $SRC_DIR; $PRG $OPTS $action)
output="ChildrenNoSpouse"
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,listc=True,listc_spouses=False"
(cd $SRC_DIR; $PRG $OPTS $action)
output="ChildrenSpouse"
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,listc=True,listc_spouses=True"
(cd $SRC_DIR; $PRG $OPTS $action)

View File

@ -5,55 +5,55 @@
# $Id$
REP="det_ancestor_report"
REP="det_descendant_report"
FMT="txt"
TOP_DIR=`dirname $PWD`
TEST_DIR=$TOP_DIR/test
SRC_DIR=$TOP_DIR/src
PRG="python gramps.py"
SRC_DIR=$TOP_DIR
PRG="python3 Gramps.py"
EXAMPLE_XML=$TOP_DIR/example/gramps/example.gramps
EXAMPLE_GED=$TOP_DIR/example/gedcom/sample.ged
REP_DIR=$TEST_DIR/reports/$REP
mkdir -p $REP_DIR
DATA_DIR=$TEST_DIR/data
mkdir -p $DATA_DIR
if [ -f $DATA_DIR/example.grdb ]; then
rm $DATA_DIR/example.grdb
if [ -f $DATA_DIR/example.gramps ]; then
rm $DATA_DIR/example.gramps
fi
echo ""
echo "+--------------------------------------------------------------"
echo "| Import XML, write GRDB"
echo "| Import XML, write .gramps"
echo "+--------------------------------------------------------------"
OPTS="-i $EXAMPLE_XML -o $DATA_DIR/example.grdb"
(cd $SRC_DIR; $PRG $OPTS)
OPTS="-i $EXAMPLE_XML -e $DATA_DIR/example.gramps"
#(cd $SRC_DIR; $PRG $OPTS)
OPTS="-O $DATA_DIR/example.grdb"
OPTS="-i $DATA_DIR/example.gramps"
echo ""
echo "+--------------------------------------------------------------"
echo "| Export Test Files"
echo "| Text Report: "$REP
echo "| Text Format: "$FMT
echo "+--------------------------------------------------------------"
for desref in {0,1}; do
for incphotos in {0,1}; do
for omitda in {0,1}; do
for incsources in {0,1}; do
for usenick in {0,1}; do
for fulldates in {0,1}; do
for incnotes in {0,1}; do
for repplace in {0,1}; do
for repdate in {0,1}; do
for computeage in {0,1}; do
for incnames in {0,1}; do
for incevents in {0,1}; do
for listc in {0,1}; do
for desref in 'True' 'False'; do
for incphotos in 'True' 'False'; do
for omitda in 'True' 'False'; do
for incsources in 'True' 'False'; do
for fulldates in 'True' 'False'; do
for incnotes in 'True' 'False'; do
for repplace in 'True' 'False'; do
for repdate in 'True' 'False'; do
for computeage in 'True' 'False'; do
for incnames in 'True' 'False'; do
for incevents in 'True' 'False'; do
for listc in 'True' 'False'; do
output="$desref$incphotos$omitda$incsources$usenick$fulldates$incnotes$repplace$repdate$computeage$incnames$incevents$listc"
action="-a report -p name=$REP,id=I44,off=$FMT,of=$REP_DIR/$output.$FMT,desref=$desref,incphotos=$incphotos,omitda=$omitda,incsources=$incsources,usenick=$usenick,fulldates=$fulldates,incnotes=$incnotes,repplace=$repplace,repdate=$repdate,computeage=$computeage,incnames=$incnames,incevents=$incevents,listc=$listc"
(cd $SRC_DIR; $PRG $OPTS $action)
done
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,desref=$desref,incphotos=$incphotos,omitda=$omitda,incsources=$incsources,fulldates=$fulldates,incnotes=$incnotes,repplace=$repplace,repdate=$repdate,computeage=$computeage,incnames=$incnames,incevents=$incevents,listc=$listc"
#(cd $SRC_DIR; $PRG $OPTS $action)
done
done
done
@ -66,3 +66,14 @@ done
done
done
done
(cd $SRC_DIR; $PRG -i $EXAMPLE_GED -e $DATA_DIR/example.gramps)
output="NoChildren"
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,listc=False,listc_spouses=False"
(cd $SRC_DIR; $PRG $OPTS $action)
output="ChildrenNoSpouse"
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,listc=True,listc_spouses=False"
(cd $SRC_DIR; $PRG $OPTS $action)
output="ChildrenSpouse"
action="-a report -p name=$REP,off=$FMT,of=$REP_DIR/$output.$FMT,listc=True,listc_spouses=True"
(cd $SRC_DIR; $PRG $OPTS $action)