Make the Family Group Report work. Eliminiate the use of depricated functions.

svn: r6216
This commit is contained in:
Brian Matherly 2006-03-29 02:35:19 +00:00
parent ae7296cb25
commit 4761c816c5
2 changed files with 55 additions and 46 deletions

View File

@ -7,6 +7,7 @@
* src/GenericFilter.py: Use filename instead of URI for XML parser * src/GenericFilter.py: Use filename instead of URI for XML parser
* src/BaseDoc.py: Use filename instead of URI for XML parser * src/BaseDoc.py: Use filename instead of URI for XML parser
(works on Windows and Linux) (works on Windows and Linux)
* src/plugins/FamilyGroup.py: use new functions
2006-03-28 Don Allingham <don@gramps-project.org> 2006-03-28 Don Allingham <don@gramps-project.org>
* src/Mime/_GnomeMime.py: find the default application instead of * src/Mime/_GnomeMime.py: find the default application instead of

View File

@ -44,8 +44,8 @@ import gtk
import RelLib import RelLib
from PluginUtils import Report, ReportOptions, register_report from PluginUtils import Report, ReportOptions, register_report
import BaseDoc import BaseDoc
import const
import DateHandler import DateHandler
import Utils
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -164,7 +164,7 @@ class FamilyGroup(Report.Report):
place = "" place = ""
date = "" date = ""
if event: if event:
date = event.get_date() date = DateHandler.get_date(event)
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
if place_handle: if place_handle:
place = self.database.get_place_from_handle(place_handle).get_title() place = self.database.get_place_from_handle(place_handle).get_title()
@ -222,17 +222,17 @@ class FamilyGroup(Report.Report):
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
birth_handle = person.get_birth_handle() birth_ref = person.get_birth_ref()
birth = None birth = None
if birth_handle: if birth_ref:
birth = self.database.get_event_from_handle(birth_handle) birth = self.database.get_event_from_handle(birth_ref.ref)
if birth or self.missingInfo: if birth or self.missingInfo:
self.dump_parent_event(_("Birth"),birth) self.dump_parent_event(_("Birth"),birth)
death_handle = person.get_death_handle() death_ref = person.get_death_ref()
death = None death = None
if death_handle: if death_ref:
death = self.database.get_event_from_handle(death_handle) death = self.database.get_event_from_handle(death_ref.ref)
if death or self.missingInfo: if death or self.missingInfo:
self.dump_parent_event(_("Death"),death) self.dump_parent_event(_("Death"),death)
@ -246,30 +246,34 @@ class FamilyGroup(Report.Report):
father = self.database.get_person_from_handle(father_handle) father = self.database.get_person_from_handle(father_handle)
father_name = father.get_primary_name().get_regular_name() father_name = father.get_primary_name().get_regular_name()
if self.incRelDates: if self.incRelDates:
birth_handle = father.get_birth_handle() birth_ref = father.get_birth_ref()
birth = " " birth = " "
if birth_handle: if birth_ref:
birth = self.database.get_event_from_handle(birth_handle).get_date() event = self.database.get_event_from_handle(birth_ref.ref)
death_handle = father.get_death_handle() birth = DateHandler.get_date( event )
death_ref = father.get_death_ref()
death = " " death = " "
if death_handle: if death_ref:
death = self.database.get_event_from_handle(death_handle).get_date() event = self.database.get_event_from_handle(death_ref.ref)
if birth_handle or death_handle: death = DateHandler.get_date( event )
if birth_ref or death_ref:
father_name = "%s (%s - %s)" % (father_name,birth,death) father_name = "%s (%s - %s)" % (father_name,birth,death)
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if mother_handle: if mother_handle:
mother = self.database.get_person_from_handle(mother_handle) mother = self.database.get_person_from_handle(mother_handle)
mother_name = mother.get_primary_name().get_regular_name() mother_name = mother.get_primary_name().get_regular_name()
if self.incRelDates: if self.incRelDates:
birth_handle = mother.get_birth_handle() birth_ref = mother.get_birth_ref()
birth = " " birth = " "
if birth_handle: if birth_ref:
birth = self.database.get_event_from_handle(birth_handle).get_date() event = self.database.get_event_from_handle(birth_ref.ref)
death_handle = mother.get_death_handle() birth = DateHandler.get_date( event )
death_ref = mother.get_death_ref()
death = " " death = " "
if death_handle: if death_ref:
death = self.database.get_event_from_handle(death_handle).get_date() event = self.database.get_event_from_handle(birth_ref.ref)
if birth_handle or death_handle: death = DateHandler.get_date( event )
if birth_ref or death_ref:
mother_name = "%s (%s - %s)" % (mother_name,birth,death) mother_name = "%s (%s - %s)" % (mother_name,birth,death)
if self.missingInfo or father_name != "": if self.missingInfo or father_name != "":
@ -279,18 +283,20 @@ class FamilyGroup(Report.Report):
self.dump_parent_line(_("Mother"),mother_name) self.dump_parent_line(_("Mother"),mother_name)
if self.incParEvents: if self.incParEvents:
for event_handle in person.get_event_list(): excludeEvts = ( person.get_birth_ref(), person.get_death_ref() )
event = self.database.get_event_from_handle(event_handle) for event_ref in person.get_event_ref_list():
evtName = event.get_name() if event_ref not in excludeEvts:
if (evtName != "Death") and (evtName != "Birth"): event = self.database.get_event_from_handle(event_ref.ref)
self.dump_parent_event(_(evtName),event) evtType = event.get_type()
evtName = Utils.format_event( evtType )
self.dump_parent_event(evtName,event)
if self.incParAddr: if self.incParAddr:
addrlist = person.get_address_list()[:] addrlist = person.get_address_list()[:]
for addr in addrlist: for addr in addrlist:
location = "%s %s %s %s" % (addr.get_street(),addr.get_city(), location = "%s %s %s %s" % (addr.get_street(),addr.get_city(),
addr.get_state(),addr.get_country()) addr.get_state(),addr.get_country())
date = addr.get_date() date = DateHandler.get_date( addr )
self.doc.start_row() self.doc.start_row()
self.doc.start_cell("FGR-TextContents") self.doc.start_cell("FGR-TextContents")
@ -315,7 +321,7 @@ class FamilyGroup(Report.Report):
if self.incParNames: if self.incParNames:
for alt_name in person.get_alternate_names(): for alt_name in person.get_alternate_names():
type = const.NameTypesMap.find_value(alt_name.get_type()) type = Utils.format_name_type( alt_name.get_type() )
name = alt_name.get_regular_name() name = alt_name.get_regular_name()
self.dump_parent_line(type,name) self.dump_parent_line(type,name)
@ -356,14 +362,14 @@ class FamilyGroup(Report.Report):
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
families = len(person.get_family_handle_list()) families = len(person.get_family_handle_list())
birth_handle = person.get_birth_handle() birth_ref = person.get_birth_ref()
if birth_handle: if birth_ref:
birth = self.database.get_event_from_handle(birth_handle) birth = self.database.get_event_from_handle(birth_ref.ref)
else: else:
birth = None birth = None
death_handle = person.get_death_handle() death_ref = person.get_death_ref()
if death_handle: if death_ref:
death = self.database.get_event_from_handle(death_handle) death = self.database.get_event_from_handle(death_ref.ref)
else: else:
death = None death = None
@ -416,10 +422,10 @@ class FamilyGroup(Report.Report):
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
index = index + 1 index = index + 1
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
for event_handle in family.get_event_list(): for event_ref in family.get_event_ref_list():
if event_handle: if event_ref:
event = self.database.get_event_from_handle(event_handle) event = self.database.get_event_from_handle(event_ref.ref)
if event.get_name() == "Marriage": if event.get_type() == RelLib.Event.MARRIAGE:
m = event m = event
break break
else: else:
@ -448,15 +454,17 @@ class FamilyGroup(Report.Report):
spouse = self.database.get_person_from_handle(spouse_id) spouse = self.database.get_person_from_handle(spouse_id)
spouse_name = spouse.get_primary_name().get_regular_name() spouse_name = spouse.get_primary_name().get_regular_name()
if self.incRelDates: if self.incRelDates:
birth_handle = spouse.get_birth_handle()
birth = " " birth = " "
if birth_handle: birth_ref = spouse.get_birth_ref()
birth = self.database.get_event_from_handle(birth_handle).get_date() if birth_ref:
death_handle = spouse.get_death_handle() event = self.database.get_event_from_handle(birth_ref.ref)
birth = DateHandler.get_date(event)
death = " " death = " "
if death_handle: death_ref = spouse.get_death_ref()
death = self.database.get_event_from_handle(death_handle).get_date() if death_ref:
if birth_handle or death_handle: event = self.database.get_event_from_handle(death_ref.ref)
death = DateHandler.get_date(event)
if birth_ref or death_ref:
spouse_name = "%s (%s - %s)" % (spouse_name,birth,death) spouse_name = "%s (%s - %s)" % (spouse_name,birth,death)
self.doc.write_text(spouse_name) self.doc.write_text(spouse_name)
self.doc.end_paragraph() self.doc.end_paragraph()