def run(database, document, obj): """ Display link references for this note. """ # setup the simple access functions sdb = SimpleAccess(database) sdoc = SimpleDoc(document) stab = QuickTable(sdb) # display the title sdoc.title(_("Link References for this note")) sdoc.paragraph("\n") stab.columns(_("Type"), _("Reference"), _("Link check")) for (ldomain, ltype, lprop, lvalue) in obj.get_links(): if ldomain == "gramps": tagtype = _(ltype) ref_obj = sdb.get_link(ltype, lprop, lvalue) if ref_obj: tagvalue = ref_obj tagcheck = _("Ok") else: tagvalue = lvalue tagcheck = _("Failed: missing object") else: tagtype = _("Internet") tagvalue = lvalue tagcheck = "" stab.row(tagtype, tagvalue, tagcheck) if stab.get_row_count() > 0: stab.write(sdoc) document.has_data = True else: sdoc.paragraph(_("No link references for this note")) sdoc.paragraph("") document.has_data = False sdoc.paragraph("")
def run(database, document, obj): """ Display link references for this note. """ # setup the simple access functions sdb = SimpleAccess(database) sdoc = SimpleDoc(document) stab = QuickTable(sdb) # display the title sdoc.title(_("Link References for this note")) sdoc.paragraph("\n") stab.columns(_("Type"), _("Reference"), _("Link check")) for (ldomain, ltype, lprop, lvalue) in obj.get_links(): if ldomain == "gramps": tagtype = _(ltype) ref_obj = sdb.get_link(ltype, lprop, lvalue) if ref_obj: tagvalue = ref_obj tagcheck = _("Ok") else: tagvalue = styledtext_tag.value tagcheck = _("Failed: missing object") else: tagtype = _("Internet") tagvalue = lvalue tagcheck = "" stab.row(tagtype, tagvalue, tagcheck) if stab.get_row_count() > 0: stab.write(sdoc) document.has_data = True else: sdoc.paragraph(_("No link references for this note")) sdoc.paragraph("") document.has_data = False sdoc.paragraph("")
def write_report(self): """ The routine that actually creates the report. At this point, the document is opened and ready for writing. """ sdb = SimpleAccess(self.database) self.doc.start_paragraph("NoteLink-Title") title = _("Note Link Check Report") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_table('NoteLinkTable', 'NoteLink-Table') self.doc.start_row() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Note ID")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Link Type")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Links To")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Status")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for note in self.database.iter_notes(): for (ldomain, ltype, lprop, lvalue) in note.get_links(): if ldomain == "gramps": tagtype = _(ltype) ref_obj = sdb.get_link(ltype, lprop, lvalue) if ref_obj: tagvalue = sdb.describe(ref_obj) tagcheck = _("Ok") else: tagvalue = "%s://%s/%s/%s" % (ldomain, ltype, lprop, lvalue) tagcheck = _("Failed") else: tagtype = _("Internet") tagvalue = lvalue tagcheck = "" self.doc.start_row() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(note.gramps_id) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(tagtype) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(tagvalue) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(tagcheck) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def write_report(self): """ The routine that actually creates the report. At this point, the document is opened and ready for writing. """ sdb = SimpleAccess(self.database) self.doc.start_paragraph("NoteLink-Title") title = _("Note Link Check Report") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_table('NoteLinkTable','NoteLink-Table') self.doc.start_row() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Note ID")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Link Type")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Links To")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal-Bold') self.doc.write_text(_("Status")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for note in self.database.iter_notes(): for (ldomain, ltype, lprop, lvalue) in note.get_links(): if ldomain == "gramps": tagtype = _(ltype) ref_obj = sdb.get_link(ltype, lprop, lvalue) if ref_obj: tagvalue = sdb.describe(ref_obj) tagcheck = _("Ok") else: tagvalue = "%s://%s/%s/%s" % (ldomain, ltype, lprop, lvalue) tagcheck = _("Failed") else: tagtype = _("Internet") tagvalue = lvalue tagcheck = "" self.doc.start_row() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(note.gramps_id) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(tagtype) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(tagvalue) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('NoteLink-TableCell') self.doc.start_paragraph('NoteLink-Normal') self.doc.write_text(tagcheck) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()