def write_addresses(self): alist = self.person.get_address_list() if len(alist) == 0: return self.doc.start_table("addresses", "IDS-IndTable") self.doc.start_row() self.doc.start_cell("IDS-TableHead", 2) self.doc.start_paragraph("IDS-TableTitle") self.doc.write_text(_("Addresses")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for addr in alist: text = ReportUtils.get_address_str(addr) date = DateHandler.get_date(addr) endnotes = "" if self.use_srcs: endnotes = Endnotes.cite_source(self.bibli, self.database, addr) self.doc.start_row() self.normal_cell(date) self.normal_cell(text, endnotes) self.doc.end_row() self.doc.end_table() self.doc.start_paragraph('IDS-Normal') self.doc.end_paragraph()
def write_alt_names(self): if len(self.person.get_alternate_names()) < 1: return self.doc.start_table("altnames", "IDS-IndTable") self.doc.start_row() self.doc.start_cell("IDS-TableHead", 2) self.doc.start_paragraph("IDS-TableTitle") self.doc.write_text(_("Alternate Names")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for name in self.person.get_alternate_names(): name_type = str(name.get_type()) self.doc.start_row() self.normal_cell(name_type) text = self._name_display.display_name(name) endnotes = "" if self.use_srcs: endnotes = Endnotes.cite_source(self.bibli, self.database, name) self.normal_cell(text, endnotes) self.doc.end_row() self.doc.end_table() self.doc.start_paragraph('IDS-Normal') self.doc.end_paragraph()
def endnotes(self, obj): if not obj or not self.inc_sources: return "" txt = endnotes.cite_source(self.bibli, self.database, obj) if txt: txt = '<super>' + txt + '</super>' return txt
def write_fact(self, event_ref, event, show_type=True): """ Writes a single event. """ role = event_ref.get_role() description = event.get_description() date = DateHandler.get_date(event) place = '' place_handle = event.get_place_handle() if place_handle: place = self.database.get_place_from_handle( place_handle).get_title() date_place = combine(_('%s in %s. '), '%s. ', date, place) if show_type: # Groups with more than one type column_1 = str(event.get_type()) if role not in (EventRoleType.PRIMARY, EventRoleType.FAMILY): column_1 = column_1 + ' (' + str(role) + ')' column_2 = combine('%s, %s', '%s', description, date_place) else: # Groups with a single type (remove event type from first column) column_1 = date column_2 = combine('%s, %s', '%s', description, place) endnotes = "" if self.use_srcs: endnotes = Endnotes.cite_source(self.bibli, self.database, event) self.doc.start_row() self.normal_cell(column_1) self.doc.start_cell('IDS-NormalCell') self.doc.start_paragraph('IDS-Normal') self.doc.write_text(column_2) if endnotes: self.doc.start_superscript() self.doc.write_text(endnotes) self.doc.end_superscript() self.doc.end_paragraph() for notehandle in event.get_note_list(): note = self.database.get_note_from_handle(notehandle) text = note.get_styledtext() note_format = note.get_format() self.doc.write_styled_note( text, note_format, 'IDS-Normal', contains_html=note.get_type() == NoteType.HTML_CODE) self.doc.end_cell() self.doc.end_row()
def write_person(self, count): if count != 0: self.doc.page_break() self.bibli = Bibliography(Bibliography.MODE_DATE | Bibliography.MODE_PAGE) media_list = self.person.get_media_list() name = self._name_display.display(self.person) # feature request 2356: avoid genitive form title = _("Summary of %s") % name mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("IDS-Title") self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_paragraph("IDS-Normal") self.doc.end_paragraph() name = self.person.get_primary_name() text = self._name_display.display_name(name) mark = ReportUtils.get_person_mark(self.database, self.person) endnotes = "" if self.use_srcs: endnotes = Endnotes.cite_source(self.bibli, self.database, name) family_handle = self.person.get_main_parents_family_handle() if family_handle: family = self.database.get_family_from_handle(family_handle) father_inst_id = family.get_father_handle() if father_inst_id: father_inst = self.database.get_person_from_handle( father_inst_id) father = self._name_display.display(father_inst) fmark = ReportUtils.get_person_mark(self.database, father_inst) else: father = "" fmark = None mother_inst_id = family.get_mother_handle() if mother_inst_id: mother_inst = self.database.get_person_from_handle( mother_inst_id) mother = self._name_display.display(mother_inst) mmark = ReportUtils.get_person_mark(self.database, mother_inst) else: mother = "" mmark = None else: father = "" fmark = None mother = "" mmark = None self.doc.start_table('person', 'IDS-PersonTable') self.doc.start_row() self.doc.start_cell('IDS-NormalCell') self.normal_paragraph("%s:" % _("Name")) self.normal_paragraph("%s:" % _("Gender")) self.normal_paragraph("%s:" % _("Father")) self.normal_paragraph("%s:" % _("Mother")) self.doc.end_cell() self.doc.start_cell('IDS-NormalCell') self.normal_paragraph(text, endnotes, mark) if self.person.get_gender() == Person.MALE: self.normal_paragraph(_("Male")) elif self.person.get_gender() == Person.FEMALE: self.normal_paragraph(_("Female")) else: self.normal_paragraph(_("Unknown")) self.normal_paragraph(father, mark=fmark) self.normal_paragraph(mother, mark=mmark) self.doc.end_cell() self.doc.start_cell('IDS-NormalCell') if self.use_images and len(media_list) > 0: media0 = media_list[0] media_handle = media0.get_reference_handle() media = self.database.get_object_from_handle(media_handle) mime_type = media.get_mime_type() if mime_type and mime_type.startswith("image"): filename = media_path_full(self.database, media.get_path()) if os.path.exists(filename): self.doc.add_media_object(filename, "right", 4.0, 4.0, crop=media0.get_rectangle()) else: self._user.warn( _("Could not add photo to page"), "%s: %s" % (filename, _('File does not exist'))) self.doc.end_cell() self.doc.end_row() self.doc.end_table() self.doc.start_paragraph("IDS-Normal") self.doc.end_paragraph() self.write_alt_names() self.write_events() self.write_alt_parents() self.write_families() self.write_addresses() self.write_note() if self.use_srcs: if self.use_pagebreak and self.bibli.get_citation_count(): self.doc.page_break() Endnotes.write_endnotes(self.bibli, self.database, self.doc, printnotes=self.use_srcs_notes)