Remove use of deprecated functions. Supported graphical reports should work now.

svn: r6232
This commit is contained in:
Brian Matherly 2006-03-30 05:15:54 +00:00
parent 0c11137172
commit 68dc46cdd6
9 changed files with 82 additions and 64 deletions

View File

@ -7,6 +7,8 @@
* src/plugins/DetDescendantReport.py: remove use of deprecated functions
* src/plugins/DetAncestralReport.py: remove use of deprecated functions
* src/PluginUtils/_Plugins.py: remove statbox
* src/SubstKeywords.py: remove use of deprecated functions
* src/plugins/ various files: remove use of deprecated functions
2006-03-29 Don Allingham <don@gramps-project.org>
* src/Utils.py: provide launch function for spawning processes

View File

@ -1004,15 +1004,21 @@ def estimate_age(db, person, end_handle=None, start_handle=None):
@rtype: tuple
"""
bhandle = None
if start_handle:
bhandle = start_handle
else:
bhandle = person.get_birth_handle()
bref = person.get_birth_ref()
if bref:
bhandle = bref.get_reference_handle()
dhandle = None
if end_handle:
dhandle = end_handle
else:
dhandle = person.get_death_handle()
dref = person.get_death_ref()
if dref:
dhandle = dref.get_reference_handle()
# if either of the events is not defined, return an error message
if not bhandle:

View File

@ -43,6 +43,7 @@ __version__ = "$Revision$"
import NameDisplay
import DateHandler
import RelLib
#------------------------------------------------------------------------
#
@ -82,16 +83,16 @@ class SubstKeywords:
self.m = ""
self.M = ""
birth_handle = person.get_birth_handle()
if birth_handle:
birth = database.get_event_from_handle(birth_handle)
birth_ref = person.get_birth_ref()
if birth_ref:
birth = database.get_event_from_handle(birth_ref.ref)
self.b = DateHandler.get_date(birth)
bplace_handle = birth.get_place_handle()
if bplace_handle:
self.B = database.get_place_from_handle(bplace_handle).get_title()
death_handle = person.get_death_handle()
if death_handle:
death = database.get_event_from_handle(death_handle)
death_ref = person.get_death_ref()
if death_ref:
death = database.get_event_from_handle(death_ref.ref)
self.d = DateHandler.get_date(death)
dplace_handle = death.get_place_handle()
if dplace_handle:
@ -113,11 +114,11 @@ class SubstKeywords:
father = database.get_person_from_handle(father_handle)
self.s = NameDisplay.displayer.display(father)
self.S = NameDisplay.displayer.sorted(father)
for e_id in f.get_event_list():
if not e_id:
for e_ref in f.get_event_ref_list():
if not e_ref:
continue
e = database.get_event_from_handle(e_id)
if e.get_name() == 'Marriage':
e = database.get_event_from_handle(e_ref.ref)
if e.get_type() == RelLib.Event.MARRIAGE:
self.m = DateHandler.get_date(e)
mplace_handle = e.get_place_handle()
if mplace_handle:

View File

@ -63,7 +63,7 @@ import gtk.glade
#
#-------------------------------------------------------------------------
from RelLib import Person
import const
import Utils
import ListModel
from PluginUtils import Plugins, Report, ReportOptions, \
@ -1026,7 +1026,7 @@ class BookReportDialog(Report.ReportDialog):
"""Build a menu of document types that are appropriate for
this text report. This menu will be generated based upon
whether the document requires table support, etc."""
self.format_menu = Plugins.GrampsBookFormatComboBox()
self.format_menu = Report.GrampsBookFormatComboBox()
self.format_menu.set(self.doc_uses_tables(),
self.doc_type_changed, None, active)

View File

@ -193,17 +193,19 @@ class FanChart(Report.Report):
person = self.database.get_person_from_handle(person_handle)
pn = person.get_primary_name()
birth_handle = person.get_birth_handle()
if birth_handle:
b = self.database.get_event_from_handle(birth_handle).get_date_object().get_year()
birth_ref = person.get_birth_ref()
if birth_ref:
birth = self.database.get_event_from_handle(birth_ref.ref)
b = birth.get_date_object().get_year()
if b == 0:
b = ""
else:
b = ""
death_handle = person.get_death_handle()
if death_handle:
d = self.database.get_event_from_handle(death_handle).get_date_object().get_year()
death_ref = person.get_death_ref()
if death_ref:
death = self.database.get_event_from_handle(death_ref.ref)
d = death.get_date_object().get_year()
if d == 0:
d = ""
else:

View File

@ -247,8 +247,8 @@ class GraphViz:
family = self.database.get_family_from_handle(family_handle)
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
fadopted = frel != RelLib.Person.CHILD_REL_BIRTH
madopted = mrel != RelLib.Person.CHILD_REL_BIRTH
fadopted = frel != RelLib.Person.CHILD_BIRTH
madopted = mrel != RelLib.Person.CHILD_BIRTH
famid = family.get_gramps_id().replace('-','_')
if (self.show_families and
(father_handle and person_dict.has_key(father_handle) or
@ -299,15 +299,15 @@ class GraphViz:
if self.includeid:
label = label + " (%s)" % the_id
if self.includedates:
birth_handle = person.get_birth_handle()
if birth_handle:
birth_event = self.database.get_event_from_handle(birth_handle)
birth_ref = person.get_birth_ref()
if birth_ref:
birth_event = self.database.get_event_from_handle(birth_ref.ref)
birth = self.dump_event(birth_event)
else:
birth = ''
death_handle = person.get_death_handle()
if death_handle:
death_event = self.database.get_event_from_handle(death_handle)
death_ref = person.get_death_ref()
if death_ref:
death_event = self.database.get_event_from_handle(death_ref.ref)
death = self.dump_event(death_event)
else:
death = ''
@ -347,10 +347,10 @@ class GraphViz:
self.f.write('style=filled fillcolor=%s, ' % self.colors['family'])
marriage = ""
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":
for event_ref in fam.get_event_ref_list():
if event_ref:
event = self.database.get_event_from_handle(event_ref.ref)
if event.get_type() == RelLib.Event.MARRIAGE:
m = event
break
else:

View File

@ -56,7 +56,7 @@ import BaseDoc
from PluginUtils import Report, ReportOptions, ReportUtils, register_report
import GenericFilter
import DateHandler
from Utils import ProgressMeter
from Utils import ProgressMeter, format_event
#------------------------------------------------------------------------
#
@ -224,16 +224,16 @@ class Extract:
def get_person_age(self, person):
"return age for given person, if alive"
death_handle = person.get_death_handle()
if not death_handle:
death_ref = person.get_death_ref()
if not death_ref:
return [self.estimate_age(person)]
return [_("Already dead")]
def get_death_age(self, person):
"return age at death for given person, if dead"
death_handle = person.get_death_handle()
if death_handle:
return [self.estimate_age(person, death_handle)]
death_ref = person.get_death_ref()
if death_ref:
return [self.estimate_age(person, death_ref.ref)]
return [_("Still alive")]
def get_event_ages(self, data):
@ -252,7 +252,8 @@ class Extract:
person, event_handles = data
for event_handle in event_handles:
event = self.db.get_event_from_handle(event_handle)
types.append(event.get_name())
evtType = format_event( event.get_type() )
types.append(evtType)
if types:
return types
return [_("Events missing")]
@ -286,9 +287,9 @@ class Extract:
person, child_handles = data
for child_handle in child_handles:
child = self.db.get_person_from_handle(child_handle)
birth_handle = child.get_birth_handle()
if birth_handle:
ages.append(self.estimate_age(person, birth_handle))
birth_ref = child.get_birth_ref()
if birth_ref:
ages.append(self.estimate_age(person, birth_ref.ref))
else:
errors.append(_("Birth missing"))
continue
@ -318,16 +319,16 @@ class Extract:
def get_birth(self, person):
"return birth event for given person or None"
birth_handle = person.get_birth_handle()
if birth_handle:
return self.db.get_event_from_handle(birth_handle)
birth_ref = person.get_birth_ref()
if birth_ref:
return self.db.get_event_from_handle(birth_ref.ref)
return None
def get_death(self, person):
"return death event for given person or None"
death_handle = person.get_death_handle()
if death_handle:
return self.db.get_event_from_handle(death_handle)
death_ref = person.get_death_ref()
if death_ref:
return self.db.get_event_from_handle(death_ref.ref)
return None
def get_child_handles(self, person):
@ -370,7 +371,9 @@ class Extract:
def get_event_handles(self, person):
"return list of event handles for given person or None"
events = person.get_event_list()
events = []
for event_ref in person.get_event_ref_list():
events.append( event_ref.get_reference_handle())
if events:
return (person, events)

View File

@ -92,9 +92,9 @@ def build_report(database,person):
incomp_names = incomp_names + 1
if (not person.get_main_parents_family_handle()) and (not len(person.get_family_handle_list())):
disconnected = disconnected + 1
birth_handle = person.get_birth_handle()
if birth_handle:
birth = database.get_event_from_handle(birth_handle)
birth_ref = person.get_birth_ref()
if birth_ref:
birth = database.get_event_from_handle(birth_ref.ref)
if not DateHandler.get_date(birth):
missing_bday = missing_bday + 1
else:

View File

@ -192,15 +192,17 @@ class TimeLine(Report.Report):
for p_id in self.plist:
p = self.database.get_person_from_handle(p_id)
b_id = p.get_birth_handle()
if b_id:
b = self.database.get_event_from_handle(b_id).get_date_object().get_year()
b_ref = p.get_birth_ref()
if b_ref:
birth = self.database.get_event_from_handle(b_ref.ref)
b = birth.get_date_object().get_year()
else:
b = None
d_id = p.get_death_handle()
if d_id:
d = self.database.get_event_from_handle(d_id).get_date_object().get_year()
d_ref = p.get_death_ref()
if d_ref:
death = self.database.get_event_from_handle(d_ref.ref)
d = death.get_date_object().get_year()
else:
d = None
@ -289,15 +291,17 @@ class TimeLine(Report.Report):
for p_id in self.plist:
p = self.database.get_person_from_handle(p_id)
b_id = p.get_birth_handle()
if b_id:
b = self.database.get_event_from_handle(b_id).get_date_object().get_year()
b_ref = p.get_birth_ref()
if b_ref:
birth = self.database.get_event_from_handle(b_ref.ref)
b = birth.get_date_object().get_year()
else:
b = None
d_id = p.get_death_handle()
if d_id:
d = self.database.get_event_from_handle(d_id).get_date_object().get_year()
d_ref = p.get_death_ref()
if d_ref:
death = self.database.get_event_from_handle(d_ref.ref)
d = death.get_date_object().get_year()
else:
d = None