Fix handle errors in reports

The find_spouse report utility function can return None.
This commit is contained in:
Nick Hall 2015-12-13 18:53:32 +00:00
parent 997da5170d
commit 5fc7dd6874
4 changed files with 29 additions and 25 deletions

View File

@ -528,8 +528,9 @@ class RecurseDown:
father if s_level else myself) father if s_level else myself)
spouse_handle = ReportUtils.find_spouse(person, family) spouse_handle = ReportUtils.find_spouse(person, family)
if self.max_spouses > s_level and \ if (self.max_spouses > s_level and
spouse_handle not in self.families_seen: spouse_handle and
spouse_handle not in self.families_seen):
def _spouse_box(who): def _spouse_box(who):
return self.add_person_box((x_level, s_level+1), return self.add_person_box((x_level, s_level+1),
spouse_handle, family_handle, who) spouse_handle, family_handle, who)

View File

@ -1987,23 +1987,23 @@ class Narrator(object):
:rtype: unicode :rtype: unicode
""" """
spouse_handle = ReportUtils.find_spouse(self.__person, family)
spouse = self.__db.get_person_from_handle(spouse_handle)
event = ReportUtils.find_marriage(self.__db, family)
date = self.__empty_date date = self.__empty_date
place = self.__empty_place place = self.__empty_place
spouse_name = None
spouse_handle = ReportUtils.find_spouse(self.__person, family)
if spouse_handle:
spouse = self.__db.get_person_from_handle(spouse_handle)
if spouse: if spouse:
if not name_display: if not name_display:
spouse_name = _nd.display(spouse) spouse_name = _nd.display(spouse)
else: else:
spouse_name = name_display.display(spouse) spouse_name = name_display.display(spouse)
if not spouse_name: if not spouse_name:
spouse_name = self.__translate_text("Unknown")
else:
# not all families have a spouse.
spouse_name = self.__translate_text("Unknown") # not: _("Unknown") spouse_name = self.__translate_text("Unknown") # not: _("Unknown")
event = ReportUtils.find_marriage(self.__db, family)
if event: if event:
if self.__use_fulldate : if self.__use_fulldate :
mdate = self.__get_date(event.get_date_object()) mdate = self.__get_date(event.get_date_object())

View File

@ -526,13 +526,16 @@ class DetAncestorReport(Report):
is_first = True is_first = True
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
spouse_handle = ReportUtils.find_spouse(person,family) spouse_handle = ReportUtils.find_spouse(person, family)
if spouse_handle:
spouse = self.db.get_person_from_handle(spouse_handle) spouse = self.db.get_person_from_handle(spouse_handle)
spouse_mark = ReportUtils.get_person_mark(self.db, spouse) spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
text = "" else:
text = self.__narrator.get_married_string(family, is_first, spouse_mark = None
self._name_display)
text = self.__narrator.get_married_string(family,
is_first,
self._name_display)
if text: if text:
self.doc.write_text_citation(text, spouse_mark) self.doc.write_text_citation(text, spouse_mark)
is_first = False is_first = False

View File

@ -527,15 +527,15 @@ class DetDescendantReport(Report):
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
spouse_handle = ReportUtils.find_spouse(person, family) spouse_handle = ReportUtils.find_spouse(person, family)
if spouse_handle:
spouse = self.db.get_person_from_handle(spouse_handle) spouse = self.db.get_person_from_handle(spouse_handle)
text = ""
spouse_mark = ReportUtils.get_person_mark(self.db, spouse) spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
else:
spouse_mark = None
text = self.__narrator.get_married_string(family, text = self.__narrator.get_married_string(family,
is_first, is_first,
self._name_display) self._name_display)
if text: if text:
self.doc.write_text_citation(text, spouse_mark) self.doc.write_text_citation(text, spouse_mark)
is_first = False is_first = False