def write_report(self): if len(report_titles) > 0: report_titles.clear() if len(report_person_ref) > 0: report_person_ref.clear() self.ca = CollectAscendants(self.database, self.user, self.title) self.ascendants = self.ca.collect_data(self.filter, self.center_person) if len(self.ascendants) > 1: self.user.begin_progress(self.title, _('Writing %s reports...') % \ (len(self.ascendants)), len(self.ascendants)) # If there is only one item, then no need for a table # of contents, however if we have more than one lets generate one self.write_toc() report_count = 0 for person_handle in self.ascendants: if len(self.ascendants) > 1: self.user.step_progress() person = self.database.get_person_from_handle(person_handle) self.doc.start_paragraph("DR-Title") name = self._name_display.display(person) if len(self.ascendants) > 1: report_count = report_count + 1 report_titles[report_count] = \ _("%s. Descendants of %s") % (report_count, name) else: report_titles[report_count] = _("Descendants of %s") % name mark = IndexMark(report_titles[report_count], INDEX_TYPE_TOC, 1) self.doc.write_text(report_titles[report_count], mark) self.doc.end_paragraph() recurse = RecurseDown(self.max_generations, self.database, self.objPrint, self._showdups, report_count) recurse.recurse(1, person, None) self.doc.page_break() if len(self.ascendants) > 1: self.user.end_progress()
class DescendantBookReport(Report): def __init__(self, database, options, user): """ Create the DescendantBook object that produces the report. The arguments are: database - the GRAMPS database instance options - instance of the Options class for this report user - a gen.user.User() instance This report needs the following parameters (class variables) that come in the options class. gen - Maximum number of generations to include. name_format - Preferred format to display names dups - Whether to include duplicate descendant trees filter_option - Specific report filter to use. """ Report.__init__(self, database, options, user) menu = options.menu self.user = user self.title = _('Descendants Report') self.max_generations = menu.get_option_by_name('gen').get_value() pid = menu.get_option_by_name('pid').get_value() self.center_person = database.get_person_from_gramps_id(pid) if (self.center_person == None): raise ReportError(_("Person %s is not in the Database") % pid) sort = Sort(self.database) self.by_birthdate_key = sort.by_birthdate_key #Initialize the Printinfo class self._showdups = menu.get_option_by_name('dups').get_value() numbering = menu.get_option_by_name('numbering').get_value() if numbering == "Simple": obj = PrintSimple(self._showdups) elif numbering == "de Villiers/Pama": obj = PrintVilliers() elif numbering == "Meurgey de Tupigny": obj = PrintMeurgey() else: raise AttributeError("no such numbering: '%s'" % self.numbering) marrs = menu.get_option_by_name('marrs').get_value() divs = menu.get_option_by_name('divs').get_value() self.filter_option = menu.get_option_by_name('filter') self.filter = self.filter_option.get_filter() # Copy the global NameDisplay so that we don't change application defaults. self._name_display = copy.deepcopy(global_name_display) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) self.objPrint = Printinfo(self.doc, database, obj, marrs, divs, self._name_display) def write_report(self): if len(report_titles) > 0: report_titles.clear() if len(report_person_ref) > 0: report_person_ref.clear() self.ca = CollectAscendants(self.database, self.user, self.title) self.ascendants = self.ca.collect_data(self.filter, self.center_person) if len(self.ascendants) > 1: self.user.begin_progress(self.title, _('Writing %s reports...') % \ (len(self.ascendants)), len(self.ascendants)) # If there is only one item, then no need for a table # of contents, however if we have more than one lets generate one self.write_toc() report_count = 0 for person_handle in self.ascendants: if len(self.ascendants) > 1: self.user.step_progress() person = self.database.get_person_from_handle(person_handle) self.doc.start_paragraph("DR-Title") name = self._name_display.display(person) if len(self.ascendants) > 1: report_count = report_count + 1 report_titles[report_count] = \ _("%s. Descendants of %s") % (report_count, name) else: report_titles[report_count] = _("Descendants of %s") % name mark = IndexMark(report_titles[report_count], INDEX_TYPE_TOC, 1) self.doc.write_text(report_titles[report_count], mark) self.doc.end_paragraph() recurse = RecurseDown(self.max_generations, self.database, self.objPrint, self._showdups, report_count) recurse.recurse(1, person, None) self.doc.page_break() if len(self.ascendants) > 1: self.user.end_progress() def write_toc(self): if len(self.ascendants) <= 1: return self.doc.start_paragraph("DR-Title") title = _("Descendant Report") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_paragraph("DR-TOC-Title") title = _("Table Of Contents") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() report_count = 0 for asc_handle in self.ascendants: person = self.database.get_person_from_handle(asc_handle) name = self._name_display.display_name(person.get_primary_name()) report_count = report_count + 1 self.doc.start_paragraph("DR-TOC-Detail") text = _("%d. %s") % (report_count, name) mark = IndexMark(text, INDEX_TYPE_TOC, 2) self.doc.write_text(text, mark) self.doc.end_paragraph() self.doc.page_break()
class DescendantBookReport(Report): def __init__(self, database, options, user): """ Create the DescendantBook object that produces the report. The arguments are: database - the GRAMPS database instance options - instance of the Options class for this report user - a gen.user.User() instance This report needs the following parameters (class variables) that come in the options class. gen - Maximum number of generations to include. name_format - Preferred format to display names dups - Whether to include duplicate descendant trees filter_option - Specific report filter to use. """ Report.__init__(self, database, options, user) menu = options.menu self.user = user self.title = _('Descendants Report') self.max_generations = menu.get_option_by_name('gen').get_value() pid = menu.get_option_by_name('pid').get_value() self.center_person = database.get_person_from_gramps_id(pid) if (self.center_person == None) : raise ReportError(_("Person %s is not in the Database") % pid ) sort = Sort(self.database) self.by_birthdate_key = sort.by_birthdate_key #Initialize the Printinfo class self._showdups = menu.get_option_by_name('dups').get_value() numbering = menu.get_option_by_name('numbering').get_value() if numbering == "Simple": obj = PrintSimple(self._showdups) elif numbering == "de Villiers/Pama": obj = PrintVilliers() elif numbering == "Meurgey de Tupigny": obj = PrintMeurgey() else: raise AttributeError("no such numbering: '%s'" % self.numbering) marrs = menu.get_option_by_name('marrs').get_value() divs = menu.get_option_by_name('divs').get_value() self.filter_option = menu.get_option_by_name('filter') self.filter = self.filter_option.get_filter() # Copy the global NameDisplay so that we don't change application defaults. self._name_display = copy.deepcopy(global_name_display) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) self.objPrint = Printinfo(self.doc, database, obj, marrs, divs, self._name_display) def write_report(self): if len(report_titles) > 0: report_titles.clear() if len(report_person_ref) > 0: report_person_ref.clear() self.ca = CollectAscendants(self.database, self.user, self.title) self.ascendants = self.ca.collect_data(self.filter, self.center_person) if len(self.ascendants) > 1: self.user.begin_progress(self.title, _('Writing %s reports...') % \ (len(self.ascendants)), len(self.ascendants)) # If there is only one item, then no need for a table # of contents, however if we have more than one lets generate one self.write_toc() report_count = 0 for person_handle in self.ascendants: if len(self.ascendants) > 1: self.user.step_progress() person = self.database.get_person_from_handle(person_handle) self.doc.start_paragraph("DR-Title") name = self._name_display.display(person) if len(self.ascendants) > 1: report_count = report_count + 1 report_titles[report_count] = \ _("%s. Descendants of %s") % (report_count, name) else: report_titles[report_count] = _("Descendants of %s") % name mark = IndexMark(report_titles[report_count], INDEX_TYPE_TOC, 1) self.doc.write_text(report_titles[report_count], mark) self.doc.end_paragraph() recurse = RecurseDown(self.max_generations, self.database, self.objPrint, self._showdups, report_count) recurse.recurse(1, person, None) self.doc.page_break() if len(self.ascendants) > 1: self.user.end_progress() def write_toc(self): if len(self.ascendants) <= 1: return self.doc.start_paragraph("DR-Title") title = _("Descendant Report") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_paragraph("DR-TOC-Title") title = _("Table Of Contents") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() report_count = 0 for asc_handle in self.ascendants: person = self.database.get_person_from_handle(asc_handle) name = self._name_display.display_name(person.get_primary_name()) report_count = report_count + 1 self.doc.start_paragraph("DR-TOC-Detail") text = _("%d. %s") % (report_count, name) mark = IndexMark(text, INDEX_TYPE_TOC, 2) self.doc.write_text(text, mark) self.doc.end_paragraph() self.doc.page_break()