From 8d08b62c8dcaa0f58db4136adf67ba7bc8f4d319 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Wed, 2 Mar 2016 09:13:35 -0600 Subject: [PATCH] 9284: Narrative Report with BSDDB, additional fixes and test --- gramps/plugins/test/test_reports.py | 14 ++++++++++-- gramps/plugins/webreport/narrativeweb.py | 29 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/gramps/plugins/test/test_reports.py b/gramps/plugins/test/test_reports.py index e7df34e01..d98580e1b 100644 --- a/gramps/plugins/test/test_reports.py +++ b/gramps/plugins/test/test_reports.py @@ -102,16 +102,26 @@ reports = ReportControl() # If you could run all reports in a standard way: #reports.testall(TestDynamic) -def output_contains(text): +def report_contains(text): def test_output_file(out, err, report_name): contents = open(report_name + ".txt").read() print(contents) return text in contents return test_output_file +def err_does_not_contain(text): + def test_output_file(out, err, report_name): + print(err) + return text not in err + return test_output_file + reports.addtest(TestDynamic, "tag_report", - output_contains("I0037 Smith, Edwin Michael"), + report_contains("I0037 Smith, Edwin Michael"), 'off=txt,tag=tag1') +reports.addtest(TestDynamic, "navwebpage", + err_does_not_contain("Failed to write report."), + 'off=html') + if __name__ == "__main__": unittest.main() diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 66e9e60d4..bb52147f4 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -6053,7 +6053,10 @@ class PersonPages(BasePage): if gen_nr > maxgen: return tree gen_offset = int(max_size / pow(2, gen_nr+1)) - person = self.dbase_.get_person_from_handle(person_handle) + if person_handle: + person = self.dbase_.get_person_from_handle(person_handle) + else: + person = None if not person: return tree @@ -6160,9 +6163,10 @@ class PersonPages(BasePage): for birthdate, handle in children: if handle == self.person.get_handle(): child_ped(ol) - else: + elif handle: child = self.dbase_.get_person_from_handle(handle) - ol += Html("li") + self.pedigree_person(child) + if child: + ol += Html("li") + self.pedigree_person(child) else: child_ped(ol) return ol @@ -6181,8 +6185,14 @@ class PersonPages(BasePage): family = self.dbase_.get_family_from_handle(parent_handle) father_handle = family.get_father_handle() mother_handle = family.get_mother_handle() - mother = self.dbase_.get_person_from_handle(mother_handle) - father = self.dbase_.get_person_from_handle(father_handle) + if mother_handle: + mother = self.dbase_.get_person_from_handle(mother_handle) + else: + mother = None + if father_handle: + father = self.dbase_.get_person_from_handle(father_handle) + else: + father = None else: family = None father = None @@ -6588,9 +6598,10 @@ class PersonPages(BasePage): pedsp += [childol] for child_ref in childlist: child = self.dbase_.get_person_from_handle(child_ref.ref) - childol += (Html("li") + - self.pedigree_person(child) - ) + if child: + childol += (Html("li") + + self.pedigree_person(child) + ) return ped def display_event_header(self): @@ -7718,7 +7729,7 @@ class NavWebReport(Report): self.write_gendex(gendex_io, person) else: self.write_gendex(fp_gendex, person) - self.close_file(fp_gendex, gendex_io, date) + self.close_file(fp_gendex, gendex_io, 0) def write_gendex(self, fp, person): """