From 8330e8dad0833aaa077a3d9e62e2792b99e274f8 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 14 Nov 2006 04:39:55 +0000 Subject: [PATCH] * src/plugins/DetAncestralReport.py: Add family Events * src/plugins/DetDescendantReport.py: Add family Events svn: r7625 --- ChangeLog | 4 + src/plugins/DetAncestralReport.py | 120 +++++++++++++++++++---------- src/plugins/DetDescendantReport.py | 108 ++++++++++++++++++-------- 3 files changed, 157 insertions(+), 75 deletions(-) diff --git a/ChangeLog b/ChangeLog index a76764281..ba75cbfec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-11-13 Brian Matherly + * src/plugins/DetAncestralReport.py: Add family Events + * src/plugins/DetDescendantReport.py: Add family Events + 2006-11-13 Don Allingham * src/Editors/_EditFamily.py: fix FAM_WIDTH diff --git a/src/plugins/DetAncestralReport.py b/src/plugins/DetAncestralReport.py index 9647087d4..37a481ddc 100644 --- a/src/plugins/DetAncestralReport.py +++ b/src/plugins/DetAncestralReport.py @@ -177,14 +177,16 @@ class DetAncestorReport(Report): self.gen_handles[person_handle] = key dupPerson = self.write_person(key) if dupPerson == 0: # Is this a duplicate ind record - if self.listChildren: + if self.listChildren or self.includeEvents: for family_handle in person.get_family_handle_list(): family = self.database.get_family_from_handle(family_handle) mother_handle = family.get_mother_handle() if mother_handle == None or \ person.get_gender() == RelLib.Person.FEMALE: - self.write_children(family) - + if self.listChildren: + self.write_children(family) + if self.includeEvents: + self.write_family_events(family) if self.includeSources: self.write_endnotes() @@ -298,13 +300,6 @@ class DetAncestorReport(Report): for event_ref in person.get_event_ref_list(): if event_ref == birth_ref or event_ref == death_ref: continue - event = self.database.get_event_from_handle(event_ref.ref) - date = DateHandler.get_date(event) - ph = event.get_place_handle() - if ph: - place = self.database.get_place_from_handle(ph).get_title() - else: - place = u'' if first: self.doc.start_paragraph('DAR-MoreHeader') @@ -312,38 +307,48 @@ class DetAncestorReport(Report): 'person_name' : _nd.display(person) }) self.doc.end_paragraph() first = 0 - - - self.doc.start_paragraph('DAR-MoreDetails') - evtName = str( event.get_type() ) - if date and place: - self.doc.write_text( - _('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % { - 'event_name' : _(evtName), - 'date' : date, - 'endnotes' : self.endnotes(event), - 'place' : place }) - elif date: - self.doc.write_text( - _('%(event_name)s: %(date)s%(endnotes)s. ') % { - 'event_name' : _(evtName), - 'endnotes' : self.endnotes(event), - 'date' : date}) - elif place: - self.doc.write_text( - _('%(event_name)s: %(place)s%(endnotes)s. ') % { - 'event_name' : _(evtName), - 'endnotes' : self.endnotes(event), - 'place' : place }) - else: - self.doc.write_text(_('%(event_name)s: ') % { - 'event_name' : _(evtName)}) - if event.get_description(): - self.doc.write_text(event.get_description()) - self.doc.end_paragraph() + + self.write_event(event_ref) return 0 # Not duplicate person + + def write_event(self, event_ref): + event = self.database.get_event_from_handle(event_ref.ref) + date = DateHandler.get_date(event) + ph = event.get_place_handle() + if ph: + place = self.database.get_place_from_handle(ph).get_title() + else: + place = u'' + self.doc.start_paragraph('DAR-MoreDetails') + evtName = str( event.get_type() ) + if date and place: + self.doc.write_text( + _('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % { + 'event_name' : _(evtName), + 'date' : date, + 'endnotes' : self.endnotes(event), + 'place' : place }) + elif date: + self.doc.write_text( + _('%(event_name)s: %(date)s%(endnotes)s. ') % { + 'event_name' : _(evtName), + 'endnotes' : self.endnotes(event), + 'date' : date}) + elif place: + self.doc.write_text( + _('%(event_name)s: %(place)s%(endnotes)s. ') % { + 'event_name' : _(evtName), + 'endnotes' : self.endnotes(event), + 'place' : place }) + else: + self.doc.write_text(_('%(event_name)s: ') % { + 'event_name' : _(evtName)}) + if event.get_description(): + self.doc.write_text(event.get_description()) + self.doc.end_paragraph() + def write_parents(self, person, firstName): family_handle = person.get_main_parents_family_handle() if family_handle: @@ -447,6 +452,37 @@ class DetAncestorReport(Report): self.doc.end_paragraph() + def write_family_events(self,family): + + if not family.get_event_ref_list(): + return + + 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") + + first = 1 + for event_ref in family.get_event_ref_list(): + if first: + self.doc.start_paragraph('DAR-MoreHeader') + self.doc.write_text( + _('More about %(mother_name)s and %(father_name)s:') % { + 'mother_name' : mother_name, + 'father_name' : father_name }) + self.doc.end_paragraph() + first = 0 + self.write_event(event_ref) + def write_mate(self, mate): """Output birth, death, parentage, marriage and notes information """ @@ -516,9 +552,11 @@ class DetAncestorReport(Report): self.doc.end_paragraph() - if person_name: - if self.listChildren and mate.get_gender()==RelLib.Person.MALE: + if person_name and mate.get_gender()==RelLib.Person.MALE: + if self.listChildren: self.write_children(family) + if self.includeEvents: + self.write_family_events(family) def calc_age(self,ind): """ diff --git a/src/plugins/DetDescendantReport.py b/src/plugins/DetDescendantReport.py index 0e69e6451..258b6e1f0 100644 --- a/src/plugins/DetDescendantReport.py +++ b/src/plugins/DetDescendantReport.py @@ -208,10 +208,13 @@ class DetDescendantReport(Report): self.gen_handles[person_handle] = key dupPerson = self.write_person(key) if dupPerson == 0: # Is this a duplicate ind record - if self.listChildren: + if self.listChildren or self.includeEvents: for family_handle in person.get_family_handle_list(): family = self.database.get_family_from_handle(family_handle) - self.write_children(family) + if self.listChildren: + self.write_children(family) + if self.includeEvents: + self.write_family_events(family) if self.includeSources: self.write_endnotes() @@ -326,14 +329,6 @@ class DetDescendantReport(Report): for event_ref in person.get_event_ref_list(): if event_ref == birth_ref or event_ref == death_ref: continue - event = self.database.get_event_from_handle(event_ref.ref) - date = DateHandler.get_date(event) - ename = str( event.get_type() ) - place_handle = event.get_place_handle() - if place_handle: - place = self.database.get_place_from_handle(place_handle).get_title() - else: - place = u'' if first: self.doc.start_paragraph('DDR-MoreHeader') @@ -342,32 +337,46 @@ class DetDescendantReport(Report): self.doc.end_paragraph() first = 0 - - self.doc.start_paragraph('DDR-MoreDetails') - if date and place: - self.doc.write_text(_('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % { - 'event_name' : ename, - 'date' : date, - 'endnotes' : self.endnotes(event), - 'place' : place }) - elif date: - self.doc.write_text(_('%(event_name)s: %(date)s%(endnotes)s. ') % { - 'event_name' : ename, - 'endnotes' : self.endnotes(event), - 'date' : date}) - elif place: - self.doc.write_text(_('%(event_name)s: %(place)s%(endnotes)s. ') % { - 'event_name' : ename, - 'endnotes' : self.endnotes(event), - 'place' : place }) - else: - self.doc.write_text(_('%(event_name)s: ') % { - 'event_name' : ename}) - if event.get_description(): - self.doc.write_text(event.get_description()) - self.doc.end_paragraph() + self.write_event(event_ref) return 0 # Not duplicate person + + def write_event(self, event_ref): + event = self.database.get_event_from_handle(event_ref.ref) + date = DateHandler.get_date(event) + ph = event.get_place_handle() + if ph: + place = self.database.get_place_from_handle(ph).get_title() + else: + place = u'' + + self.doc.start_paragraph('DDR-MoreDetails') + evtName = str( event.get_type() ) + if date and place: + self.doc.write_text( + _('%(event_name)s: %(date)s, %(place)s%(endnotes)s. ') % { + 'event_name' : _(evtName), + 'date' : date, + 'endnotes' : self.endnotes(event), + 'place' : place }) + elif date: + self.doc.write_text( + _('%(event_name)s: %(date)s%(endnotes)s. ') % { + 'event_name' : _(evtName), + 'endnotes' : self.endnotes(event), + 'date' : date}) + elif place: + self.doc.write_text( + _('%(event_name)s: %(place)s%(endnotes)s. ') % { + 'event_name' : _(evtName), + 'endnotes' : self.endnotes(event), + 'place' : place }) + else: + self.doc.write_text(_('%(event_name)s: ') % { + 'event_name' : _(evtName)}) + if event.get_description(): + self.doc.write_text(event.get_description()) + self.doc.end_paragraph() def write_parents(self, person, firstName): family_handle = person.get_main_parents_family_handle() @@ -478,6 +487,37 @@ class DetDescendantReport(Report): self.database, child, 0, self.EMPTY_DATE, self.EMPTY_PLACE)) self.doc.end_paragraph() + def write_family_events(self,family): + + if not family.get_event_ref_list(): + return + + 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") + + first = 1 + for event_ref in family.get_event_ref_list(): + if first: + self.doc.start_paragraph('DDR-MoreHeader') + self.doc.write_text( + _('More about %(mother_name)s and %(father_name)s:') % { + 'mother_name' : mother_name, + 'father_name' : father_name }) + self.doc.end_paragraph() + first = 0 + self.write_event(event_ref) + def write_mate(self, mate): """Output birth, death, parentage, marriage and notes information """ for family_handle in mate.get_family_handle_list():