From d9277db7eea49404124eff86288fb2828212f22f Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Thu, 30 Mar 2006 05:15:54 +0000 Subject: [PATCH] Remove use of deprecated functions. Supported graphical reports should work now. svn: r6232 --- ChangeLog | 2 ++ src/PluginUtils/_ReportUtils.py | 10 +++++++-- src/SubstKeywords.py | 21 ++++++++++--------- src/plugins/BookReport.py | 4 ++-- src/plugins/FanChart.py | 14 +++++++------ src/plugins/GraphViz.py | 24 ++++++++++----------- src/plugins/StatisticsChart.py | 37 ++++++++++++++++++--------------- src/plugins/Summary.py | 6 +++--- src/plugins/TimeLine.py | 28 ++++++++++++++----------- 9 files changed, 82 insertions(+), 64 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2df9e22bb..c64e1031a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * src/Utils.py: provide launch function for spawning processes diff --git a/src/PluginUtils/_ReportUtils.py b/src/PluginUtils/_ReportUtils.py index a2c85cd43..c5f022123 100644 --- a/src/PluginUtils/_ReportUtils.py +++ b/src/PluginUtils/_ReportUtils.py @@ -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: diff --git a/src/SubstKeywords.py b/src/SubstKeywords.py index 83facee10..e11cbf3d4 100644 --- a/src/SubstKeywords.py +++ b/src/SubstKeywords.py @@ -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: diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index 74c7a3eee..1657931a3 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -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) diff --git a/src/plugins/FanChart.py b/src/plugins/FanChart.py index a96d88e4e..08fbfc629 100644 --- a/src/plugins/FanChart.py +++ b/src/plugins/FanChart.py @@ -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: diff --git a/src/plugins/GraphViz.py b/src/plugins/GraphViz.py index 1fb03db4c..2b2edd4aa 100644 --- a/src/plugins/GraphViz.py +++ b/src/plugins/GraphViz.py @@ -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: diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index f2d79f8d6..d588807f7 100644 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -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) diff --git a/src/plugins/Summary.py b/src/plugins/Summary.py index 62efb8fa3..8813636d5 100644 --- a/src/plugins/Summary.py +++ b/src/plugins/Summary.py @@ -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: diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index 418455b6a..11185e8dd 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -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