Fix handle errors in reports
The find_spouse report utility function can return None.
This commit is contained in:
parent
997da5170d
commit
5fc7dd6874
@ -528,8 +528,9 @@ class RecurseDown:
|
||||
father if s_level else myself)
|
||||
|
||||
spouse_handle = ReportUtils.find_spouse(person, family)
|
||||
if self.max_spouses > s_level and \
|
||||
spouse_handle not in self.families_seen:
|
||||
if (self.max_spouses > s_level and
|
||||
spouse_handle and
|
||||
spouse_handle not in self.families_seen):
|
||||
def _spouse_box(who):
|
||||
return self.add_person_box((x_level, s_level+1),
|
||||
spouse_handle, family_handle, who)
|
||||
|
@ -1987,23 +1987,23 @@ class Narrator(object):
|
||||
: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
|
||||
place = self.__empty_place
|
||||
if spouse:
|
||||
if not name_display:
|
||||
spouse_name = _nd.display(spouse)
|
||||
else:
|
||||
spouse_name = name_display.display(spouse)
|
||||
if not spouse_name:
|
||||
spouse_name = self.__translate_text("Unknown")
|
||||
else:
|
||||
# not all families have a spouse.
|
||||
|
||||
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 not name_display:
|
||||
spouse_name = _nd.display(spouse)
|
||||
else:
|
||||
spouse_name = name_display.display(spouse)
|
||||
if not spouse_name:
|
||||
spouse_name = self.__translate_text("Unknown") # not: _("Unknown")
|
||||
|
||||
event = ReportUtils.find_marriage(self.__db, family)
|
||||
if event:
|
||||
if self.__use_fulldate :
|
||||
mdate = self.__get_date(event.get_date_object())
|
||||
|
@ -526,13 +526,16 @@ class DetAncestorReport(Report):
|
||||
is_first = True
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
spouse_handle = ReportUtils.find_spouse(person,family)
|
||||
spouse = self.db.get_person_from_handle(spouse_handle)
|
||||
spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
|
||||
text = ""
|
||||
text = self.__narrator.get_married_string(family, is_first,
|
||||
self._name_display)
|
||||
spouse_handle = ReportUtils.find_spouse(person, family)
|
||||
if spouse_handle:
|
||||
spouse = self.db.get_person_from_handle(spouse_handle)
|
||||
spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
|
||||
else:
|
||||
spouse_mark = None
|
||||
|
||||
text = self.__narrator.get_married_string(family,
|
||||
is_first,
|
||||
self._name_display)
|
||||
if text:
|
||||
self.doc.write_text_citation(text, spouse_mark)
|
||||
is_first = False
|
||||
|
@ -527,15 +527,15 @@ class DetDescendantReport(Report):
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
spouse_handle = ReportUtils.find_spouse(person, family)
|
||||
spouse = self.db.get_person_from_handle(spouse_handle)
|
||||
|
||||
text = ""
|
||||
spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
|
||||
if spouse_handle:
|
||||
spouse = self.db.get_person_from_handle(spouse_handle)
|
||||
spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
|
||||
else:
|
||||
spouse_mark = None
|
||||
|
||||
text = self.__narrator.get_married_string(family,
|
||||
is_first,
|
||||
self._name_display)
|
||||
|
||||
if text:
|
||||
self.doc.write_text_citation(text, spouse_mark)
|
||||
is_first = False
|
||||
|
Loading…
Reference in New Issue
Block a user