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/DetDescendantReport.py: remove use of deprecated functions
* src/plugins/DetAncestralReport.py: remove use of deprecated functions * src/plugins/DetAncestralReport.py: remove use of deprecated functions
* src/PluginUtils/_Plugins.py: remove statbox * 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> 2006-03-29 Don Allingham <don@gramps-project.org>
* src/Utils.py: provide launch function for spawning processes * 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 @rtype: tuple
""" """
bhandle = None
if start_handle: if start_handle:
bhandle = start_handle bhandle = start_handle
else: else:
bhandle = person.get_birth_handle() bref = person.get_birth_ref()
if bref:
bhandle = bref.get_reference_handle()
dhandle = None
if end_handle: if end_handle:
dhandle = end_handle dhandle = end_handle
else: 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 either of the events is not defined, return an error message
if not bhandle: if not bhandle:

View File

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

View File

@ -63,7 +63,7 @@ import gtk.glade
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import Person from RelLib import Person
import const
import Utils import Utils
import ListModel import ListModel
from PluginUtils import Plugins, Report, ReportOptions, \ from PluginUtils import Plugins, Report, ReportOptions, \
@ -1026,7 +1026,7 @@ class BookReportDialog(Report.ReportDialog):
"""Build a menu of document types that are appropriate for """Build a menu of document types that are appropriate for
this text report. This menu will be generated based upon this text report. This menu will be generated based upon
whether the document requires table support, etc.""" 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.format_menu.set(self.doc_uses_tables(),
self.doc_type_changed, None, active) 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) person = self.database.get_person_from_handle(person_handle)
pn = person.get_primary_name() pn = person.get_primary_name()
birth_handle = person.get_birth_handle() birth_ref = person.get_birth_ref()
if birth_handle: if birth_ref:
b = self.database.get_event_from_handle(birth_handle).get_date_object().get_year() birth = self.database.get_event_from_handle(birth_ref.ref)
b = birth.get_date_object().get_year()
if b == 0: if b == 0:
b = "" b = ""
else: else:
b = "" b = ""
death_handle = person.get_death_handle() death_ref = person.get_death_ref()
if death_handle: if death_ref:
d = self.database.get_event_from_handle(death_handle).get_date_object().get_year() death = self.database.get_event_from_handle(death_ref.ref)
d = death.get_date_object().get_year()
if d == 0: if d == 0:
d = "" d = ""
else: else:

View File

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

View File

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

View File

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

View File

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