Merge pull request #344 from bertcarnell/bertcarnell/list_child_spouses

Add spouses to the child listing in DAR and DDR
This commit is contained in:
Sam Manzi 2017-02-04 09:45:49 +11:00 committed by GitHub
commit f28c90bc7a
4 changed files with 140 additions and 50 deletions

View File

@ -12,6 +12,7 @@
# Copyright (C) 2011 Tim G L Lyons # Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2013-2014 Paul Franklin # Copyright (C) 2013-2014 Paul Franklin
# Copyright (C) 2014 Gerald Kunzmann <g.kunzmann@arcor.de> # 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 # 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 # 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. firstName - Whether to use first names instead of pronouns.
fulldate - Whether to use full dates instead of just year. fulldate - Whether to use full dates instead of just year.
listchildren - Whether to list children. listchildren - Whether to list children.
list_children_spouses - Whether to list the spouses of the children
includenotes - Whether to include notes. includenotes - Whether to include notes.
incattrs - Whether to include attributes incattrs - Whether to include attributes
blankplace - Whether to replace missing Places with ___________. blankplace - Whether to replace missing Places with ___________.
@ -136,6 +138,7 @@ class DetAncestorReport(Report):
self.fulldate = get_value('fulldates') self.fulldate = get_value('fulldates')
use_fulldate = self.fulldate use_fulldate = self.fulldate
self.listchildren = get_value('listc') self.listchildren = get_value('listc')
self.list_children_spouses = get_value('listc_spouses')
self.includenotes = get_value('incnotes') self.includenotes = get_value('incnotes')
use_call = get_value('usecall') use_call = get_value('usecall')
blankplace = get_value('repplace') blankplace = get_value('repplace')
@ -556,7 +559,10 @@ class DetAncestorReport(Report):
is_first = False is_first = False
def write_children(self, family): def write_children(self, family):
""" List children. """
List children.
:param family: Family
:return:
""" """
if not family.get_child_ref_list(): if not family.get_child_ref_list():
@ -614,6 +620,25 @@ class DetAncestorReport(Report):
self.doc.write_text_citation( self.doc.write_text_citation(
self.__narrator.get_died_string() or self.__narrator.get_died_string() or
self.__narrator.get_buried_string()) 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() self.doc.end_paragraph()
def write_family_events(self, family): def write_family_events(self, family):
@ -692,7 +717,7 @@ class DetAncestorReport(Report):
if self.addimages and len(plist) > 0: if self.addimages and len(plist) > 0:
photo = plist[0] photo = plist[0]
utils.insert_image(self._db, self.doc, utils.insert_image(self._db, self.doc,
photo, self._user) photo, self._user)
name = self._nd.display(ind) name = self._nd.display(ind)
if not name: if not name:
@ -773,6 +798,9 @@ class DetAncestorOptions(MenuReportOptions):
return _nd.display(person) return _nd.display(person)
def add_menu_options(self, menu): def add_menu_options(self, menu):
"""
Add Menu Options
"""
from functools import partial from functools import partial
# Report Options # Report Options
@ -818,6 +846,11 @@ class DetAncestorOptions(MenuReportOptions):
listc.set_help(_("Whether to list children.")) listc.set_help(_("Whether to list children."))
addopt("listc", listc) 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 = BooleanOption(_("Compute death age"), True)
computeage.set_help(_("Whether to compute a person's age at death.")) computeage.set_help(_("Whether to compute a person's age at death."))
addopt("computeage", computeage) addopt("computeage", computeage)

View File

@ -15,6 +15,7 @@
# Copyright (C) 2012 lcc <lcc@6zap.com> # Copyright (C) 2012 lcc <lcc@6zap.com>
# Copyright (C) 2013-2014 Paul Franklin # Copyright (C) 2013-2014 Paul Franklin
# Copyright (C) 2015 Craig J. Anderson # 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 # 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 # 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. pageben - Whether to include page break before End Notes.
fulldates - Whether to use full dates instead of just year. fulldates - Whether to use full dates instead of just year.
listc - Whether to list children. listc - Whether to list children.
list_children_spouses - Whether to list the spouses of the children
incnotes - Whether to include notes. incnotes - Whether to include notes.
usecall - Whether to use the call name as the first name. usecall - Whether to use the call name as the first name.
repplace - Whether to replace missing Places with ___________. repplace - Whether to replace missing Places with ___________.
@ -151,6 +153,7 @@ class DetDescendantReport(Report):
self.fulldate = get_value('fulldates') self.fulldate = get_value('fulldates')
use_fulldate = self.fulldate use_fulldate = self.fulldate
self.listchildren = get_value('listc') self.listchildren = get_value('listc')
self.list_children_spouses = get_value('listc_spouses')
self.inc_notes = get_value('incnotes') self.inc_notes = get_value('incnotes')
use_call = get_value('usecall') use_call = get_value('usecall')
blankplace = get_value('repplace') blankplace = get_value('repplace')
@ -665,6 +668,8 @@ class DetDescendantReport(Report):
def __write_children(self, family): def __write_children(self, family):
""" """
List the children for the given family. List the children for the given family.
:param family: Family
:return:
""" """
if not family.get_child_ref_list(): if not family.get_child_ref_list():
return return
@ -724,6 +729,25 @@ class DetDescendantReport(Report):
self.doc.write_text_citation( self.doc.write_text_citation(
self.__narrator.get_died_string() or self.__narrator.get_died_string() or
self.__narrator.get_buried_string()) 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() self.doc.end_paragraph()
def __write_family_notes(self, family): def __write_family_notes(self, family):
@ -1029,6 +1053,11 @@ class DetDescendantOptions(MenuReportOptions):
listc.set_help(_("Whether to list children.")) listc.set_help(_("Whether to list children."))
add_option("listc", listc) 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 = BooleanOption(_("Compute death age"), True)
computeage.set_help(_("Whether to compute a person's age at death.")) computeage.set_help(_("Whether to compute a person's age at death."))
add_option("computeage", computeage) add_option("computeage", computeage)

View File

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