* 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> 2005-01-02 Guillaume Pratte <guillaumep@soireevideo.org>
* src/po/fr.po : Update from the STABLE branch. * src/po/fr.po : Update from the STABLE branch.

View File

@ -185,21 +185,21 @@ class Report:
# Ordinal generation names. Used by multiple reports. # Ordinal generation names. Used by multiple reports.
gen = { gen = {
1 : _("First"), 2 : _("Second"), 1 : _("First Generation"), 2 : _("Second Generation"),
3 : _("Third"), 4 : _("Fourth"), 3 : _("Third Generation"), 4 : _("Fourth Generation"),
5 : _("Fifth"), 6 : _("Sixth"), 5 : _("Fifth Generation"), 6 : _("Sixth Generation"),
7 : _("Seventh"), 8 : _("Eighth"), 7 : _("Seventh Generation"), 8 : _("Eighth Generation"),
9 : _("Ninth"), 10: _("Tenth"), 9 : _("Ninth Generation"), 10: _("Tenth Generation"),
11: _("Eleventh"), 12: _("Twelfth"), 11: _("Eleventh Generation"), 12: _("Twelfth Generation"),
13: _("Thirteenth"), 14: _("Fourteenth"), 13: _("Thirteenth Generation"), 14: _("Fourteenth Generation"),
15: _("Fifteenth"), 16: _("Sixteenth"), 15: _("Fifteenth Generation"), 16: _("Sixteenth Generation"),
17: _("Seventeenth"), 18: _("Eighteenth"), 17: _("Seventeenth Generation"), 18: _("Eighteenth Generation"),
19: _("Nineteenth"), 20: _("Twentieth"), 19: _("Nineteenth Generation"), 20: _("Twentieth Generation"),
21: _("Twenty-first"), 22: _("Twenty-second"), 21: _("Twenty-first Generation"), 22: _("Twenty-second Generation"),
23: _("Twenty-third"), 24: _("Twenty-fourth"), 23: _("Twenty-third Generation"), 24: _("Twenty-fourth Generation"),
25: _("Twenty-fifth"), 26: _("Twenty-sixth"), 25: _("Twenty-fifth Generation"), 26: _("Twenty-sixth Generation"),
27: _("Twenty-seventh"), 28: _("Twenty-eighth"), 27: _("Twenty-seventh Generation"), 28: _("Twenty-eighth Generation"),
29: _("Twenty-ninth") 29: _("Twenty-ninth Generation")
} }
def __init__(self, database, person, options_class): 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: else:
person_name = _('She') 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 person.get_gender() == RelLib.Person.MALE:
if bdate: if bdate:
@ -1233,14 +1234,14 @@ def died_str(database,person,person_name=None,empty_date="",empty_place="",
'age' : age } 'age' : age }
else: else:
if not age_units: #male, no date, no place, no age if not age_units: #male, no date, no place, no age
text = _("%(male_name)s died.") % { pass #text = _("%(male_name)s died.") % {
'male_name' : person_name } #'male_name' : person_name }
elif age_units == 1: #male, no date, no place, years elif age_units == 1: #male, no date, no place, years
text = _("%(male_name)s died " text = _("%(male_name)s died "
"at the age of %(age)d years.") % { "at the age of %(age)d years.") % {
'male_name' : person_name, 'age' : age } 'male_name' : person_name, 'age' : age }
elif age_units == 2: #male, no date, no place, months 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.") % { "at the age of %(age)d months.") % {
'male_name' : person_name, 'age' : age } 'male_name' : person_name, 'age' : age }
elif age_units == 3: #male, no date, no place, days 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 } 'age' : age }
else: else:
if not age_units: #female, no date, no place, no age if not age_units: #female, no date, no place, no age
text = _("%(female_name)s died.") % { pass #text = _("%(female_name)s died.") % {
'female_name' : person_name } #'female_name' : person_name }
elif age_units == 1: #female, no date, no place, years elif age_units == 1: #female, no date, no place, years
text = _("%(female_name)s died " text = _("%(female_name)s died "
"at the age of %(age)d years.") % { "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 + " " text = text + " "
return 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 = { _rtype = {
RelLib.Family.MARRIED : _("Married"), RelLib.Family.MARRIED : _("Married"),
RelLib.Family.UNMARRIED : _("Unmarried"), RelLib.Family.UNMARRIED : _("Unmarried"),
@ -1492,3 +1715,53 @@ _rtype = {
def relationship_name(rtype): def relationship_name(rtype):
return _rtype.get(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 DateHandler import displayer as _dd
from NameDisplay import displayer as _nd from NameDisplay import displayer as _nd
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
EMPTY_ENTRY = "_____________" EMPTY_ENTRY = "_____________"
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# #
@ -104,7 +110,7 @@ class DetAncestorReport(Report.Report):
self.addImages = options_class.handler.options_dict['incphotos'] self.addImages = options_class.handler.options_dict['incphotos']
self.gen_handles = {} self.gen_handles = {}
self.prev_gen_hanldes= {} self.prev_gen_handles= {}
if self.blankDate: if self.blankDate:
self.EMPTY_DATE = EMPTY_ENTRY self.EMPTY_DATE = EMPTY_ENTRY
@ -152,12 +158,12 @@ class DetAncestorReport(Report.Report):
self.doc.end_paragraph() self.doc.end_paragraph()
generation = generation + 1 generation = generation + 1
if self.childRef: if self.childRef:
self.prev_gen_hanldes= self.gen_handles.copy() self.prev_gen_handles= self.gen_handles.copy()
self.gen_handles.clear() self.gen_handles.clear()
person_handle = self.map[key] person_handle = self.map[key]
person = self.database.get_person_from_handle(person_handle) 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) dupPerson = self.write_person(key)
if dupPerson == 0: # Is this a duplicate ind record if dupPerson == 0: # Is this a duplicate ind record
if person.get_gender() == RelLib.Person.FEMALE and \ if person.get_gender() == RelLib.Person.FEMALE and \
@ -286,208 +292,102 @@ class DetAncestorReport(Report.Report):
is_first = False is_first = False
def write_children(self, family): def write_children(self, family):
""" List children """ 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
""" """
num_children = len(family.get_child_handle_list()) if not family.get_child_handle_list():
if num_children > 0: return
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")
father_handle = family.get_father_handle() mother_handle = family.get_mother_handle()
if father_handle: if mother_handle:
father_obj = self.database.get_person_from_handle(father_handle) mother = self.database.get_person_from_handle(mother_handle)
father = father_obj.get_primary_name().get_regular_name() mother_name = _nd.display(mother)
else: else:
father = _("unknown") 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() 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): def write_mate(self, mate):
"""Output birth, death, parentage, marriage and notes information """ """Output birth, death, parentage, marriage and notes information """
famList = mate.get_family_handle_list() for family_handle in mate.get_family_handle_list():
if len(famList) > 0: family = self.database.get_family_from_handle(family_handle)
for fam_id in famList: person_name = ""
fam = self.database.get_family_from_handle(fam_id) ind_handle = None
person= "" if mate.get_gender() == RelLib.Person.MALE:
if mate.get_gender() == RelLib.Person.MALE: ind_handle = family.get_mother_handle()
if fam.get_mother_handle(): heshe = _("She")
ind_id= fam.get_mother_handle() else:
ind = self.database.get_person_from_handle(ind_id) heshe = _("He")
person = ind.get_primary_name().get_regular_name() ind_handle = family.get_father_handle()
firstName = ind.get_primary_name().get_first_name() if ind_handle:
heshe = _("She") ind = self.database.get_person_from_handle(ind_handle)
else: person_name = _nd.display(ind)
heshe= _("He") firstName = ind.get_primary_name().get_first_name()
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()
if person: if person_name:
if self.addImages: if self.addImages:
ReportUtils.insert_images(self.database,self.doc,ind) ReportUtils.insert_images(self.database,self.doc,ind)
self.doc.start_paragraph("DAR-Entry") self.doc.start_paragraph("DAR-Entry")
if not self.firstName: if not self.firstName:
firstName = heshe 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) self.EMPTY_DATE,self.EMPTY_PLACE)
if text: if text:
self.doc.write_text(text) self.doc.write_text(text)
age,units = self.calc_age(ind) self.write_parents(ind, firstName)
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.end_paragraph()
self.doc.end_paragraph() if self.listChildren \
and mate.get_gender() == RelLib.Person.MALE:
self.write_children(family)
if self.listChildren \ def calc_age(self,ind):
and mate.get_gender() == RelLib.Person.MALE:
self.write_children(fam)
def calc_age(self, ind):
""" """
Calulate age. Calulate age.
@ -498,43 +398,10 @@ class DetAncestorReport(Report.Report):
months: 2 months: 2
days: 3 days: 3
""" """
if self.calcAgeFlag:
age = 0 return ReportUtils.old_calc_age(self.database,ind)
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()
else: else:
birth_year_valid = None return (0,0)
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)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -751,5 +618,3 @@ register_report(
author_name="Bruce DeGrasse", author_name="Bruce DeGrasse",
author_email="bdegrasse1@attbi.com" author_email="bdegrasse1@attbi.com"
) )

View File

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