* src/Report.py: Proper translatable strings for generation numbers.

* src/ReportUtils.py: More report-related methods.
* src/plugins/DetAncestralReport.py: Use ReportUtils methods.
* src/plugins/DetDescendantReport.py: Use ReportUtils methods.


svn: r4016
This commit is contained in:
Alex Roitman 2005-02-02 05:09:07 +00:00
parent 6b9380044c
commit aa41d93ec1
5 changed files with 607 additions and 824 deletions

View File

@ -1,3 +1,9 @@
2005-02-01 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Report.py: Proper translatable strings for generation numbers.
* src/ReportUtils.py: More report-related methods.
* src/plugins/DetAncestralReport.py: Use ReportUtils methods.
* src/plugins/DetDescendantReport.py: Use ReportUtils methods.
2005-01-02 Guillaume Pratte <guillaumep@soireevideo.org>
* src/po/fr.po : Update from the STABLE branch.

View File

@ -185,21 +185,21 @@ class Report:
# Ordinal generation names. Used by multiple reports.
gen = {
1 : _("First"), 2 : _("Second"),
3 : _("Third"), 4 : _("Fourth"),
5 : _("Fifth"), 6 : _("Sixth"),
7 : _("Seventh"), 8 : _("Eighth"),
9 : _("Ninth"), 10: _("Tenth"),
11: _("Eleventh"), 12: _("Twelfth"),
13: _("Thirteenth"), 14: _("Fourteenth"),
15: _("Fifteenth"), 16: _("Sixteenth"),
17: _("Seventeenth"), 18: _("Eighteenth"),
19: _("Nineteenth"), 20: _("Twentieth"),
21: _("Twenty-first"), 22: _("Twenty-second"),
23: _("Twenty-third"), 24: _("Twenty-fourth"),
25: _("Twenty-fifth"), 26: _("Twenty-sixth"),
27: _("Twenty-seventh"), 28: _("Twenty-eighth"),
29: _("Twenty-ninth")
1 : _("First Generation"), 2 : _("Second Generation"),
3 : _("Third Generation"), 4 : _("Fourth Generation"),
5 : _("Fifth Generation"), 6 : _("Sixth Generation"),
7 : _("Seventh Generation"), 8 : _("Eighth Generation"),
9 : _("Ninth Generation"), 10: _("Tenth Generation"),
11: _("Eleventh Generation"), 12: _("Twelfth Generation"),
13: _("Thirteenth Generation"), 14: _("Fourteenth Generation"),
15: _("Fifteenth Generation"), 16: _("Sixteenth Generation"),
17: _("Seventeenth Generation"), 18: _("Eighteenth Generation"),
19: _("Nineteenth Generation"), 20: _("Twentieth Generation"),
21: _("Twenty-first Generation"), 22: _("Twenty-second Generation"),
23: _("Twenty-third Generation"), 24: _("Twenty-fourth Generation"),
25: _("Twenty-fifth Generation"), 26: _("Twenty-sixth Generation"),
27: _("Twenty-seventh Generation"), 28: _("Twenty-eighth Generation"),
29: _("Twenty-ninth Generation")
}
def __init__(self, database, person, options_class):

View File

@ -464,7 +464,8 @@ def born_died_str(database,person,endnotes=None,name_object=None,person_name=Non
else:
person_name = _('She')
bdate,bplace,ddate,dplace = get_birth_death_strings(database,person)
bdate,bplace,bdate_full,ddate,dplace,ddate_full = \
get_birth_death_strings(database,person)
if person.get_gender() == RelLib.Person.MALE:
if bdate:
@ -1233,14 +1234,14 @@ def died_str(database,person,person_name=None,empty_date="",empty_place="",
'age' : age }
else:
if not age_units: #male, no date, no place, no age
text = _("%(male_name)s died.") % {
'male_name' : person_name }
pass #text = _("%(male_name)s died.") % {
#'male_name' : person_name }
elif age_units == 1: #male, no date, no place, years
text = _("%(male_name)s died "
"at the age of %(age)d years.") % {
'male_name' : person_name, 'age' : age }
elif age_units == 2: #male, no date, no place, months
text = _("%(male_name)s died "
passtext = _("%(male_name)s died "
"at the age of %(age)d months.") % {
'male_name' : person_name, 'age' : age }
elif age_units == 3: #male, no date, no place, days
@ -1364,8 +1365,8 @@ def died_str(database,person,person_name=None,empty_date="",empty_place="",
'age' : age }
else:
if not age_units: #female, no date, no place, no age
text = _("%(female_name)s died.") % {
'female_name' : person_name }
pass #text = _("%(female_name)s died.") % {
#'female_name' : person_name }
elif age_units == 1: #female, no date, no place, years
text = _("%(female_name)s died "
"at the age of %(age)d years.") % {
@ -1482,6 +1483,228 @@ def buried_str(database,person,person_name=None,empty_date="",empty_place=""):
text = text + " "
return text
def list_person_str(database,person,person_name=None,empty_date="",empty_place=""):
"""
Briefly list person and birth/death events.
"""
if person_name == None:
person_name = _nd.display_name(person.get_primary_name())
elif person_name == 0:
if person.get_gender() == RelLib.Person.MALE:
person_name = _('He')
else:
person_name = _('She')
bdate,bplace,bdate_full,ddate,dplace,ddate_full = \
get_birth_death_strings(database,person)
text = ""
if person.get_gender() == RelLib.Person.MALE:
if bdate:
if bplace:
if ddate:
if dplace:
text = _("%(male_name)s "
"Born: %(birth_date)s %(birth_place)s "
"Died: %(death_date)s %(death_place)s.") % {
'male_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(male_name)s "
"Born: %(birth_date)s %(birth_place)s "
"Died: %(death_date)s.") % {
'male_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace,
'death_date' : ddate }
else:
if dplace:
text = _("%(male_name)s "
"Born: %(birth_date)s %(birth_place)s "
"Died: %(death_place)s.") % {
'male_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace,
'death_place' : dplace }
else:
text = _("%(male_name)s "
"Born: %(birth_date)s %(birth_place)s.") % {
'male_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace }
else:
if ddate:
if dplace:
text = _("%(male_name)s Born: %(birth_date)s "
"Died: %(death_date)s %(death_place)s.") % {
'male_name' : person_name, 'birth_date' : bdate,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(male_name)s "
"Born: %(birth_date)s Died: %(death_date)s.") % {
'male_name' : person_name, 'birth_date' : bdate,
'death_date' : ddate }
else:
if dplace:
text = _("%(male_name)s "
"Born: %(birth_date)s Died: %(death_place)s.") % {
'male_name' : person_name,
'birth_date' : bdate, 'death_place' : dplace }
else:
text = _("%(male_name)s Born: %(birth_date)s ") % {
'male_name' : person_name, 'birth_date' : bdate }
else:
if bplace:
if ddate:
if dplace:
text = _("%(male_name)s "
"Born: %(birth_place)s "
"Died: %(death_date)s %(death_place)s.") % {
'male_name' : person_name,
'birth_place' : bplace,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(male_name)s "
"Born: %(birth_place)s "
"Died: %(death_date)s.") % {
'male_name' : person_name,
'birth_place' : bplace,
'death_date' : ddate }
else:
if dplace:
text = _("%(male_name)s "
"Born: %(birth_place)s "
"Died: %(death_place)s.") % {
'male_name' : person_name,
'birth_place' : bplace,
'death_place' : dplace }
else:
text = _("%(male_name)s "
"Born: %(birth_place)s.") % {
'male_name' : person_name, 'birth_place' : bplace }
else:
if ddate:
if dplace:
text = _("%(male_name)s "
"Died: %(death_date)s %(death_place)s.") % {
'male_name' : person_name,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(male_name)s "
"Died: %(death_date)s.") % {
'male_name' : person_name, 'death_date' : ddate }
else:
if dplace:
text = _("%(male_name)s Died: %(death_place)s.") % {
'male_name' : person_name, 'death_place' : dplace }
else:
text = _("%(male_name)s.") % {
'male_name' : person_name }
else:
if bdate:
if bplace:
if ddate:
if dplace:
text = _("%(female_name)s "
"Born: %(birth_date)s %(birth_place)s "
"Died: %(death_date)s %(death_place)s.") % {
'female_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(female_name)s "
"Born: %(birth_date)s %(birth_place)s "
"Died: %(death_date)s.") % {
'female_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace,
'death_date' : ddate }
else:
if dplace:
text = _("%(female_name)s "
"Born: %(birth_date)s %(birth_place)s "
"Died: %(death_place)s.") % {
'female_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace,
'death_place' : dplace }
else:
text = _("%(female_name)s "
"Born: %(birth_date)s %(birth_place)s.") % {
'female_name' : person_name,
'birth_date' : bdate, 'birth_place' : bplace }
else:
if ddate:
if dplace:
text = _("%(female_name)s Born: %(birth_date)s "
"Died: %(death_date)s %(death_place)s.") % {
'female_name' : person_name, 'birth_date' : bdate,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(female_name)s "
"Born: %(birth_date)s Died: %(death_date)s.") % {
'female_name' : person_name, 'birth_date' : bdate,
'death_date' : ddate }
else:
if dplace:
text = _("%(female_name)s "
"Born: %(birth_date)s Died: %(death_place)s.") % {
'female_name' : person_name,
'birth_date' : bdate, 'death_place' : dplace }
else:
text = _("%(female_name)s Born: %(birth_date)s ") % {
'female_name' : person_name, 'birth_date' : bdate }
else:
if bplace:
if ddate:
if dplace:
text = _("%(female_name)s "
"Born: %(birth_place)s "
"Died: %(death_date)s %(death_place)s.") % {
'female_name' : person_name,
'birth_place' : bplace,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(female_name)s "
"Born: %(birth_place)s "
"Died: %(death_date)s.") % {
'female_name' : person_name,
'birth_place' : bplace,
'death_date' : ddate }
else:
if dplace:
text = _("%(female_name)s "
"Born: %(birth_place)s "
"Died: %(death_place)s.") % {
'female_name' : person_name,
'birth_place' : bplace,
'death_place' : dplace }
else:
text = _("%(female_name)s "
"Born: %(birth_place)s.") % {
'female_name' : person_name, 'birth_place' : bplace }
else:
if ddate:
if dplace:
text = _("%(female_name)s "
"Died: %(death_date)s %(death_place)s.") % {
'female_name' : person_name,
'death_date' : ddate,'death_place' : dplace }
else:
text = _("%(female_name)s "
"Died: %(death_date)s.") % {
'female_name' : person_name, 'death_date' : ddate }
else:
if dplace:
text = _("%(female_name)s Died: %(death_place)s.") % {
'female_name' : person_name, 'death_place' : dplace }
else:
text = _("%(female_name)s.") % {
'female_name' : person_name }
if text:
text = "- %s " % text
return text
_rtype = {
RelLib.Family.MARRIED : _("Married"),
RelLib.Family.UNMARRIED : _("Unmarried"),
@ -1492,3 +1715,53 @@ _rtype = {
def relationship_name(rtype):
return _rtype.get(rtype)
def old_calc_age(database,person):
"""
Calulate age.
Returns a tuple (age,units) where units is an integer representing
time units:
no age info: 0
years: 1
months: 2
days: 3
"""
# This is an old and ugly implementation.
# It must be changed to use the new age calculator.
age = 0
units = 0
birth_handle = person.get_birth_handle()
if birth_handle:
birth = database.get_event_from_handle(birth_handle).get_date_object()
birth_year_valid = birth.get_year_valid()
else:
birth_year_valid = None
death_handle = person.get_death_handle()
if death_handle:
death = database.get_event_from_handle(death_handle).get_date_object()
death_year_valid = death.get_year_valid()
else:
death_year_valid = None
if birth_year_valid and death_year_valid:
age = death.get_year() - birth.get_year()
units = 1 # year
if birth.get_month_valid() and death.get_month_valid():
if birth.get_month() > death.get_month():
age = age - 1
if birth.get_day_valid() and death.get_day_valid():
if birth.get_month() == death.get_month() and birth.get_day() > death.get_day():
age = age - 1
if age == 0:
age = death.get_month() - birth.get_month() # calc age in months
if birth.get_day() > death.get_day():
age = age - 1
units = 2 # month
if age == 0:
age = death.get-day() + 31 - birth.get_day() # calc age in days
units = 3 # day
return (age,units)

View File

@ -51,7 +51,13 @@ import ReportUtils
from DateHandler import displayer as _dd
from NameDisplay import displayer as _nd
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
EMPTY_ENTRY = "_____________"
#------------------------------------------------------------------------
#
#
@ -104,7 +110,7 @@ class DetAncestorReport(Report.Report):
self.addImages = options_class.handler.options_dict['incphotos']
self.gen_handles = {}
self.prev_gen_hanldes= {}
self.prev_gen_handles= {}
if self.blankDate:
self.EMPTY_DATE = EMPTY_ENTRY
@ -152,12 +158,12 @@ class DetAncestorReport(Report.Report):
self.doc.end_paragraph()
generation = generation + 1
if self.childRef:
self.prev_gen_hanldes= self.gen_handles.copy()
self.prev_gen_handles= self.gen_handles.copy()
self.gen_handles.clear()
person_handle = self.map[key]
person = self.database.get_person_from_handle(person_handle)
self.gen_handles[person_handle]= key
self.gen_handles[person_handle] = key
dupPerson = self.write_person(key)
if dupPerson == 0: # Is this a duplicate ind record
if person.get_gender() == RelLib.Person.FEMALE and \
@ -286,208 +292,102 @@ class DetAncestorReport(Report.Report):
is_first = False
def write_children(self, family):
""" List children
Statement formats:
Child of MOTHER and FATHER is:
Children of MOTHER and FATHER are:
NAME Born: DATE PLACE Died: DATE PLACE f
NAME Born: DATE PLACE Died: DATE e
NAME Born: DATE PLACE Died: PLACE d
NAME Born: DATE PLACE c
NAME Born: DATE Died: DATE PLACE b
NAME Born: DATE Died: DATE a
NAME Born: DATE Died: PLACE 9
NAME Born: DATE 8
NAME Born: PLACE Died: DATE PLACE 7
NAME Born: PLACE Died: DATE 6
NAME Born: PLACE Died: PLACE 5
NAME Born: PLACE 4
NAME Died: DATE 2
NAME Died: DATE PLACE 3
NAME Died: PLACE 1
NAME 0
""" List children.
"""
num_children = len(family.get_child_handle_list())
if num_children > 0:
self.doc.start_paragraph("DAR-ChildTitle")
mother_handle = family.get_mother_handle()
if mother_handle:
mother_obj = self.database.get_person_from_handle(mother_handle)
mother = mother_obj.get_primary_name().get_regular_name()
else:
mother = _("unknown")
if not family.get_child_handle_list():
return
father_handle = family.get_father_handle()
if father_handle:
father_obj = self.database.get_person_from_handle(father_handle)
father = father_obj.get_primary_name().get_regular_name()
else:
father = _("unknown")
mother_handle = family.get_mother_handle()
if mother_handle:
mother = self.database.get_person_from_handle(mother_handle)
mother_name = _nd.display(mother)
else:
mother_name = _("unknown")
father_handle = family.get_father_handle()
if father_handle:
father = self.database.get_person_from_handle(father_handle)
father_name = _nd.display(father)
else:
father_name = _("unknown")
self.doc.start_paragraph("DAR-ChildTitle")
self.doc.start_bold()
self.doc.write_text(_("Children of %s and %s are:") %
(mother_name,father_name))
self.doc.end_bold()
self.doc.end_paragraph()
for child_handle in family.get_child_handle_list():
self.doc.start_paragraph("DAR-ChildList")
child = self.database.get_person_from_handle(child_handle)
child_name = _nd.display(child)
if self.childRef and self.prev_gen_handles.get(child_handle):
child_name = "[%s] %s" % (
str(self.prev_gen_handles.get(child_handle)),
child_name)
text = ReportUtils.list_person_str(self.database,child,child_name)
self.doc.write_text(text)
self.doc.start_bold()
if num_children == 1:
self.doc.write_text(_("Child of %s and %s is:") % (mother, father))
else: self.doc.write_text(_("Children of %s and %s are:") % (mother, father))
self.doc.end_bold()
self.doc.end_paragraph()
for child_handle in family.get_child_handle_list():
self.doc.start_paragraph("DAR-ChildList")
child = self.database.get_person_from_handle(child_handle)
name = child.get_primary_name().get_regular_name()
birth_handle = child.get_birth_handle()
death_handle = child.get_death_handle()
if self.childRef:
if self.prev_gen_hanldes.get(child_handle) != None:
name= "[" + str(self.prev_gen_hanldes.get(child_handle)) + "] "+ name
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle)
else:
birth = None
if death_handle:
death = self.database.get_event_from_handle(death_handle)
else:
death = None
if birth and birth.get_date():
if birth.get_place_handle():
bplace = self.database.get_place_from_handle(birth.get_place_handle()).get_title()
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s %s Died: %s %s") % \
(name, birth.get_date(), bplace,
death.get_date(), dplace)) # f
else:
self.doc.write_text(_("- %s Born: %s %s Died: %s") % \
(name, birth.get_date(), bplace,
death.get_date())) # e
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s %s Died: %s") % \
(name, birth.get_date(), bplace,
dplace)) # d
else:
self.doc.write_text(_("- %s Born: %s %s") % \
(name, birth.get_date(), bplace)) # c
else:
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s %s") % \
(name, birth.get_date(), death.get_date(), \
dplace)) # b
else:
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_date(), death.get_date())) # a
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_date(), dplace)) # 9
else:
self.doc.write_text(_("- %s Born: %s") % \
(name, birth.get_date())) # 8
else:
if birth and birth.get_place_handle():
bplace = self.database.get_place_from_handle(birth.get_place_handle()).get_title()
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s %s") % \
(name, bplace, \
death.get_date(), dplace)) # 7
else:
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, bplace, death.get_date())) # 6
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, bplace, dplace)) # 5
else:
self.doc.write_text(_("- %s Born: %s") % \
(name, bplace)) # 4
else:
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Died: %s %s") % \
(name, death.get_date(), dplace)) # 3
else:
self.doc.write_text(_("- %s Died: %s") % \
(name, death.get_date())) # 2
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Died: %s") % \
(name, dplace)) # 1
else:
self.doc.write_text(_("- %s") % name) # 0
self.doc.end_paragraph()
def write_mate(self, mate):
"""Output birth, death, parentage, marriage and notes information """
famList = mate.get_family_handle_list()
if len(famList) > 0:
for fam_id in famList:
fam = self.database.get_family_from_handle(fam_id)
person= ""
if mate.get_gender() == RelLib.Person.MALE:
if fam.get_mother_handle():
ind_id= fam.get_mother_handle()
ind = self.database.get_person_from_handle(ind_id)
person = ind.get_primary_name().get_regular_name()
firstName = ind.get_primary_name().get_first_name()
heshe = _("She")
else:
heshe= _("He")
if fam.get_father_handle():
ind_id = fam.get_father_handle()
ind = self.database.get_person_from_handle(ind_id)
person = ind.get_primary_name().get_regular_name()
firstName = ind.get_primary_name().get_first_name()
for family_handle in mate.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
person_name = ""
ind_handle = None
if mate.get_gender() == RelLib.Person.MALE:
ind_handle = family.get_mother_handle()
heshe = _("She")
else:
heshe = _("He")
ind_handle = family.get_father_handle()
if ind_handle:
ind = self.database.get_person_from_handle(ind_handle)
person_name = _nd.display(ind)
firstName = ind.get_primary_name().get_first_name()
if person:
if self.addImages:
ReportUtils.insert_images(self.database,self.doc,ind)
if person_name:
if self.addImages:
ReportUtils.insert_images(self.database,self.doc,ind)
self.doc.start_paragraph("DAR-Entry")
self.doc.start_paragraph("DAR-Entry")
if not self.firstName:
firstName = heshe
if not self.firstName:
firstName = heshe
self.doc.write_text(person)
self.doc.write_text(person_name)
text = ReportUtils.born_str(self.database,ind,"",
text = ReportUtils.born_str(self.database,ind,"",
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
age,units = self.calc_age(ind)
text = ReportUtils.died_str(self.database,ind,heshe,
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
if text:
self.doc.write_text(text)
text = ReportUtils.buried_str(self.database,ind,heshe,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
if text:
self.doc.write_text(text)
age,units = self.calc_age(ind)
text = ReportUtils.died_str(self.database,ind,heshe,
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
if text:
self.doc.write_text(text)
text = ReportUtils.buried_str(self.database,ind,heshe,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.write_parents(ind, firstName)
self.write_parents(ind, firstName)
self.doc.end_paragraph()
self.doc.end_paragraph()
if self.listChildren \
and mate.get_gender() == RelLib.Person.MALE:
self.write_children(family)
if self.listChildren \
and mate.get_gender() == RelLib.Person.MALE:
self.write_children(fam)
def calc_age(self, ind):
def calc_age(self,ind):
"""
Calulate age.
@ -498,43 +398,10 @@ class DetAncestorReport(Report.Report):
months: 2
days: 3
"""
age = 0
units = 0
if not self.calcAgeFlag:
return (age,units)
birth_handle = ind.get_birth_handle()
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle).get_date_object()
birth_year_valid = birth.get_year_valid()
if self.calcAgeFlag:
return ReportUtils.old_calc_age(self.database,ind)
else:
birth_year_valid = None
death_handle = ind.get_death_handle()
if death_handle:
death = self.database.get_event_from_handle(death_handle).get_date_object()
death_year_valid = death.get_year_valid()
else:
death_year_valid = None
if birth_year_valid and death_year_valid:
age = death.get_year() - birth.get_year()
units = 1 # year
if birth.get_month_valid() and death.get_month_valid():
if birth.get_month() > death.get_month():
age = age -1
if birth.get_day_valid() and death.get_day_valid():
if birth.get_month() == death.get_month() and birth.get_day() > death.get_day():
age = age -1
if age == 0:
age = death.get_month() - birth.get_month() # calc age in months
if birth.get_day() > death.get_day():
age = age - 1
units = 2 # month
if age == 0:
age = death.get-day() + 31 - birth.get_day() # calc age in days
units = 3 # day
return (age,units)
return (0,0)
#------------------------------------------------------------------------
#
@ -751,5 +618,3 @@ register_report(
author_name="Bruce DeGrasse",
author_email="bdegrasse1@attbi.com"
)

View File

@ -48,8 +48,17 @@ from QuestionDialog import ErrorDialog
import Report
import BaseDoc
import ReportOptions
import ReportUtils
import const
from DateHandler import displayer as _dd
from NameDisplay import displayer as _nd
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
EMPTY_ENTRY = "_____________"
#------------------------------------------------------------------------
#
@ -102,19 +111,29 @@ class DetDescendantReport(Report.Report):
self.childRef = options_class.handler.options_dict['desref']
self.addImages = options_class.handler.options_dict['incphotos']
self.genIDs = {}
self.prevGenIDs= {}
self.genKeys = []
self.gen_handles = {}
self.prev_gen_handles= {}
self.gen_keys = []
if self.blankDate:
self.EMPTY_DATE = EMPTY_ENTRY
else:
self.EMPTY_DATE = ""
if self.blankPlace:
self.EMPTY_PLACE = EMPTY_ENTRY
else:
self.EMPTY_PLACE = ""
def apply_filter(self,person_handle,index,cur_gen=1):
if (not person_handle) or (cur_gen > self.max_generations):
return
self.map[index] = person_handle
if len(self.genKeys) < cur_gen:
self.genKeys.append([index])
if len(self.gen_keys) < cur_gen:
self.gen_keys.append([index])
else:
self.genKeys[cur_gen-1].append(index)
self.gen_keys[cur_gen-1].append(index)
person = self.database.get_person_from_handle(person_handle)
for family_handle in person.get_family_handle_list():
@ -124,200 +143,60 @@ class DetDescendantReport(Report.Report):
ix = max(self.map.keys())
self.apply_filter(child_handle, ix+1, cur_gen+1)
def calcAge(self, ind):
""" Calulate age
APHRASE=
at the age of NUMBER UNIT(S)
UNIT= year | month | day
UNITS= years | months | days
null
"""
def write_report(self):
self.apply_filter(self.start_person.get_handle(),1)
birth_handle = ind.get_birth_handle()
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle).get_date_object()
birth_year_valid = birth.get_year_valid()
else:
birth_year_valid = None
death_handle = ind.get_death_handle()
if death_handle:
death = self.database.get_event_from_handle(death_handle).get_date_object()
death_year_valid = death.get_year_valid()
else:
death_year_valid = None
name = self.start_person.get_primary_name().get_regular_name()
the_text = ""
if birth_year_valid and death_year_valid:
age = death.get_year() - birth.get_year()
units = 3 # year
if birth.get_month_valid() and death.get_month_valid():
if birth.get_month() > death.get_month():
age = age -1
if birth.get_day_valid() and death.get_day_valid():
if birth.get_month() == death.get_month() and birth.get_day() > death.get_day():
age = age -1
if age == 0:
age = death.get_month() - birth.get_month() # calc age in months
if birth.get_day() > death.get_day():
age = age - 1
units = 2 # month
if age == 0:
age = death.get-day() + 31 - birth.get_day() # calc age in days
units = 1 # day
if age > 1:
if units == 1:
the_text = _(" at the age of %d days") % age
elif units == 2:
the_text = _(" at the age of %d months") % age
else:
the_text = _(" at the age of %d years") % age
spouseName = ""
for family_handle in self.start_person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
if self.start_person.get_gender() == RelLib.Person.MALE:
spouse_handle = family.get_mother_handle()
else:
if units == 1:
the_text = _(" at the age of %d day") % age
elif units == 2:
the_text = _(" at the age of %d month") % age
else:
the_text = _(" at the age of %d year") % age
return the_text
spouse_handle = family.get_father_handle()
if spouse_handle:
spouse = self.database.get_person_from_handle(spouse_handle)
spouseName = _nd.display(spouse)
def write_children(self, family):
""" List children
Statement formats:
Child of MOTHER and FATHER is:
Children of MOTHER and FATHER are:
self.doc.start_paragraph("DDR-Title")
if spouseName:
name = _("%(spouse_name)s and %(person_name)s") % {
'spouse_name' : spouseName, 'person_name' : name }
NAME Born: DATE PLACE Died: DATE PLACE f
NAME Born: DATE PLACE Died: DATE e
NAME Born: DATE PLACE Died: PLACE d
NAME Born: DATE PLACE c
NAME Born: DATE Died: DATE PLACE b
NAME Born: DATE Died: DATE a
NAME Born: DATE Died: PLACE 9
NAME Born: DATE 8
NAME Born: PLACE Died: DATE PLACE 7
NAME Born: PLACE Died: DATE 6
NAME Born: PLACE Died: PLACE 5
NAME Born: PLACE 4
NAME Died: DATE 2
NAME Died: DATE PLACE 3
NAME Died: PLACE 1
NAME 0
"""
title = _("Detailed Descendant Report for %(person_name)s") % {
'person_name' : name }
self.doc.write_text(title)
self.doc.end_paragraph()
num_children = len(family.get_child_handle_list())
if num_children:
self.doc.start_paragraph("DDR-ChildTitle")
mother_handle = family.get_mother_handle()
if mother_handle:
mother = self.database.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
else:
mother = _("unknown")
father_handle = family.get_father_handle()
if father_handle:
father = self.database.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
else:
father = _("unknown")
self.doc.start_bold()
if num_children == 1:
self.doc.write_text(_("Child of %s and %s is:") % (mother, father))
else:
self.doc.write_text(_("Children of %s and %s are:") % (mother, father))
self.doc.end_bold()
keys = self.map.keys()
keys.sort()
generation = 0
need_header = 1
for generation in xrange(len(self.gen_keys)):
if self.pgbrk and generation > 0:
self.doc.page_break()
self.doc.start_paragraph("DDR-Generation")
text = self.gen.get(generation+1,
_("Generation %(generation_number)d") % {
'generation_number' : generation })
self.doc.write_text(text)
self.doc.end_paragraph()
if self.childRef:
self.prev_gen_handles = self.gen_handles.copy()
self.gen_handles.clear()
for child_handle in family.get_child_handle_list():
child = self.database.get_person_from_handle(child_handle)
self.doc.start_paragraph("DDR-ChildList")
name = child.get_primary_name().get_regular_name()
birth_handle = child.get_birth_handle()
death_handle = child.get_death_handle()
if self.childRef:
if self.prevGenIDs.get(child_handle) != None:
name= "[" + str(self.prevGenIDs.get(child_handle)) + "] "+ name
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle)
else:
birth = None
if death_handle:
death = self.database.get_event_from_handle(death_handle)
else:
death = None
if birth and birth.get_date():
if birth.get_place_handle():
bplace = self.database.get_place_from_handle(birth.get_place_handle()).get_title()
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s %s Died: %s %s") % \
(name, birth.get_date(), bplace,
death.get_date(), dplace)) # f
else:
self.doc.write_text(_("- %s Born: %s %s Died: %s") % \
(name, birth.get_date(), bplace,
death.get_date())) # e
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s %s Died: %s") % \
(name, birth.get_date(), bplace,
dplace)) # d
else: self.doc.write_text(_("- %s Born: %s %s") % \
(name, birth.get_date(), bplace)) # c
else:
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s %s") % \
(name, birth.get_date(), death.get_date(), \
dplace)) # b
else:
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_date(), death.get_date())) # a
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, birth.get_date(), dplace)) # 9
else:
self.doc.write_text(_("- %s Born: %s") % \
(name, birth.get_date())) # 8
else:
if birth and birth.get_place_handle():
bplace = self.database.get_place_from_handle(birth.get_place_handle()).get_title()
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s %s") % \
(name, bplace, \
death.get_date(), dplace)) # 7
else:
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, bplace, death.get_date())) # 6
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Born: %s Died: %s") % \
(name, bplace, dplace)) # 5
else:
self.doc.write_text(_("- %s Born: %s") % \
(name, bplace)) # 4
else:
if death and death.get_date():
if death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Died: %s %s") % \
(name, death.get_date(), dplace)) # 3
else:
self.doc.write_text(_("- %s Died: %s") % \
(name, death.get_date())) # 2
elif death and death.get_place_handle():
dplace = self.database.get_place_from_handle(death.get_place_handle()).get_title()
self.doc.write_text(_("- %s Died: %s") % \
(name, dplace)) # 1
else:
self.doc.write_text(_("- %s") % name) # 0
self.doc.end_paragraph()
for key in self.gen_keys[generation]:
person_handle = self.map[key]
person = self.database.get_person_from_handle(person_handle)
self.gen_handles[person_handle] = key
dupPerson = self.write_person(key)
if dupPerson == 0: # Is this a duplicate ind record
if self.listChildren:
for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
self.write_children(family)
def write_person(self, key):
"""Output birth, death, parentage, marriage and notes information """
@ -325,11 +204,11 @@ class DetDescendantReport(Report.Report):
person_handle = self.map[key]
person = self.database.get_person_from_handle(person_handle)
if self.addImages:
self.insert_images(person)
ReportUtils.insert_images(self.database,self.doc,person)
self.doc.start_paragraph("DDR-First-Entry","%s." % str(key))
name = person.get_primary_name().get_regular_name()
name = _nd.display(person)
if self.firstName:
firstName = person.get_primary_name().get_first_name()
@ -357,8 +236,22 @@ class DetDescendantReport(Report.Report):
# Check birth record
birth_handle = person.get_birth_handle()
if birth_handle:
self.write_birth(person)
self.write_death(person, firstName)
text = ReportUtils.born_str(self.database,person,"",
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
if person.get_death_handle():
age,units = self.calc_age(person)
text = ReportUtils.died_str(self.database,person,firstName,
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
if text:
self.doc.write_text(text)
text = ReportUtils.buried_str(self.database,person,firstName,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.write_parents(person, firstName)
self.write_marriage(person)
self.doc.end_paragraph()
@ -375,417 +268,163 @@ class DetDescendantReport(Report.Report):
return 0 # Not duplicate person
def write_birth(self, person):
""" Check birth record
Statement formats name precedes this
was born on DATE.
was born on ________.
was born on Date in Place.
was born on ________ in PLACE.
was born in ____________.
was born in the year YEAR.
was born in PLACE.
was born in ____________.
"""
birth_handle = person.get_birth_handle()
if birth_handle:
birth = self.database.get_event_from_handle(birth_handle)
date_obj = birth.get_date_object()
date_txt = birth.get_date()
if birth.get_place_handle():
place = self.database.get_place_from_handle(birth.get_place_handle()).get_title()
if place[-1:] == '.':
place = place[:-1]
elif self.blankDate:
place = "______________"
else:
place = ""
if date_txt:
if date_obj.get_day_valid() and date_obj.get_month_valid() and \
self.fullDate:
if place:
self.doc.write_text(_(" was born on %s in %s.") % (date_txt, place))
else:
self.doc.write_text(_(" was born on %s.") % date_txt )
elif place:
self.doc.write_text(_(" was born in the year %s in %s.") % \
(date_obj.get_year(), place))
else:
self.doc.write_text(_(" was born in the year %s.") % date_obj.get_year())
elif place:
self.doc.write_text(_(" was born in %s.") % place)
else:
self.doc.write_text(_("."))
def write_death(self, person, firstName):
""" Write obit sentence
Statement format: DPHRASE APHRASE BPHRASE
DPHRASE=
FIRSTNAME died on FULLDATE in PLACE
FIRSTNAME died on FULLDATE
FIRSTNAME died in PLACE
FIRSTNAME died on FULLDATE in PLACE
FIRSTNAME died in YEAR in PLACE
FIRSTNAME died in YEAR
APHRASE= see calcAge
at the age of NUMBER UNIT(S)
null
where
UNIT= year | month | day
UNITS= years | months | days
BPHRASE=
, and was buried on FULLDATE in PLACE.
, and was buried on FULLDATE.
, and was buried in PLACE.
.
"""
t1 = ""
death_handle = person.get_death_handle()
if death_handle:
death = self.database.get_event_from_handle(death_handle)
date_obj = death.get_date_object()
date_txt = death.get_date()
place_handle = death.get_place_handle()
if place_handle:
place = self.database.get_place_from_handle(place_handle).get_title()
if place[-1:] == '.':
place = place[:-1]
elif self.blankPlace:
place = "_____________"
else:
place = ""
if date_txt:
if date_obj.get_day() and date_obj.get_month() and \
self.fullDate:
fulldate = date_txt
elif date_obj.get_month() and self.fullDate:
fulldate = "%s %s" % (date_obj.get_month(), date_obj.get_year())
else:
fulldate = ""
elif self.blankDate:
fulldate = "_____________"
else:
fulldate = ""
if fulldate:
if place:
t1 = _(" %s died on %s in %s") % (firstName, fulldate, place)
else:
t1 = _(" %s died on %s") % (firstName, fulldate)
elif date_obj.get_year() > 0:
if place:
t1 = _(" %s died in %s in %s") % (firstName, date_obj.get_year(), place)
else:
t1 = _(" %s died in %s") % (firstName, date_obj.get_year())
elif place:
t1 = _(" %s died in %s") % (firstName, place)
if self.calcAgeFlag:
t1 = t1 + self.calcAge(person)
t2 = ""
event_list = person.get_event_list()
for event_handle in event_list:
if event_handle:
event = self.database.get_event_from_handle(event_handle)
if event.get_name() == "Burial":
burial = event
break
else:
burial = None
if burial:
place = ""
if burial.get_place_handle():
place = self.database.get_place_from_handle(burial.get_place_handle())
elif self.blankPlace:
place = "____________"
if place[-1:] == '.':
place = place[:-1]
fulldate = ""
date_obj = burial.get_date_object()
if date_obj:
if date_obj.get_day_valid() and date_obj.get_month_valid() and \
self.fullDate:
fulldate = burial.get_date()
elif self.blankDate:
fulldate= "___________"
if fulldate and place:
t2 = _(" and %s was buried on %s in %s") % (firstName, fulldate, place)
elif fulldate and not place:
t2 = _(" and %s was buried on %s") % (firstName, fulldate)
elif not fulldate and place:
t2 = _(" and %s was buried in %s") % (firstName, place)
t = t1 + t2
if t:
self.doc.write_text(t)
self.doc.write_text(".")
def write_parents(self, person, firstName):
""" Ouptut parents sentence
Statement format:
""" Ouptut parents sentence"""
FIRSTNAME is the son of FATHER and MOTHER.
FIRSTNAME is the son of FATHER.
FIRSTNAME is the son of MOTHER.
FIRSTNAME is the daughter of FATHER and MOTHER.
FIRSTNAME is the daughter of FATHER.
FIRSTNAME is the daughter of MOTHER.
"""
ext_family_handle = person.get_main_parents_family_handle()
if ext_family_handle:
ext_family = self.database.get_family_from_handle(ext_family_handle)
father_handle = ext_family.get_father_handle()
if father_handle:
father = self.database.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
else:
father = ""
mother_handle = ext_family.get_father_handle()
family_handle = person.get_main_parents_family_handle()
if family_handle:
family = self.database.get_family_from_handle(family_handle)
mother_handle = family.get_mother_handle()
father_handle = family.get_father_handle()
if mother_handle:
mother = self.database.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
mother = self.database.get_person_from_handle(mother_handle)
mother_name = mother.get_primary_name().get_regular_name()
else:
mother = ""
if father or mother:
if person.get_gender() == RelLib.Person.MALE:
if father:
if mother:
self.doc.write_text(_(" %s is the son of %s and %s.") % \
(firstName, father, mother))
else:
self.doc.write_text(_(" %s is the son of %s.") % \
(firstName, father))
else:
self.doc.write_text(_(" %s is the son of %s.") % \
(firstName, mother))
else:
if father:
if mother:
self.doc.write_text(_(" %s is the daughter of %s and %s.") % \
(firstName, father, mother))
else:
self.doc.write_text(_(" %s is the daughter of %s.") % \
(firstName, father))
else:
self.doc.write_text(_(" %s is the daughter of %s.") % \
(firstName, mother))
mother_name = ""
if father_handle:
father = self.database.get_person_from_handle(father_handle)
father_name = father.get_primary_name().get_regular_name()
else:
father_name = ""
text = ReportUtils.child_str(person,firstName,
father_name,mother_name,
bool(person.get_death_handle()))
if text:
self.doc.write_text(text)
def write_marriage(self, person):
""" Output marriage sentence
HE/SHE married SPOUSE on FULLDATE in PLACE.
HE/SHE married SPOUSE on FULLDATE.
HE/SHE married SPOUSE in PLACE.
HE/SHE married SPOUSE
""" Output marriage sentence"""
is_first = True
for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
spouse_handle = ReportUtils.find_spouse(person,family)
spouse = self.database.get_person_from_handle(spouse_handle)
marriage_event = ReportUtils.find_marriage(self.database,family)
text = ""
if marriage_event:
text = ReportUtils.married_str(self.database,person,spouse,
marriage_event,None,
self.EMPTY_DATE,self.EMPTY_PLACE,
is_first)
else:
text = ReportUtils.married_rel_str(self.database,person,family,
is_first)
if text:
self.doc.write_text(text)
is_first = False
def write_children(self, family):
""" List children.
"""
famList = person.get_family_handle_list()
for fam_num in range(len(famList)):
fam_id = famList[fam_num]
fam = self.database.get_family_from_handle(fam_id)
spouse = ""
t = ""
if person.get_gender() == RelLib.Person.MALE:
mother_handle = fam.get_mother_handle()
if mother_handle:
spouse = self.database.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
if fam_num == 0:
heshe = _(" He")
elif fam_num < len(famList)-1:
heshe = _(",")
else:
heshe = _(" and he")
else:
if fam_num == 0:
heshe = _(" She")
elif fam_num < len(famList)-1:
heshe = _(",")
else:
heshe = _(" and she")
father_handle = fam.get_father_handle()
if father_handle:
spouse = self.database.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
if not family.get_child_handle_list():
return
for event_handle in fam.get_event_list():
if event_handle:
event = self.database.get_event_from_handle(event_handle)
if event.get_name() == "Marriage":
marriage = event
break
else:
marriage = None
mother_handle = family.get_mother_handle()
if mother_handle:
mother = self.database.get_person_from_handle(mother_handle)
mother_name = _nd.display(mother)
else:
mother_name = _("unknown")
fulldate = ""
place = ""
if marriage:
if marriage.get_place_handle():
place = self.database.get_place_from_handle(marriage.get_place_handle()).get_title()
elif self.blankPlace:
place = "____________"
father_handle = family.get_father_handle()
if father_handle:
father = self.database.get_person_from_handle(father_handle)
father_name = _nd.display(father)
else:
father_name = _("unknown")
date_obj = marriage.get_date_object()
if date_obj:
if date_obj.get_year_valid():
if date_obj.get_day_valid() and date_obj.get_month_valid() and \
self.fullDate:
fulldate = marriage.get_date()
elif self.blankDate:
fulldate = "__________"
self.doc.start_paragraph("DDR-ChildTitle")
self.doc.start_bold()
self.doc.write_text(_("Children of %s and %s are:") %
(mother_name,father_name))
self.doc.end_bold()
self.doc.end_paragraph()
if fam.get_relationship() == RelLib.Family.MARRIED:
if spouse:
if not fulldate and not place:
t = _("%s married %s") % (heshe, spouse)
elif not fulldate and place:
t = _("%s married %s in %s") % (heshe, spouse, place)
elif fulldate and not place:
t = _("%s married %s on %s") % (heshe, spouse, fulldate)
else:
t = _("%s married %s on %s in %s") % \
(heshe, spouse, fulldate, place)
else:
if not fulldate and not place:
t = _("%s married") % heshe
elif not fulldate and place:
t = _("%s married in %s") % (heshe, place)
elif fulldate and not place:
t = _("%s married on %s") % (heshe, fulldate)
else:
t = _("%s married on %s in %s") % \
(heshe, fulldate, place)
else: # Not a marriage
if spouse != "":
t = _("%s had a relationship with %s") % (heshe, spouse)
else:
t = _("%s had a relationship with") % heshe
for child_handle in family.get_child_handle_list():
self.doc.start_paragraph("DDR-ChildList")
child = self.database.get_person_from_handle(child_handle)
child_name = _nd.display(child)
if t != "":
self.doc.write_text(t)
if fam_num == len(famList)-1:
self.doc.write_text(".")
if self.childRef and self.prev_gen_handles.get(child_handle):
child_name = "[%s] %s" % (
str(self.prev_gen_handles.get(child_handle)),
child_name)
def write_mate(self, person):
text = ReportUtils.list_person_str(self.database,child,child_name)
self.doc.write_text(text)
self.doc.end_paragraph()
def write_mate(self, mate):
"""Output birth, death, parentage, marriage and notes information """
for fam_id in person.get_family_handle_list():
fam = self.database.get_family_from_handle(fam_id)
mate = ""
if person.get_gender() == RelLib.Person.MALE:
for family_handle in mate.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
person_name = ""
ind_handle = None
if mate.get_gender() == RelLib.Person.MALE:
ind_handle = family.get_mother_handle()
heshe = _("She")
mother_handle = fam.get_mother_handle()
if mother_handle:
mate = self.database.get_person_from_handle(mother_handle)
mateName = mate.get_primary_name().get_regular_name()
mateFirstName = mate.get_primary_name().get_first_name()
else:
heshe = _("He")
father_handle = fam.get_father_handle()
if father_handle:
mate = self.database.get_person_from_handle(father_handle)
mateName = mate.get_primary_name().get_regular_name()
mateFirstName = mate.get_primary_name().get_first_name()
ind_handle = family.get_father_handle()
if ind_handle:
ind = self.database.get_person_from_handle(ind_handle)
person_name = _nd.display(ind)
firstName = ind.get_primary_name().get_first_name()
if mate:
if person_name:
if self.addImages:
self.insert_images(mate)
ReportUtils.insert_images(self.database,self.doc,ind)
self.doc.start_paragraph("DDR-Entry")
if not self.firstName:
mateFirstName = heshe
firstName = heshe
self.doc.write_text(person_name)
text = ReportUtils.born_str(self.database,ind,"",
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
age,units = self.calc_age(ind)
text = ReportUtils.died_str(self.database,ind,heshe,
self.EMPTY_DATE,self.EMPTY_PLACE,age,units)
if text:
self.doc.write_text(text)
text = ReportUtils.buried_str(self.database,ind,heshe,
self.EMPTY_DATE,self.EMPTY_PLACE)
if text:
self.doc.write_text(text)
self.write_parents(ind, firstName)
self.doc.write_text(mateName)
self.write_birth(mate)
self.write_death(mate, mateFirstName)
self.write_parents(mate, mateFirstName)
self.doc.end_paragraph()
if self.listChildren \
and mate.get_gender() == RelLib.Person.MALE:
self.write_children(family)
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def insert_images(self, person):
photos = person.get_media_list()
for photo in photos :
object_handle = photo.get_reference_handle()
object = self.database.get_object_from_handle(object_handle)
if object.get_mime_type()[0:5] == "image":
file = object.get_path()
self.doc.add_media_object(file,"row",4.0,4.0)
#--------------------------------------------------------------------
#
#
#
#--------------------------------------------------------------------
def write_report(self):
self.cur_gen= 1
self.apply_filter(self.start_person.get_handle(),1)
name = self.start_person.get_primary_name().get_regular_name()
famList = self.start_person.get_family_handle_list()
spouseName= ""
if len(famList):
for fam_id in famList:
fam = self.database.get_family_from_handle(fam_id)
if self.start_person.get_gender() == RelLib.Person.MALE:
mother_handle = fam.get_mother_handle()
if mother_handle:
spouseName = self.database.get_person_from_handle(mother_handle).get_primary_name().get_first_name()
else:
father_handle = fam.get_father_handle()
if father_handle:
spouseName = self.database.get_person_from_handle(father_handle).get_primary_name().get_first_name()
self.doc.start_paragraph("DDR-Title")
if spouseName:
name = spouseName + _(" and ") + name
title = _("Detailed Descendant Report for %s") % name
self.doc.write_text(title)
self.doc.end_paragraph()
keys = self.map.keys()
keys.sort()
generation = 0
need_header = 1
for generation in xrange(len(self.genKeys)):
if self.pgbrk and generation > 0:
self.doc.page_break()
self.doc.start_paragraph("DDR-Generation")
t = _("%s Generation") % DetDescendantReport.gen[generation+1]
self.doc.write_text(t)
self.doc.end_paragraph()
if self.childRef:
self.prevGenIDs= self.genIDs.copy()
self.genIDs.clear()
for key in self.genKeys[generation]:
person_handle = self.map[key]
person = self.database.get_person_from_handle(person_handle)
self.genIDs[person_handle]= key
dupPerson= self.write_person(key)
if dupPerson == 0: # Is this a duplicate ind record
if self.listChildren:
for family_handle in person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
self.write_children(family)
def calc_age(self,ind):
"""
Calulate age.
Returns a tuple (age,units) where units is an integer representing
time units:
no age info: 0
years: 1
months: 2
days: 3
"""
if self.calcAgeFlag:
return ReportUtils.old_calc_age(self.database,ind)
else:
return (0,0)
#------------------------------------------------------------------------
#