diff --git a/src/ReportBase/_ReportUtils.py b/src/ReportBase/_ReportUtils.py
index 7bf214869..c744207c2 100644
--- a/src/ReportBase/_ReportUtils.py
+++ b/src/ReportBase/_ReportUtils.py
@@ -166,30 +166,6 @@ def find_marriage(database, family):
return event
return None
-def get_birth_or_fallback(database, person):
- birth_ref = person.get_birth_ref()
- if birth_ref: # regular birth found
- return database.get_event_from_handle(birth_ref.ref)
- # now search the event list for fallbacks
- for event_ref in person.get_primary_event_ref_list():
- event = database.get_event_from_handle(event_ref.ref)
- if (event.type.is_birth_fallback() and
- event_ref.role.is_primary()):
- return event
- return None
-
-def get_death_or_fallback(database, person):
- death_ref = person.get_death_ref()
- if death_ref: # regular death found
- return database.get_event_from_handle(death_ref.ref)
- # now search the event list for fallbacks
- for event_ref in person.get_primary_event_ref_list():
- event = database.get_event_from_handle(event_ref.ref)
- if (event.type.is_death_fallback() and
- event_ref.role.is_primary()):
- return event
- return None
-
#-------------------------------------------------------------------------
#
# Indexing function
diff --git a/src/Sort.py b/src/Sort.py
index c5ce085cb..181cecf11 100644
--- a/src/Sort.py
+++ b/src/Sort.py
@@ -40,8 +40,8 @@ import locale
#
#-------------------------------------------------------------------------
from gen.lib import Date
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
from BasicUtils import name_displayer as _nd
-from ReportBase import ReportUtils
#-------------------------------------------------------------------------
#
@@ -118,13 +118,13 @@ class Sort(object):
first = self.database.get_person_from_handle(first_id)
second = self.database.get_person_from_handle(second_id)
- birth1 = ReportUtils.get_birth_or_fallback(self.database, first)
+ birth1 = get_birth_or_fallback(self.database, first)
if birth1:
date1 = birth1.get_date_object()
else:
date1 = Date()
- birth2 = ReportUtils.get_birth_or_fallback(self.database, second)
+ birth2 = get_birth_or_fallback(self.database, second)
if birth2:
date2 = birth2.get_date_object()
else:
@@ -143,7 +143,7 @@ class Sort(object):
are equal, sorts by name"""
first = self.database.get_person_from_handle(first_id)
- birth1 = ReportUtils.get_birth_or_fallback(self.database, first)
+ birth1 = get_birth_or_fallback(self.database, first)
if birth1:
date1 = birth1.get_date_object()
else:
diff --git a/src/SubstKeywords.py b/src/SubstKeywords.py
index 993851398..0c84950ae 100644
--- a/src/SubstKeywords.py
+++ b/src/SubstKeywords.py
@@ -39,9 +39,9 @@ Mary Smith was born on 3/28/1923.
#------------------------------------------------------------------------
from BasicUtils import name_displayer
-from ReportBase import ReportUtils
import DateHandler
import gen.lib
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
@@ -81,13 +81,13 @@ class SubstKeywords(object):
self.m = ""
self.M = ""
- birth = ReportUtils.get_birth_or_fallback(database, person)
+ birth = get_birth_or_fallback(database, person)
if birth:
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 = ReportUtils.get_death_or_fallback(database, person)
+ death = get_death_or_fallback(database, person)
if death:
self.d = DateHandler.get_date(death)
dplace_handle = death.get_place_handle()
diff --git a/src/gen/db/base.py b/src/gen/db/base.py
index ebd07e0f7..807ef013b 100644
--- a/src/gen/db/base.py
+++ b/src/gen/db/base.py
@@ -1520,46 +1520,6 @@ class GrampsDbBase(object):
"""
raise NotImplementedError
- def get_birth_or_fallback(self, person):
- """
- Get BIRTH event from a person, or fallback to an event around
- the time of birth.
- """
- birth_ref = person.get_birth_ref()
- if birth_ref: # regular birth found
- event = self.get_event_from_handle(birth_ref.ref)
- if event:
- return event
- # now search the event list for fallbacks
- for event_ref in person.get_primary_event_ref_list():
- if event_ref:
- event = self.get_event_from_handle(event_ref.ref)
- if (event
- and event.type.is_birth_fallback()
- and event_ref.role.is_primary()):
- return event
- return None
-
- def get_death_or_fallback(self, person):
- """
- Get a DEATH event from a person, or fallback to an
- event around the time of death.
- """
- death_ref = person.get_death_ref()
- if death_ref: # regular death found
- event = self.get_event_from_handle(death_ref.ref)
- if event:
- return event
- # now search the event list for fallbacks
- for event_ref in person.get_primary_event_ref_list():
- if event_ref:
- event = self.get_event_from_handle(event_ref.ref)
- if (event
- and event.type.is_death_fallback()
- and event_ref.role.is_primary()):
- return event
- return None
-
def add_child_to_family(self, family, child,
mrel=gen.lib.ChildRefType(),
frel=gen.lib.ChildRefType(),
diff --git a/src/gen/utils/Makefile.am b/src/gen/utils/Makefile.am
index ff1bdcd38..a0591289b 100644
--- a/src/gen/utils/Makefile.am
+++ b/src/gen/utils/Makefile.am
@@ -10,6 +10,7 @@ pkgdata_PYTHON = \
callback.py \
callman.py \
configmanager.py \
+ fallback.py \
progressmon.py \
longop.py
diff --git a/src/gen/utils/__init__.py b/src/gen/utils/__init__.py
index 3113ae6c0..9a710b3a9 100644
--- a/src/gen/utils/__init__.py
+++ b/src/gen/utils/__init__.py
@@ -22,6 +22,7 @@
Generic utilities useful for users of the gen package
"""
+from fallback import *
from configmanager import ConfigManager
from progressmon import ProgressMonitor
from longop import LongOpStatus
diff --git a/src/gui/editors/displaytabs/childmodel.py b/src/gui/editors/displaytabs/childmodel.py
index 2e9eee093..a852a2a89 100644
--- a/src/gui/editors/displaytabs/childmodel.py
+++ b/src/gui/editors/displaytabs/childmodel.py
@@ -36,8 +36,8 @@ import cgi
import DateHandler
from BasicUtils import name_displayer
import Utils
-from ReportBase import ReportUtils
import gen.lib
+from gen.utils import get_birth_or_fallback
#-------------------------------------------------------------------------
#
@@ -78,7 +78,7 @@ class ChildModel(gtk.ListStore):
return self.family.get_child_ref_list()
def column_birth_day(self, data):
- birth = ReportUtils.get_birth_or_fallback(self.db, data)
+ birth = get_birth_or_fallback(self.db, data)
if birth:
if birth.get_type() == gen.lib.EventType.BIRTH:
return DateHandler.get_date(birth)
diff --git a/src/gui/editors/editfamily.py b/src/gui/editors/editfamily.py
index c2bad05ba..e981150ac 100644
--- a/src/gui/editors/editfamily.py
+++ b/src/gui/editors/editfamily.py
@@ -64,7 +64,6 @@ from glade import Glade
from editprimary import EditPrimary
from editchildref import EditChildRef
from editperson import EditPerson
-from ReportBase import ReportUtils
from displaytabs import (EmbeddedList, EventEmbedList, SourceEmbedList,
FamilyAttrEmbedList, NoteTab, GalleryTab,
FamilyLdsEmbedList, ChildModel)
@@ -72,8 +71,9 @@ from gui.widgets import (PrivacyButton, MonitoredEntry, MonitoredDataType)
from gen.plug import CATEGORY_QR_FAMILY
from QuestionDialog import (ErrorDialog, RunDatabaseRepair, WarningDialog,
MessageHideDialog)
-
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
from gui.selectors import SelectorFactory
+
SelectPerson = SelectorFactory('Person')
_RETURN = gdk.keyval_from_name("Return")
@@ -898,7 +898,7 @@ class EditFamily(EditPrimary):
person = db.get_person_from_handle(handle)
name = "%s [%s]" % (name_displayer.display(person),
person.gramps_id)
- birth = ReportUtils.get_birth_or_fallback(db, person)
+ birth = get_birth_or_fallback(db, person)
self.callman.register_handles({'person': [handle]})
if birth:
#if event changes it view needs to update
@@ -906,7 +906,7 @@ class EditFamily(EditPrimary):
if birth and birth.get_type() == gen.lib.EventType.BAPTISM:
birth_label.set_label(_("Baptism:"))
- death = ReportUtils.get_death_or_fallback(db, person)
+ death = get_death_or_fallback(db, person)
if death:
#if event changes it view needs to update
self.callman.register_handles({'event': [death.get_handle()]})
diff --git a/src/plugins/drawreport/TimeLine.py b/src/plugins/drawreport/TimeLine.py
index a9e5c6828..aef8e80fa 100644
--- a/src/plugins/drawreport/TimeLine.py
+++ b/src/plugins/drawreport/TimeLine.py
@@ -48,6 +48,7 @@ from BasicUtils import name_displayer
from Utils import probably_alive
from gui.utils import ProgressMeter
import gen.lib
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
@@ -139,13 +140,13 @@ class TimeLine(Report):
for p_id in self.plist:
self.progress.step()
p = self.database.get_person_from_handle(p_id)
- birth = ReportUtils.get_birth_or_fallback(self.database, p)
+ birth = get_birth_or_fallback(self.database, p)
if birth:
b = birth.get_date_object().to_calendar(self.calendar).get_year()
else:
b = None
- death = ReportUtils.get_death_or_fallback(self.database, p)
+ death = get_death_or_fallback(self.database, p)
if death:
d = death.get_date_object().to_calendar(self.calendar).get_year()
else:
@@ -242,13 +243,13 @@ class TimeLine(Report):
for p_id in self.plist:
p = self.database.get_person_from_handle(p_id)
- birth = ReportUtils.get_birth_or_fallback(self.database, p)
+ birth = get_birth_or_fallback(self.database, p)
if birth:
b = birth.get_date_object().to_calendar(self.calendar).get_year()
else:
b = None
- death = ReportUtils.get_death_or_fallback(self.database, p)
+ death = get_death_or_fallback(self.database, p)
if death:
d = death.get_date_object().to_calendar(self.calendar).get_year()
else:
diff --git a/src/plugins/gramplet/PedigreeGramplet.py b/src/plugins/gramplet/PedigreeGramplet.py
index e0e8b5ded..1ac082c65 100644
--- a/src/plugins/gramplet/PedigreeGramplet.py
+++ b/src/plugins/gramplet/PedigreeGramplet.py
@@ -36,9 +36,9 @@ from gen.plug import Gramplet
from TransUtils import sgettext as _
from gettext import ngettext
from BasicUtils import name_displayer
-from ReportBase import ReportUtils
import DateHandler
import gen
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
@@ -185,7 +185,7 @@ class PedigreeGramplet(Gramplet):
self.set_box(generation, 0) # regardless, turn off line if on
def info_string(self, person):
- birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person)
+ birth = get_birth_or_fallback(self.dbstate.db, person)
if birth and birth.get_type() != gen.lib.EventType.BIRTH:
sdate = DateHandler.get_date(birth)
if sdate:
@@ -197,7 +197,7 @@ class PedigreeGramplet(Gramplet):
else:
bdate = ""
- death = ReportUtils.get_death_or_fallback(self.dbstate.db, person)
+ death = get_death_or_fallback(self.dbstate.db, person)
if death and death.get_type() != gen.lib.EventType.DEATH:
sdate = DateHandler.get_date(death)
if sdate:
diff --git a/src/plugins/graph/GVFamilyLines.py b/src/plugins/graph/GVFamilyLines.py
index 3aa6f7163..052f230d6 100644
--- a/src/plugins/graph/GVFamilyLines.py
+++ b/src/plugins/graph/GVFamilyLines.py
@@ -56,6 +56,7 @@ from ReportBase import Report, ReportUtils, MenuReportOptions
from gen.plug.menu import NumberOption, ColorOption, BooleanOption, \
EnumeratedListOption, PersonListOption, \
SurnameColorOption
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
@@ -780,8 +781,8 @@ class FamilyLinesReport(Report):
# see if we have a birth/death or fallback dates we can use
if self._incdates or self._incplaces:
- bth_event = ReportUtils.get_birth_or_fallback(self._db, person)
- dth_event = ReportUtils.get_death_or_fallback(self._db, person)
+ bth_event = get_birth_or_fallback(self._db, person)
+ dth_event = get_death_or_fallback(self._db, person)
else:
bth_event = None
dth_event = None
diff --git a/src/plugins/graph/GVHourGlass.py b/src/plugins/graph/GVHourGlass.py
index a6ba65789..a97d090af 100644
--- a/src/plugins/graph/GVHourGlass.py
+++ b/src/plugins/graph/GVHourGlass.py
@@ -43,6 +43,7 @@ from gen.plug.menu import (PersonOption, BooleanOption, NumberOption,
EnumeratedListOption)
from ReportBase import Report, ReportUtils, MenuReportOptions
import DateHandler
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
@@ -169,13 +170,13 @@ class HourGlassReport(Report):
p_id = person.get_gramps_id()
name = name_displayer.display_formal(person)
- birth_evt = ReportUtils.get_birth_or_fallback(self.__db, person)
+ birth_evt = get_birth_or_fallback(self.__db, person)
if birth_evt:
birth = DateHandler.get_date(birth_evt)
else:
birth = ""
- death_evt = ReportUtils.get_death_or_fallback(self.__db, person)
+ death_evt = get_death_or_fallback(self.__db, person)
if death_evt:
death = DateHandler.get_date(death_evt)
else:
diff --git a/src/plugins/graph/GVRelGraph.py b/src/plugins/graph/GVRelGraph.py
index c06e81bcb..c4faa0d4b 100644
--- a/src/plugins/graph/GVRelGraph.py
+++ b/src/plugins/graph/GVRelGraph.py
@@ -53,6 +53,7 @@ import DateHandler
import gen.lib
import Utils
import ThumbNails
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
@@ -403,13 +404,13 @@ class RelGraphReport(Report):
def get_date_strings(self, person):
"returns tuple of birth/christening and death/burying date strings"
- birth_event = ReportUtils.get_birth_or_fallback(self.database, person)
+ birth_event = get_birth_or_fallback(self.database, person)
if birth_event:
birth = self.get_event_string(birth_event)
else:
birth = ""
- death_event = ReportUtils.get_death_or_fallback(self.database, person)
+ death_event = get_death_or_fallback(self.database, person)
if death_event:
death = self.get_event_string(death_event)
else:
diff --git a/src/plugins/lib/libformatting.py b/src/plugins/lib/libformatting.py
index b4fb52fdd..e3cf26d4e 100644
--- a/src/plugins/lib/libformatting.py
+++ b/src/plugins/lib/libformatting.py
@@ -40,7 +40,7 @@ from cgi import escape
import gen.lib
import DateHandler
from BasicUtils import name_displayer
-from ReportBase import ReportUtils
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#-------------------------------------------------------------------------
#
@@ -111,7 +111,7 @@ class FormattingHelper(object):
name = name_displayer.display(person)
text = name
if line_count >= 3:
- birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person)
+ birth = get_birth_or_fallback(self.dbstate.db, person)
if birth and use_markup and birth.get_type() != \
gen.lib.EventType.BIRTH:
bdate = "%s" % escape(DateHandler.get_date(birth))
@@ -126,7 +126,7 @@ class FormattingHelper(object):
else:
bdate = ""
bplace = ""
- death = ReportUtils.get_death_or_fallback(self.dbstate.db, person)
+ death = get_death_or_fallback(self.dbstate.db, person)
if death and use_markup and death.get_type() != \
gen.lib.EventType.DEATH:
ddate = "%s" % escape(DateHandler.get_date(death))
diff --git a/src/plugins/textreport/DescendReport.py b/src/plugins/textreport/DescendReport.py
index 60995ef6c..f8586d88f 100644
--- a/src/plugins/textreport/DescendReport.py
+++ b/src/plugins/textreport/DescendReport.py
@@ -46,6 +46,7 @@ from Errors import ReportError
from ReportBase import Report, ReportUtils, MenuReportOptions
import DateHandler
import Sort
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
_BORN = _('b.')
_DIED = _('d.')
@@ -85,8 +86,8 @@ class DescendantReport(Report):
self.by_birthdate = sort.by_birthdate
def dump_dates(self, person):
- birth = ReportUtils.get_birth_or_fallback(self.database, person)
- death = ReportUtils.get_death_or_fallback(self.database, person)
+ birth = get_birth_or_fallback(self.database, person)
+ death = get_death_or_fallback(self.database, person)
if birth or death:
self.doc.write_text(' (')
diff --git a/src/plugins/textreport/KinshipReport.py b/src/plugins/textreport/KinshipReport.py
index 09d94b335..4b5462595 100644
--- a/src/plugins/textreport/KinshipReport.py
+++ b/src/plugins/textreport/KinshipReport.py
@@ -44,6 +44,7 @@ from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
from gen.plug.menu import NumberOption, BooleanOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions
import DateHandler
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
#------------------------------------------------------------------------
#
@@ -283,12 +284,12 @@ class KinshipReport(Report):
name = name_displayer.display(person)
mark = ReportUtils.get_person_mark(self.database, person)
birth_date = ""
- birth = ReportUtils.get_birth_or_fallback(self.database, person)
+ birth = get_birth_or_fallback(self.database, person)
if birth:
birth_date = DateHandler.get_date(birth)
death_date = ""
- death = ReportUtils.get_death_or_fallback(self.database, person)
+ death = get_death_or_fallback(self.database, person)
if death:
death_date = DateHandler.get_date(death)
dates = _(" (%(birth_date)s - %(death_date)s)") % {
diff --git a/src/plugins/view/relview.py b/src/plugins/view/relview.py
index dc46f5b7b..333bfcdc1 100644
--- a/src/plugins/view/relview.py
+++ b/src/plugins/view/relview.py
@@ -61,7 +61,7 @@ import Errors
import Bookmarks
import const
-from ReportBase import ReportUtils
+from gen.utils import get_birth_or_fallback, get_death_or_fallback
_GenderCode = {
gen.lib.Person.MALE : u'\u2642',
@@ -582,7 +582,7 @@ class RelationshipView(NavigationView):
2, 3, 0, 1, yoptions=0)
# Birth event.
- birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person)
+ birth = get_birth_or_fallback(self.dbstate.db, person)
if birth:
birth_title = birth.get_type()
else:
@@ -593,7 +593,7 @@ class RelationshipView(NavigationView):
subtbl.attach(widgets.BasicLabel(self.format_event(birth)),
2, 3, 1, 2, yoptions=0)
- death = ReportUtils.get_death_or_fallback(self.dbstate.db, person)
+ death = get_death_or_fallback(self.dbstate.db, person)
if death:
death_title = death.get_type()
else:
@@ -1121,7 +1121,7 @@ class RelationshipView(NavigationView):
if not person:
return None
- birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person)
+ birth = get_birth_or_fallback(self.dbstate.db, person)
if birth and birth.get_type() != gen.lib.EventType.BIRTH:
sdate = DateHandler.get_date(birth)
if sdate:
@@ -1133,7 +1133,7 @@ class RelationshipView(NavigationView):
else:
bdate = ""
- death = ReportUtils.get_death_or_fallback(self.dbstate.db, person)
+ death = get_death_or_fallback(self.dbstate.db, person)
if death and death.get_type() != gen.lib.EventType.DEATH:
sdate = DateHandler.get_date(death)
if sdate: