def write_events(self): elist = self.database.get_event_handles() FilterClass = GenericFilterFactory('Event') filter = FilterClass() filter.add_rule(rules.event.HasTag([self.tag])) event_list = filter.apply(self.database, elist) if not event_list: return self.doc.start_paragraph("TR-Heading") header = self._("Events") mark = IndexMark(header, INDEX_TYPE_TOC, 2) self.doc.write_text(header, mark) self.doc.end_paragraph() self.doc.start_table('EventTable','TR-Table') self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Id")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Type")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Participants")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Date")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for event_handle in event_list: event = self.database.get_event_from_handle(event_handle) self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(event.get_gramps_id()) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(str(event.get_type())) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(get_participant_from_event(self.database, event_handle)) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') date = get_date(event) if date: self.doc.write_text(date) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def write_media(self): mlist = self.database.get_media_object_handles(sort_handles=True) FilterClass = GenericFilterFactory('Media') filter = FilterClass() filter.add_rule(rules.media.HasTag([self.tag])) media_list = filter.apply(self.database, mlist) if not media_list: return self.doc.start_paragraph("TR-Heading") header = self._("Media") mark = IndexMark(header, INDEX_TYPE_TOC, 2) self.doc.write_text(header ,mark) self.doc.end_paragraph() self.doc.start_table('MediaTable','TR-Table') self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Id")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Title")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Type")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Date")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for media_handle in media_list: media = self.database.get_object_from_handle(media_handle) self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(media.get_gramps_id()) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') title = media.get_description() self.doc.write_text(str(title)) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') mime_type = media.get_mime_type() self.doc.write_text(str(mime_type)) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') date = get_date(media) if date: self.doc.write_text(date) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def format_date(self, date): return get_date(date)
def write_people(self): plist = self.database.iter_person_handles() FilterClass = GenericFilterFactory('Person') filter = FilterClass() filter.add_rule(rules.person.HasTag([self.tag])) ind_list = filter.apply(self.database, plist) if not ind_list: return self.doc.start_paragraph("TR-Heading") header = self._("People") mark = IndexMark(header, INDEX_TYPE_TOC, 2) self.doc.write_text(header, mark) self.doc.end_paragraph() self.doc.start_table('PeopleTable','TR-Table') self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Id")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Name")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Birth")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Death")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for person_handle in ind_list: person = self.database.get_person_from_handle(person_handle) self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(person.get_gramps_id()) self.doc.end_paragraph() self.doc.end_cell() name = self._name_display.display(person) mark = ReportUtils.get_person_mark(self.database, person) self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(name, mark) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') birth_ref = person.get_birth_ref() if birth_ref: event = self.database.get_event_from_handle(birth_ref.ref) self.doc.write_text(get_date( event )) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') death_ref = person.get_death_ref() if death_ref: event = self.database.get_event_from_handle(death_ref.ref) self.doc.write_text(get_date( event )) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def listeventref(self): sc = {'source': 'S_ID', 'citalist': 'C_ID'} stc = {} citation_without_notes = 0 EMPTY = " " def toYear(date): yeartext = date.get_year() return yeartext # build citation list cl cl = [] i = 1 for ci in self.__db.iter_citations(): if ci.source_handle in self.source_handles: # sc[ci.source_handle].append(ci.handle) cl.append(ci.handle) # build citations - event dic xy #(a,b): set([('Citation', 'c4a8c46041e08799b17')]) # event: c4a8c4f95b01e38564a event: Taufe #!! # Nur Taufen ! ci = defaultdict(list) for ev in self.__db.iter_events(): if ev.type.is_marriage(): evcithandlelist = ev.get_referenced_citation_handles() for (a, b) in evcithandlelist: if b in cl: ci[b].append(ev.handle) cikeys = ci.keys() for di in cikeys: print((di), di in cl) print(len(cikeys)) print("CITA", len(ci.keys()), len(sc.values())) # print ("SOURCE", len(sc.keys()), len(sc.values()), len(sc[0]) ) # build citasource dictionary sc = defaultdict(list) for ci2 in self.__db.iter_citations(): if ci2.handle in cikeys: print("HALLO ", ci2, ci2.source_handle) sc[ci2.source_handle].append(ci2.handle) sckeys = sc.keys() for di in sckeys: print((di), sc[di]) print(len(sckeys), len(sc[di])) # build eventpersonrole dictionary # event: c4a8c4f95b01e38564a event: Taufe refhandlelist = [] pedic = {} pedic = defaultdict(list) for pe in self.__db.get_person_handles(): for eventref in self.__db.get_person_from_handle( pe).event_ref_list: pedic[eventref.ref].append((eventref.get_role(), pe)) # #source # skeys = sc.keys() # skeys.sort(key=lambda x:self._formatlocal_source_text(self.__db.get_source_from_handle(x))) # for s in skeys: for s in sorted(sc.keys()): self._user.step_progress() self.doc.start_paragraph("SRC-SourceTitle") self.doc.write_text( self._formatlocal_source_text( self.__db.get_source_from_handle(s))) self.doc.end_paragraph() self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" ID: %s") % self.__db.get_source_from_handle(s).gramps_id) self.doc.end_paragraph() # note in sources for sourcenotehandle in self.__db.get_source_from_handle( s).get_note_list(): self.doc.start_paragraph("SRC-NoteDetails") self.doc.write_text( _(" Type: %s") % self.__db.get_note_from_handle(sourcenotehandle).type) self.doc.write_text( _(" N-ID: %s") % self.__db.get_note_from_handle(sourcenotehandle).gramps_id) self.doc.end_paragraph() self.doc.start_paragraph("SRC-NoteText") self.doc.write_text( _(" %s") % self.__db.get_note_from_handle(sourcenotehandle).text) self.doc.end_paragraph() self.doc.start_table("EventTable", "SRC-EventTable") column_titles = [ _("LNr"), _("Source"), _("Date"), _("Person"), _("Parents"), _("Age / Wittness"), _("Text") ] self.doc.start_row() for title in column_titles: self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(title) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() i = 1 ckeys = sc[s] ckeys.sort( key=lambda x: self.__db.get_citation_from_handle(x).page) for c in ckeys: # c contains citationhandles self._user.step_progress() self.doc.start_row() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%d") % i) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" %s") % self.__db.get_citation_from_handle(c).page) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" %s ") % get_date(self.__db.get_citation_from_handle(c))) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") for e in ci[c]: event = self.__db.get_event_from_handle(e) self.doc.write_text(_("%s") % event.get_type()) self.doc.write_text(_(" ( %s )") % event.gramps_id) self.doc.end_paragraph() self.doc.end_cell() # Brautleute self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") for e in ci[c]: event = self.__db.get_event_from_handle(e) ref_handles = [ x for x in self.database.find_backlink_handles(e) ] # print(mi, evt_handle) for (ref_type, ref_handle) in ref_handles: if ref_type == 'Person': continue else: family = self.database.get_family_from_handle( ref_handle) father_handle = family.get_father_handle() mother_handle = family.get_mother_handle() if father_handle: fp = self.database.get_person_from_handle( father_handle) father_name = \ fp.primary_name.get_name() # self._name_display.display_name(fp.get_primary_name()).lower() father_name = father_name + (_(" [%s]") % fp.gramps_id) else: father_name = _("unknown") if mother_handle: mp = self.database.get_person_from_handle( mother_handle) mother_name = \ mp.primary_name.get_name() # self._name_display.display_name(fp.get_primary_name()).lower() mother_name = mother_name + (_(" [%s]") % mp.gramps_id) else: mother_name = _("unknown") famo_name = father_name + " " + mother_name self.doc.write_text(_("%s") % famo_name) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() i += 1 self.doc.end_table()
def __init__(self, dbstate, uistate, track, handle1, handle2): ManagedWindow.__init__(self, uistate, track, self.__class__) self.dbstate = dbstate database = dbstate.db self.ev1 = database.get_event_from_handle(handle1) self.ev2 = database.get_event_from_handle(handle2) self.define_glade('mergeevent', _GLADE_FILE) self.set_window(self._gladeobj.toplevel, self.get_widget("event_title"), _("Merge Events")) self.setup_configs('interface.merge-event', 500, 250) # Detailed selection widgets type1 = str(self.ev1.get_type()) type2 = str(self.ev2.get_type()) entry1 = self.get_widget("type1") entry2 = self.get_widget("type2") entry1.set_text(type1) entry2.set_text(type2) if entry1.get_text() == entry2.get_text(): for widget_name in ('type1', 'type2', 'type_btn1', 'type_btn2'): self.get_widget(widget_name).set_sensitive(False) entry1 = self.get_widget("date1") entry2 = self.get_widget("date2") entry1.set_text(get_date(self.ev1)) entry2.set_text(get_date(self.ev2)) if entry1.get_text() == entry2.get_text(): for widget_name in ('date1', 'date2', 'date_btn1', 'date_btn2'): self.get_widget(widget_name).set_sensitive(False) place1 = self.ev1.get_place_handle() if place1: place1 = database.get_place_from_handle(place1) place2 = self.ev2.get_place_handle() if place2: place2 = database.get_place_from_handle(place2) place1 = place1.get_title() if place1 else "" place2 = place2.get_title() if place2 else "" entry1 = self.get_widget("place1") entry2 = self.get_widget("place2") entry1.set_text(place1) entry2.set_text(place2) if entry1.get_text() == entry2.get_text(): for widget_name in ('place1', 'place2', 'place_btn1', 'place_btn2'): self.get_widget(widget_name).set_sensitive(False) entry1 = self.get_widget("desc1") entry2 = self.get_widget("desc2") entry1.set_text(self.ev1.get_description()) entry2.set_text(self.ev2.get_description()) if entry1.get_text() == entry2.get_text(): for widget_name in ('desc1', 'desc2', 'desc_btn1', 'desc_btn2'): self.get_widget(widget_name).set_sensitive(False) gramps1 = self.ev1.get_gramps_id() gramps2 = self.ev2.get_gramps_id() entry1 = self.get_widget("gramps1") entry2 = self.get_widget("gramps2") entry1.set_text(gramps1) entry2.set_text(gramps2) if entry1.get_text() == entry2.get_text(): for widget_name in ('gramps1', 'gramps2', 'gramps_btn1', 'gramps_btn2'): self.get_widget(widget_name).set_sensitive(False) # Main window widgets that determine which handle survives ppant1 = get_participant_from_event(database, handle1) ppant2 = get_participant_from_event(database, handle2) rbutton1 = self.get_widget("handle_btn1") rbutton_label1 = self.get_widget("label_handle_btn1") rbutton_label2 = self.get_widget("label_handle_btn2") rbutton_label1.set_label("%s %s [%s]" % (type1, ppant1, gramps1)) rbutton_label2.set_label("%s %s [%s]" % (type2, ppant2, gramps2)) rbutton1.connect("toggled", self.on_handle1_toggled) self.connect_button("event_help", self.cb_help) self.connect_button("event_ok", self.cb_merge) self.connect_button("event_cancel", self.close) self.show()
def __init__(self, dbstate, uistate, handle1, handle2): ManagedWindow.__init__(self, uistate, [], self.__class__) self.dbstate = dbstate database = dbstate.db self.citation1 = database.get_citation_from_handle(handle1) self.citation2 = database.get_citation_from_handle(handle2) self.define_glade('mergecitation', _GLADE_FILE) self.set_window(self._gladeobj.toplevel, self.get_widget('citation_title'), _("Merge Citations")) # Detailed Selection widgets page1 = self.citation1.get_page() page2 = self.citation2.get_page() entry1 = self.get_widget("page1") entry2 = self.get_widget("page2") entry1.set_text(page1) entry2.set_text(page2) if entry1.get_text() == entry2.get_text(): for widget_name in ('page1', 'page2', 'page_btn1', 'page_btn2'): self.get_widget(widget_name).set_sensitive(False) entry1 = self.get_widget("date1") entry2 = self.get_widget("date2") entry1.set_text(get_date(self.citation1)) entry2.set_text(get_date(self.citation2)) if entry1.get_text() == entry2.get_text(): for widget_name in ('date1', 'date2', 'date_btn1', 'date_btn2'): self.get_widget(widget_name).set_sensitive(False) entry1 = self.get_widget("confidence1") entry2 = self.get_widget("confidence2") entry1.set_text(_(conf_strings[self.citation1.get_confidence_level()])) entry2.set_text(_(conf_strings[self.citation2.get_confidence_level()])) if entry1.get_text() == entry2.get_text(): for widget_name in ('confidence1', 'confidence2', 'confidence_btn1', 'confidence_btn2'): self.get_widget(widget_name).set_sensitive(False) gramps1 = self.citation1.get_gramps_id() gramps2 = self.citation2.get_gramps_id() entry1 = self.get_widget("gramps1") entry2 = self.get_widget("gramps2") entry1.set_text(gramps1) entry2.set_text(gramps2) if entry1.get_text() == entry2.get_text(): for widget_name in ('gramps1', 'gramps2', 'gramps_btn1', 'gramps_btn2'): self.get_widget(widget_name).set_sensitive(False) # Main window widgets that determine which handle survives rbutton1 = self.get_widget("handle_btn1") rbutton_label1 = self.get_widget("label_handle_btn1") rbutton_label2 = self.get_widget("label_handle_btn2") rbutton_label1.set_label(page1 + " [" + gramps1 + "]") rbutton_label2.set_label(page2 + " [" + gramps2 + "]") rbutton1.connect("toggled", self.on_handle1_toggled) self.connect_button('citation_help', self.cb_help) self.connect_button('citation_ok', self.cb_merge) self.connect_button('citation_cancel', self.close) self.show()
def run(database, document, filter_name, *args, **kwargs): """ Loops through the families that the person is a child in, and display the information about the other children. """ # setup the simple access functions sdb = SimpleAccess(database) sdoc = SimpleDoc(document) stab = QuickTable(sdb) if (filter_name == 'all'): sdoc.title(_("Summary counts of current selection")) sdoc.paragraph("") sdoc.paragraph( _("Right-click row (or press ENTER) to see selected items.")) sdoc.paragraph("") stab.columns(_("Object"), _("Count/Total")) if hasattr(database, "db"): stab.row([_("People"), "Filter", "Person"], "%d/%d" % (len(database.get_person_handles()), len(database.db.get_person_handles()))) stab.row([_("Families"), "Filter", "Family"], "%d/%d" % (len(database.get_family_handles()), len(database.db.get_family_handles()))) stab.row([_("Events"), "Filter", "Event"], "%d/%d" % (len(database.get_event_handles()), len(database.db.get_event_handles()))) stab.row([_("Places"), "Filter", "Place"], "%d/%d" % (len(database.get_place_handles()), len(database.db.get_place_handles()))) stab.row([_("Sources"), "Filter", "Source"], "%d/%d" % (len(database.get_source_handles()), len(database.db.get_source_handles()))) stab.row([_("Repositories"), "Filter", "Repository"], "%d/%d" % (len(database.get_repository_handles()), len(database.db.get_repository_handles()))) stab.row([_("Media"), "Filter", "Media"], "%d/%d" % (len(database.get_media_handles()), len(database.db.get_media_handles()))) stab.row([_("Notes"), "Filter", "Note"], "%d/%d" % (len(database.get_note_handles()), len(database.db.get_note_handles()))) else: stab.row([_("People"), "Filter", "Person"], "%d/%d" % (len(database.get_person_handles()), len(database.basedb.get_person_handles()))) stab.row([_("Families"), "Filter", "Family"], "%d/%d" % (len(database.get_family_handles()), len(database.basedb.get_family_handles()))) stab.row([_("Events"), "Filter", "Event"], "%d/%d" % (len(database.get_event_handles()), len(database.basedb.get_event_handles()))) stab.row([_("Places"), "Filter", "Place"], "%d/%d" % (len(database.get_place_handles()), len(database.basedb.get_place_handles()))) stab.row([_("Sources"), "Filter", "Source"], "%d/%d" % (len(database.get_source_handles()), len(database.basedb.get_source_handles()))) stab.row([_("Repositories"), "Filter", "Repository"], "%d/%d" % (len(database.get_repository_handles()), len(database.basedb.get_repository_handles()))) stab.row([_("Media"), "Filter", "Media"], "%d/%d" % (len(database.get_media_handles()), len(database.basedb.get_media_handles()))) stab.row([_("Notes"), "Filter", "Note"], "%d/%d" % (len(database.get_note_handles()), len(database.basedb.get_note_handles()))) sdoc.paragraph("") stab.write(sdoc) return # display the title if filter_name in fname_map: sdoc.title(_("Filtering on %s") % fname_map[filter_name]) # listed above else: sdoc.title(_("Filtering on %s") % _(filter_name)) sdoc.paragraph("") matches = 0 if (filter_name == 'Inverse Person'): sdb.dbase = database.db stab.columns(_("Person"), _("Gramps ID"), _("Birth Date")) proxy_handles = set(database.iter_person_handles()) for person in database.db.iter_people(): if person.handle not in proxy_handles: stab.row(person, person.gramps_id, sdb.birth_or_fallback(person)) matches += 1 elif (filter_name == 'Inverse Family'): sdb.dbase = database.db stab.columns(_("Family"), _("Gramps ID")) proxy_handles = set(database.iter_family_handles()) for family in database.db.iter_families(): if family.handle not in proxy_handles: stab.row(family, family.gramps_id) matches += 1 elif (filter_name == 'Inverse Event'): sdb.dbase = database.db stab.columns(_("Event"), _("Gramps ID")) proxy_handles = set(database.iter_event_handles()) for event in database.db.iter_events(): if event.handle not in proxy_handles: stab.row(event, event.gramps_id) matches += 1 elif (filter_name == 'Inverse Place'): sdb.dbase = database.db stab.columns(_("Place"), _("Gramps ID")) proxy_handles = set(database.iter_place_handles()) for place in database.db.iter_places(): if place.handle not in proxy_handles: stab.row(place, place.gramps_id) matches += 1 elif (filter_name == 'Inverse Source'): sdb.dbase = database.db stab.columns(_("Source"), _("Gramps ID")) proxy_handles = set(database.iter_source_handles()) for source in database.db.iter_sources(): if source.handle not in proxy_handles: stab.row(source, source.gramps_id) matches += 1 elif (filter_name == 'Inverse Repository'): sdb.dbase = database.db stab.columns(_("Repository"), _("Gramps ID")) proxy_handles = set(database.iter_repository_handles()) for repository in database.db.iter_repositories(): if repository.handle not in proxy_handles: stab.row(repository, repository.gramps_id) matches += 1 elif (filter_name == 'Inverse Media'): sdb.dbase = database.db stab.columns(_("Media"), _("Gramps ID")) proxy_handles = set(database.iter_media_handles()) for media in database.db.iter_media(): if media.handle not in proxy_handles: stab.row(media, media.gramps_id) matches += 1 elif (filter_name == 'Inverse Note'): sdb.dbase = database.db stab.columns(_("Note"), _("Gramps ID")) proxy_handles = set(database.iter_note_handles()) for note in database.db.iter_notes(): if note.handle not in proxy_handles: stab.row(note, note.gramps_id) matches += 1 elif (filter_name in ['all people', 'Person']): stab.columns(_("Person"), _("Gramps ID"), _("Birth Date")) for person in database.iter_people(): stab.row(person, person.gramps_id, sdb.birth_or_fallback(person)) matches += 1 elif (filter_name in ['all families', 'Family']): stab.columns(_("Family"), _("Gramps ID")) for family in database.iter_families(): stab.row(family, family.gramps_id) matches += 1 elif (filter_name in ['all events', 'Event']): stab.columns(_("Event"), _("Gramps ID")) for obj in database.iter_events(): stab.row(obj, obj.gramps_id) matches += 1 elif (filter_name in ['all places', 'Place']): stab.columns(_("Place"), _("Gramps ID")) for obj in database.iter_places(): stab.row(obj, obj.gramps_id) matches += 1 elif (filter_name in ['all sources', 'Source']): stab.columns(_("Source"), _("Gramps ID")) for obj in database.iter_sources(): stab.row(obj, obj.gramps_id) matches += 1 elif (filter_name in ['all repositories', 'Repository']): stab.columns(_("Repository"), _("Gramps ID")) for obj in database.iter_repositories(): stab.row(obj, obj.gramps_id) matches += 1 elif (filter_name in ['all media', 'Media']): stab.columns(_("Media"), _("Gramps ID")) for obj in database.iter_media(): stab.row(obj, obj.gramps_id) matches += 1 elif (filter_name in ['all notes', 'Note']): stab.columns(_("Note"), _("Gramps ID")) for obj in database.iter_notes(): stab.row(obj, obj.gramps_id) matches += 1 elif (filter_name == 'males'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) for person in database.iter_people(): if person.gender == Person.MALE: stab.row(person, sdb.birth_or_fallback(person), str(person.get_primary_name().get_type())) matches += 1 elif (filter_name == 'females'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) for person in database.iter_people(): if person.gender == Person.FEMALE: stab.row(person, sdb.birth_or_fallback(person), str(person.get_primary_name().get_type())) matches += 1 elif (filter_name == 'people with unknown gender'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) for person in database.iter_people(): if person.gender not in [Person.FEMALE, Person.MALE]: stab.row(person, sdb.birth_or_fallback(person), str(person.get_primary_name().get_type())) matches += 1 elif (filter_name == 'incomplete names'): stab.columns(_("Name"), _("Birth Date"), _("Name type")) for person in database.iter_people(): for name in [person.get_primary_name() ] + person.get_alternate_names(): if name.get_first_name().strip() == "": stab.row([name.get_name(), "Person", person.handle], sdb.birth_or_fallback(person), str(name.get_type())) matches += 1 else: if name.get_surname_list(): for surname in name.get_surname_list(): if surname.get_surname().strip() == "": stab.row([ name.get_first_name(), "Person", person.handle ], sdb.birth_or_fallback(person), str(name.get_type())) matches += 1 else: stab.row( [name.get_first_name(), "Person", person.handle], sdb.birth_or_fallback(person), str(name.get_type())) matches += 1 elif (filter_name == 'people with missing birth dates'): stab.columns(_("Person"), _("Type")) for person in database.iter_people(): birth_ref = person.get_birth_ref() if birth_ref: birth = database.get_event_from_handle(birth_ref.ref) if not get_date(birth): stab.row(person, _("birth event but no date")) matches += 1 else: stab.row(person, _("missing birth event")) matches += 1 elif (filter_name == 'disconnected people'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) for person in database.iter_people(): if ((not person.get_main_parents_family_handle()) and (not len(person.get_family_handle_list()))): stab.row(person, sdb.birth_or_fallback(person), str(person.get_primary_name().get_type())) matches += 1 elif (filter_name == 'unique surnames'): namelist = defaultdict(int) for person in database.iter_people(): names = [person.get_primary_name()] + person.get_alternate_names() surnames = list(set([name.get_group_name() for name in names])) for surname in surnames: namelist[surname] += 1 stab.columns(_("Surname"), _("Count")) for name in sorted(namelist): stab.row(name, namelist[name]) matches += 1 stab.set_callback( "leftdouble", lambda name: run_quick_report_by_name_direct( "samesurnames", database, document, name)) elif (filter_name == 'people with media'): stab.columns(_("Person"), _("Media count")) for person in database.iter_people(): length = len(person.get_media_list()) if length > 0: stab.row(person, str(length)) matches += 1 elif (filter_name == 'media references'): stab.columns(_("Person"), _("Reference")) for person in database.iter_people(): medialist = person.get_media_list() for item in medialist: stab.row(person, _("media")) matches += 1 elif (filter_name == 'unique media'): stab.columns(_("Unique Media")) for photo in database.iter_media(): fullname = media_path_full(database, photo.get_path()) stab.row(fullname) matches += 1 elif (filter_name == 'missing media'): stab.columns(_("Missing Media")) for photo in database.iter_media(): fullname = media_path_full(database, photo.get_path()) try: os.path.getsize(fullname) except: stab.row(fullname) matches += 1 elif (filter_name == 'media by size'): stab.columns(_("Media"), _("Size in bytes")) for photo in database.iter_media(): fullname = media_path_full(database, photo.get_path()) try: bytes = os.path.getsize(fullname) stab.row(fullname, str(bytes)) matches += 1 except: pass elif (filter_name == 'list of people'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) handles = kwargs["handles"] for person_handle in handles: person = database.get_person_from_handle(person_handle) stab.row(person, sdb.birth_or_fallback(person), str(person.get_primary_name().get_type())) matches += 1 else: raise AttributeError("invalid filter name: '%s'" % filter_name) # Translators: leave all/any {...} untranslated sdoc.paragraph( ngettext("Filter matched {number_of} record.", "Filter matched {number_of} records.", matches).format(number_of=matches)) sdoc.paragraph("") document.has_data = matches > 0 if matches > 0: stab.write(sdoc)
def on_merge_ok_clicked(self, obj): """ Performs the actual merge of citations (Derived from ExtractCity) """ fields = self.menu.get_model()[self.menu.get_active()][1] dont_merge_notes = int(self.notes_obj.get_active()) LOG.debug("fields %d dont_merge_notes %d" % (fields, dont_merge_notes)) self.options.handler.options_dict['fields'] = fields self.options.handler.options_dict[ 'dont_merge_notes'] = dont_merge_notes # Save options self.options.handler.save_options() self.progress = ProgressMeter(_('Checking Sources'), '') self.progress.set_pass(_('Looking for citation fields'), self.db.get_number_of_citations()) db = self.dbstate.db db.disable_signals() num_merges = 0 for handle in db.iter_source_handles(): dict = {} citation_handle_list = list(db.find_backlink_handles(handle)) for (class_name, citation_handle) in citation_handle_list: if class_name != Citation.__name__: raise MergeError("Encountered an object of type %s " "that has a citation reference." % class_name) citation = db.get_citation_from_handle(citation_handle) if citation is None: continue key = citation.get_page() if fields != IGNORE_DATE and fields != IGNORE_BOTH: key += "\n" + get_date(citation) if fields != IGNORE_CONFIDENCE and fields != IGNORE_BOTH: key += "\n" + \ conf_strings[citation.get_confidence_level()] if key in dict and \ (not dont_merge_notes or len(citation.note_list) == 0): citation_match_handle = dict[key] citation_match = \ db.get_citation_from_handle(citation_match_handle) try: query = MergeCitationQuery(self.dbstate, citation_match, citation) query.execute() except AssertionError: print("Tool/Family Tree processing/MergeCitations", \ "citation1 gramps_id", citation_match.get_gramps_id(), \ "citation2 gramps_id", citation.get_gramps_id() , \ "citation backlink handles", \ list(db.find_backlink_handles(citation.get_handle()))) num_merges += 1 elif (not dont_merge_notes or len(citation.note_list) == 0): dict[key] = citation_handle self.progress.step() db.enable_signals() db.request_rebuild() self.progress.close() OkDialog( _("Number of merges done"), # translators: leave all/any {...} untranslated ngettext("{number_of} citation merged", "{number_of} citations merged", num_merges).format(number_of=num_merges)) self.close(obj)
def _get_date(date): if date: return get_date(date)
def __init__(self, dbstate, uistate, handle1, handle2): ManagedWindow.__init__(self, uistate, [], self.__class__) self.dbstate = dbstate database = dbstate.db self.mo1 = database.get_object_from_handle(handle1) self.mo2 = database.get_object_from_handle(handle2) self.define_glade('mergeobject', _GLADE_FILE) self.set_window(self._gladeobj.toplevel, self.get_widget('object_title'), _("Merge Media Objects")) # Detailed selection Widgets desc1 = self.mo1.get_description() desc2 = self.mo2.get_description() entry1 = self.get_widget("desc1") entry2 = self.get_widget("desc2") entry1.set_text(desc1) entry2.set_text(desc2) if entry1.get_text() == entry2.get_text(): for widget_name in ('desc1', 'desc2', 'desc_btn1', 'desc_btn2'): self.get_widget(widget_name).set_sensitive(False) entry1 = self.get_widget("path1") entry2 = self.get_widget("path2") entry1.set_text(self.mo1.get_path()) entry2.set_text(self.mo2.get_path()) entry1.set_position(-1) entry2.set_position(-1) if entry1.get_text() == entry2.get_text(): for widget_name in ('path1', 'path2', 'path_btn1', 'path_btn2'): self.get_widget(widget_name).set_sensitive(False) entry1 = self.get_widget("date1") entry2 = self.get_widget("date2") entry1.set_text(get_date(self.mo1)) entry2.set_text(get_date(self.mo2)) if entry1.get_text() == entry2.get_text(): for widget_name in ('date1', 'date2', 'date_btn1', 'date_btn2'): self.get_widget(widget_name).set_sensitive(False) gramps1 = self.mo1.get_gramps_id() gramps2 = self.mo2.get_gramps_id() entry1 = self.get_widget("gramps1") entry2 = self.get_widget("gramps2") entry1.set_text(gramps1) entry2.set_text(gramps2) if entry1.get_text() == entry2.get_text(): for widget_name in ('gramps1', 'gramps2', 'gramps_btn1', 'gramps_btn2'): self.get_widget(widget_name).set_sensitive(False) # Main window widgets that determine which handle survives rbutton1 = self.get_widget("handle_btn1") rbutton_label1 = self.get_widget("label_handle_btn1") rbutton_label2 = self.get_widget("label_handle_btn2") rbutton_label1.set_label("%s [%s]" % (desc1, gramps1)) rbutton_label2.set_label("%s [%s]" % (desc2, gramps2)) rbutton1.connect('toggled', self.on_handle1_toggled) self.connect_button('object_help', self.cb_help) self.connect_button('object_ok', self.cb_merge) self.connect_button('object_cancel', self.close) self.show()
def main(self): self.set_text(_("Processing...")) database = self.dbstate.db personList = database.iter_people() with_media = 0 total_media = 0 incomp_names = 0 disconnected = 0 missing_bday = 0 males = 0 females = 0 unknowns = 0 bytes = 0 namelist = [] notfound = [] mobjects = database.get_number_of_media() mbytes = "0" for media in database.iter_media(): fullname = media_path_full(database, media.get_path()) try: bytes += posixpath.getsize(fullname) length = len(str(bytes)) if bytes <= 999999: mbytes = _("less than 1") else: mbytes = str(bytes)[:(length - 6)] except OSError: notfound.append(media.get_path()) for cnt, person in enumerate(personList): length = len(person.get_media_list()) if length > 0: with_media += 1 total_media += length for name in [person.get_primary_name() ] + person.get_alternate_names(): # Count unique surnames if not name.get_surname().strip() in namelist \ and not name.get_surname().strip() == "": namelist.append(name.get_surname().strip()) if name.get_first_name().strip() == "": incomp_names += 1 else: if name.get_surname_list(): for surname in name.get_surname_list(): if surname.get_surname().strip() == "": incomp_names += 1 else: incomp_names += 1 if (not person.get_main_parents_family_handle() and not len(person.get_family_handle_list())): disconnected += 1 birth_ref = person.get_birth_ref() if birth_ref: birth = database.get_event_from_handle(birth_ref.ref) if not get_date(birth): missing_bday += 1 else: missing_bday += 1 if person.get_gender() == Person.FEMALE: females += 1 elif person.get_gender() == Person.MALE: males += 1 else: unknowns += 1 if not cnt % _YIELD_INTERVAL: yield True self.clear_text() self.append_text(_("Individuals") + "\n") self.append_text("----------------------------\n") self.link(_("Number of individuals") + ":", 'Filter', 'all people') self.append_text(" %s" % database.get_number_of_people()) self.append_text("\n") self.link("%s:" % _("Males"), 'Filter', 'males') self.append_text(" %s" % males) self.append_text("\n") self.link("%s:" % _("Females"), 'Filter', 'females') self.append_text(" %s" % females) self.append_text("\n") self.link("%s:" % _("Individuals with unknown gender"), 'Filter', 'people with unknown gender') self.append_text(" %s" % unknowns) self.append_text("\n") self.link("%s:" % _("Incomplete names"), 'Filter', 'incomplete names') self.append_text(" %s" % incomp_names) self.append_text("\n") self.link("%s:" % _("Individuals missing birth dates"), 'Filter', 'people with missing birth dates') self.append_text(" %s" % missing_bday) self.append_text("\n") self.link("%s:" % _("Disconnected individuals"), 'Filter', 'disconnected people') self.append_text(" %s" % disconnected) self.append_text("\n") self.append_text("\n%s\n" % _("Family Information")) self.append_text("----------------------------\n") self.link("%s:" % _("Number of families"), 'Filter', 'all families') self.append_text(" %s" % database.get_number_of_families()) self.append_text("\n") self.link("%s:" % _("Unique surnames"), 'Filter', 'unique surnames') self.append_text(" %s" % len(namelist)) self.append_text("\n") self.append_text("\n%s\n" % _("Media Objects")) self.append_text("----------------------------\n") self.link("%s:" % _("Individuals with media objects"), 'Filter', 'people with media') self.append_text(" %s" % with_media) self.append_text("\n") self.link("%s:" % _("Total number of media object references"), 'Filter', 'media references') self.append_text(" %s" % total_media) self.append_text("\n") self.link("%s:" % _("Number of unique media objects"), 'Filter', 'unique media') self.append_text(" %s" % mobjects) self.append_text("\n") self.link("%s:" % _("Total size of media objects"), 'Filter', 'media by size') self.append_text(" %s %s" % (mbytes, _("Megabyte|MB"))) self.append_text("\n") self.link("%s:" % _("Missing Media Objects"), 'Filter', 'missing media') self.append_text(" %s\n" % len(notfound)) self.append_text("", scroll_to="begin")
def listpersonref(self): sc = {'source': 'S_ID', 'citalist': 'C_ID'} stc = {} citation_without_notes = 0 EMPTY = " " def toYear(date): yeartext = date.get_year() return yeartext # build citasource dictionary and cl list sc = defaultdict(list) cl = [] i = 1 for ci in self.__db.iter_citations(): if ci.source_handle in self.source_handles: sc[ci.source_handle].append(ci.handle) cl.append(ci.handle) # build citations - event dic xy #(a,b): set([('Citation', 'c4a8c46041e08799b17')]) # event: c4a8c4f95b01e38564a event: Taufe ci = defaultdict(list) for ev in self.__db.iter_events(): refhandlelist = ev.get_referenced_handles() for (a, b) in refhandlelist: if a == 'Citation': if b in cl: #! ci[ev.handle].append(b) ci_evkeys = ci.keys() # build eventfamily dictionary # event: c4a8c4f95b01e38564a event: Taufe refhandlelist = [] fedic = {} fedic = defaultdict(set) for fh in self.__db.get_family_handles(): for eventref in self.__db.get_family_from_handle( fh).event_ref_list: if eventref.ref in ci_evkeys: family = self.__db.get_family_from_handle(eventref.ref) fedic[eventref.ref].add( (self.__db.get_family_from_handle(fh).mother_handle, self.__db.get_family_from_handle(fh).father_handle, fh)) fedickeys = fedic.keys() #*********************************************************************** # # build eventperson dictionary # # event: c4a8c4f95b01e38564a event: Taufe # # a date sort value # b event handle # c role # d name # e pe # evdic = {} evdic = defaultdict(list) # for pe in self.__db.get_person_handles(sort_handles=True): # for eventref in self.__db.get_person_from_handle(pe).event_ref_list: # evdic[eventref.ref].append((self.__db.get_event_from_handle(eventref.ref).get_date_object().get_sort_value(),eventref.ref,eventref.get_role(),self.__db.get_person_from_handle(pe).primary_name.get_name(),pe)) for pe in self.__db.get_person_handles(sort_handles=True): for eventref in self.__db.get_person_from_handle( pe).event_ref_list: if eventref.ref in ci_evkeys: evdic[eventref.ref].append( (self.__db.get_event_from_handle( eventref.ref).get_date_object().get_sort_value(), eventref.ref, eventref.get_role(), self.__db.get_person_from_handle( pe).primary_name.get_name(), pe)) self.doc.start_paragraph("SRC-SourceTitle") self.doc.write_text(_("Person with Citations")) self.doc.end_paragraph() evkeys = evdic.keys() evkeys.sort StatCount = Counter() self.doc.start_table("PersonRoleEventTable", "SRC-PersonEventRoleTable") column_titles = [ _("LNr"), _("Ev ID"), _("Event"), _("Date"), _("Primary"), _("Prim_ID"), _("Person"), _("Gramps_ID"), _("Role"), _("Relation") ] i = 0 self.doc.start_row() for title in column_titles: self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(title) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() i = 0 ii = 0 for ev in evkeys: primarypersonAhandle = ev primarypersonBhandle = ev name = "LEER" name_id = "LEER" FamilyText = "LEERFAM" name_handle = 0 #Primary suchen for (a, b, c, d, e) in evdic[ev]: if c == EventRoleType.PRIMARY: Fam = 0 name = d name_id = self.__db.get_person_from_handle(e).gramps_id name_handle = e FamilyText = "FAMILY" elif c != EventRoleType.PRIMARY: # if it is a familyevent for k in fedickeys: if ev == k: for (a, b, c) in fedic[k]: Fam = 1 self.FamilyText = ( _("%s") % self.__db.get_event_from_handle( ev).get_type()) self.FamilyText = self.FamilyText + ( _(" Eheleute: ")) try: self.FamilyText = self.FamilyText + ( _(" %s ") % self.__db.get_person_from_handle( b).primary_name.get_name()) primarypersonBhandle = b except: self.FamilyText = self.FamilyText + ( _("unknown")) try: self.FamilyText = self.FamilyText + ( _(" and %s ") % self.__db.get_person_from_handle( a).primary_name.get_name()) primarypersonAhandle = a except: self.FamilyText = self.FamilyText + ( _("and unknown")) name = self.FamilyText else: continue for (a, b, c, d, e) in evdic[ev]: if c == EventRoleType.PRIMARY: continue elif c != EventRoleType.PRIMARY: ii += 1 # LNR self._user.step_progress() self.doc.start_row() self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % ii) self.doc.end_paragraph() self.doc.end_cell() # Event Gramps ID self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % self.__db.get_event_from_handle(ev).gramps_id) self.doc.end_paragraph() self.doc.end_cell() #Event Type self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % self.__db.get_event_from_handle(b).get_type()) self.doc.end_paragraph() self.doc.end_cell() # Event Date self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" %s") % # DateHandler.get_date(self.__db.get_event_from_handle(b))) get_date(self.__db.get_event_from_handle(b))) self.doc.end_paragraph() self.doc.end_cell() # Primary Role Name self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % name) self.doc.end_paragraph() self.doc.end_cell() # Primary Role ID self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % name_id) self.doc.end_paragraph() self.doc.end_cell() # Person Name self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % d) self.doc.end_paragraph() self.doc.end_cell() # Person ID self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % self.__db.get_person_from_handle(e).gramps_id) self.doc.end_paragraph() self.doc.end_cell() # Event Role self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % c) self.doc.end_paragraph() self.doc.end_cell() # Relation self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % self.personrelation(Fam, e, name_handle, primarypersonAhandle, primarypersonBhandle, 1)) self.doc.end_paragraph() self.doc.end_cell() StatCount.update([ self.personrelation(Fam, e, name_handle, primarypersonAhandle, primarypersonBhandle, 1) ]) self.doc.end_row() self.doc.end_table() self.doc.start_table("RoleStatisticTable", "SRC-StatTable") stat_column_titles = [_("Relation"), _("count"), _("Percent")] i = 0 self.doc.start_row() for title in stat_column_titles: self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(title) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for rel in sorted(StatCount): self.doc.start_row() # Relation self._user.step_progress() self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % rel) self.doc.end_paragraph() self.doc.end_cell() # count self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-StatCell") self.doc.write_text(_("%s") % StatCount[rel]) self.doc.end_paragraph() self.doc.end_cell() # percent pc = 100 * (StatCount[rel]) / (sum(StatCount.values())) self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-StatCell") # self.doc.write_text(_(" %1.2f ") % self.doc.write_text(_(" %.2f%% ") % pc) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.start_row() # Total self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("Total %s") % len(StatCount)) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-StatCell") self.doc.write_text(_("%s") % sum(StatCount.values())) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def write_citations(self): clist = self.database.get_citation_handles(sort_handles=True) FilterClass = GenericFilterFactory('Citation') filter = FilterClass() filter.add_rule(rules.citation.HasTag([self.tag])) citation_list = filter.apply(self.database, clist) if not citation_list: return self.doc.start_paragraph("TR-Heading") header = self._("Citations") mark = IndexMark(header, INDEX_TYPE_TOC, 2) self.doc.write_text(header ,mark) self.doc.end_paragraph() self.doc.start_table('CitationTable','TR-Table') self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Id")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Volume/Page")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Date")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(self._("Source")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for citation_handle in citation_list: citation = self.database.get_citation_from_handle(citation_handle) self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(citation.get_gramps_id()) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(citation.get_page()) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') date = get_date(citation) if date: self.doc.write_text(date) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') source_handle = citation.get_reference_handle() source = self.database.get_source_from_handle(source_handle) self.doc.write_text(source.get_title()) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def listeventref(self): sc = {'source': 'S_ID', 'citalist': 'C_ID'} stc = {} citation_without_notes = 0 EMPTY = " " def toYear(date): yeartext = date.get_year() return yeartext # build citasource dictionary and cl list sc = defaultdict(list) cl = [] i = 1 for ci in self.__db.iter_citations(): if ci.source_handle in self.source_handles: sc[ci.source_handle].append(ci.handle) cl.append(ci.handle) # build citations - event dic xy #(a,b): set([('Citation', 'c4a8c46041e08799b17')]) # event: c4a8c4f95b01e38564a event: Taufe ci = defaultdict(list) for ev in self.__db.iter_events(): refhandlelist = ev.get_referenced_handles() for (a, b) in refhandlelist: if a == 'Citation': if b in cl: #! ci[b].append(ev.handle) # build eventpersonrole dictionary # event: c4a8c4f95b01e38564a event: Taufe refhandlelist = [] pedic = {} pedic = defaultdict(list) #TTTT self.source_handles = self.filter.apply(self.__db, sourcefilterlist) #TTTT for pe in self.__db.get_person_handles(): for pe in self.__db.get_person_handles(): for eventref in self.__db.get_person_from_handle( pe).event_ref_list: pedic[eventref.ref].append((eventref.get_role(), pe)) # build eventfamily dictionary # event: c4a8c4f95b01e38564a event: Taufe refhandlelist = [] fedic = {} fedic = defaultdict(set) for fh in self.__db.get_family_handles(): for eventref in self.__db.get_family_from_handle( fh).event_ref_list: family = self.__db.get_family_from_handle(eventref.ref) fedic[eventref.ref].add( (self.__db.get_family_from_handle(fh).mother_handle, self.__db.get_family_from_handle(fh).father_handle, fh)) #source # skeys = sc.keys() # skeys.sort(key=lambda x:self._formatlocal_source_text(self.__db.get_source_from_handle(x))) #TTTTT # for s in skeys: for s in sorted(sc.keys()): self._user.step_progress() self.doc.start_paragraph("SRC-SourceTitle") self.doc.write_text( self._formatlocal_source_text( self.__db.get_source_from_handle(s))) self.doc.end_paragraph() self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" ID: %s") % self.__db.get_source_from_handle(s).gramps_id) self.doc.end_paragraph() # note in sources for sourcenotehandle in self.__db.get_source_from_handle( s).get_note_list(): self.doc.start_paragraph("SRC-NoteDetails") self.doc.write_text( _(" Type: %s") % self.__db.get_note_from_handle(sourcenotehandle).type) self.doc.write_text( _(" N-ID: %s") % self.__db.get_note_from_handle(sourcenotehandle).gramps_id) self.doc.end_paragraph() self.doc.start_paragraph("SRC-NoteText") self.doc.write_text( _(" %s") % self.__db.get_note_from_handle(sourcenotehandle).text) self.doc.end_paragraph() i = 1 ckeys = sc[s] ckeys.sort( key=lambda x: self.__db.get_citation_from_handle(x).page) for c in ckeys: # c contains citationhandles self._user.step_progress() self.doc.start_paragraph("SRC-CitationTitle") self.doc.write_text(_("%d") % i) self.doc.write_text( _(" %s") % self.__db.get_citation_from_handle(c).page) # self.doc.write_text(_(" Anno %s - ") % # toYear(self.__db.get_citation_from_handle(c).date)) self.doc.write_text( _(" Date %s ") % get_date(self.__db.get_citation_from_handle(c))) self.doc.end_paragraph() self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" ID: %s") % self.__db.get_citation_from_handle(c).gramps_id) self.doc.write_text( _(" Confidence: %s") % conf_strings[self.__db.get_citation_from_handle( c).get_confidence_level()]) self.doc.end_paragraph() i += 1 # note in citations for notehandle in self.__db.get_citation_from_handle( c).get_note_list(): self._user.step_progress() self.doc.start_paragraph("SRC-NoteDetails") self.doc.write_text( _(" Type: %s") % self.__db.get_note_from_handle(notehandle).type) self.doc.write_text( _(" N-ID: %s") % self.__db.get_note_from_handle(notehandle).gramps_id) self.doc.end_paragraph() self.doc.start_paragraph("SRC-NoteDetails") self.doc.end_paragraph() self.doc.start_paragraph("SRC-NoteText") self.doc.write_text( _(" %s") % self.__db.get_note_from_handle(notehandle).text) self.doc.end_paragraph() # event as table for e in ci[c]: self.doc.start_paragraph("SRC-SourceDetails") self.doc.end_paragraph() # if it is a familyevent for k in fedic.keys(): if e == k: for (a, b, c) in fedic[k]: self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % self.__db.get_event_from_handle( e).get_type()) self.doc.write_text( _(" ( %s )") % self.__db.get_event_from_handle( e).gramps_id) self.doc.write_text(_(" married couple: ")) try: self.doc.write_text( _(" %s ") % self.__db.get_person_from_handle( b).primary_name.get_name()) primarypersonAhandle = b except: self.doc.write_text(_("unknown")) try: self.doc.write_text( _(" and %s ") % self.__db.get_person_from_handle( a).primary_name.get_name()) primarypersonBhandle = a except: self.doc.write_text(_("and unknown")) self.doc.end_paragraph() if self.showperson: liste = pedic[e].copy() self.persontable(liste, 1, 0, primarypersonAhandle, primarypersonBhandle) for (a, b) in pedic[e]: if a.is_primary(): self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % self.__db.get_event_from_handle(e).get_type()) self.doc.write_text( _(" ( %s )") % self.__db.get_event_from_handle(e).gramps_id) self.doc.write_text( _(" %s") % self.__db.get_person_from_handle( b).primary_name.get_name()) primarypersonhandle = b self.doc.end_paragraph() if self.showperson: liste = pedic[e].copy() self.persontable(liste, 0, primarypersonhandle, 0, 0)
def summarize_people(self): """ Write a summary of all the people in the database. """ with_media = 0 incomp_names = 0 disconnected = 0 missing_bday = 0 males = 0 females = 0 unknowns = 0 namelist = [] self.doc.start_paragraph("SR-Heading") self.doc.write_text(self._("Individuals")) self.doc.end_paragraph() num_people = 0 for person in self.__db.iter_people(): num_people += 1 primary_names = [person.get_primary_name()] # Count people with media. length = len(person.get_media_list()) if length > 0: with_media += 1 # Count people with incomplete names. for name in primary_names + person.get_alternate_names(): if name.get_first_name().strip() == "": incomp_names += 1 else: if name.get_surname_list(): for surname in name.get_surname_list(): if surname.get_surname().strip() == "": incomp_names += 1 else: incomp_names += 1 # Count people without families. if (not person.get_main_parents_family_handle() and not len(person.get_family_handle_list())): disconnected += 1 # Count missing birthdays. birth_ref = person.get_birth_ref() if birth_ref: birth = self.__db.get_event_from_handle(birth_ref.ref) if not get_date(birth): missing_bday += 1 else: missing_bday += 1 # Count genders. if person.get_gender() == Person.FEMALE: females += 1 elif person.get_gender() == Person.MALE: males += 1 else: unknowns += 1 # Count unique surnames for name in primary_names + person.get_alternate_names(): if (not name.get_surname().strip() in namelist and not name.get_surname().strip() == ""): namelist.append(name.get_surname().strip()) self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Number of individuals: %d") % num_people) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Males: %d") % males) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Females: %d") % females) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text( self._("Individuals with unknown gender: %d") % unknowns) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Incomplete names: %d") % incomp_names) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text( self._("Individuals missing birth dates: %d") % missing_bday) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text( self._("Disconnected individuals: %d") % disconnected) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Unique surnames: %d") % len(namelist)) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text( self._("Individuals with media objects: %d") % with_media) self.doc.end_paragraph()
def summarize_people(self): """ Write a summary of all the people in the database. """ peDict = defaultdict() with_media = 0 incomp_names = 0 disconnected = 0 missing_bday = 0 males = 0 females = 0 unknowns = 0 namelist = [] exact_birth = 0 estimated_birth = 0 calculated_birth = 0 missing_birth = 0 sum_birth = 0 exact_bapt = 0 estimated_bapt = 0 calculated_bapt = 0 missing_bapt = 0 sum_bapt = 0 exact_death = 0 estimated_death = 0 calculated_death = 0 missing_death = 0 sum_birth = 0 exact_burial = 0 estimated_burial = 0 calculated_burial = 0 missing_burial = 0 sum_bapt = 0 mi_bday = 0 ex_birth = 0 est_birth = 0 cal_birth = 0 su_birth = 0 ##EventTuple = namedtuple('Eventtuple', ['exact_birth', 'estimated_birth', 'calculated_birth', 'missing_birth', ## 'exact_bapt', 'estimated_bapt', 'calculated_bapt', 'missing_bapt', ## 'exact_death', 'estimated_death', 'calculated_death', 'missing_death', ## 'exact_burial', 'estimated_burial', 'calculated_burial', 'missing_burial']) self.doc.start_paragraph("SR-Heading") self.doc.write_text(self._("Individuals")) self.doc.end_paragraph() num_people = 0 for person in self.__db.iter_people(): num_people += 1 evList=[0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0] # Count people with media. length = len(person.get_media_list()) if length > 0: with_media += 1 # Count people with incomplete names. for name in [person.get_primary_name()] + person.get_alternate_names(): if name.get_first_name().strip() == "": incomp_names += 1 else: if name.get_surname_list(): for surname in name.get_surname_list(): if surname.get_surname().strip() == "": incomp_names += 1 else: incomp_names += 1 # Count people without families. if (not person.get_main_parents_family_handle() and not len(person.get_family_handle_list())): disconnected += 1 # Count missing birthdays. birth_ref = person.get_birth_ref() if birth_ref: birth = self.__db.get_event_from_handle(birth_ref.ref) if not get_date(birth): missing_bday += 1 else: missing_bday += 1 # Count exact birthdays. # events with Date Quality (0 Exact, 1 Estimated, 2 Calculated) birth_ref = person.get_birth_ref() if birth_ref: birth = self.__db.get_event_from_handle(birth_ref.ref) if not get_date(birth): mi_bday += 1 elif birth.get_date_object().get_quality() == 0: ex_birth += 1 elif birth.get_date_object().get_quality() == 1: est_birth += 1 elif birth.get_date_object().get_quality() == 2: cal_birth += 1 else: mi_bday += 0 # Count primary events by quality # events with Date Quality (0 Exact, 1 Estimated, 2 Calculated) for ev_ref in person.get_primary_event_ref_list(): if ev_ref: ev = self.__db.get_event_from_handle(ev_ref.ref) if ev and ev.type.is_birth(): birth_exact, birth_calculated, birth_estimated, birth_missing = self.count_by_quality(ev) exact_birth = exact_birth + birth_exact calculated_birth = calculated_birth + birth_calculated estimated_birth = estimated_birth + birth_estimated missing_birth = missing_birth + birth_missing evList[0:4] = self.count_by_quality(ev) ##EventTuple[0], EventTuple[1], EventTuple[2], EventTuple[3] = self.count_by_quality(ev) if ev and ev.type.is_baptism(): bapt_exact, bapt_calculated, bapt_estimated, bapt_missing = self.count_by_quality(ev) exact_bapt = exact_bapt + bapt_exact calculated_bapt = calculated_bapt + bapt_calculated estimated_bapt = estimated_bapt + bapt_estimated missing_bapt = missing_bapt + bapt_missing evList[4:8] = self.count_by_quality(ev) ##EventTuple[4:8] = self.count_by_quality(ev) if ev and ev.type.is_death(): death_exact, death_calculated, death_estimated, death_missing = self.count_by_quality(ev) exact_death = exact_death + death_exact calculated_death = calculated_death + death_calculated estimated_death = estimated_death + death_estimated missing_death = missing_death + death_missing evList[8:12] = self.count_by_quality(ev) ##EventTuple[8:12] = self.count_by_quality(ev) if ev and ev.type.is_burial(): burial_exact, burial_calculated, burial_estimated, burial_missing = self.count_by_quality(ev) exact_burial = exact_burial + burial_exact calculated_burial = calculated_burial + burial_calculated estimated_burial = estimated_burial + burial_estimated missing_burial = missing_burial + burial_missing evList[12:16] = self.count_by_quality(ev) ##EventTuple[12:16] = self.count_by_quality(ev) peDict[person.gramps_id] = tuple(evList) peC = Counter(peDict.values()) # Count genders. if person.get_gender() == Person.FEMALE: females += 1 elif person.get_gender() == Person.MALE: males += 1 else: unknowns += 1 # Count unique surnames for name in [person.get_primary_name()] + person.get_alternate_names(): if not name.get_surname().strip() in namelist \ and not name.get_surname().strip() == "": namelist.append(name.get_surname().strip()) # totals sum_bday = ex_birth + est_birth + cal_birth + mi_bday sum_birth = exact_birth + calculated_birth + estimated_birth + missing_birth sum_bapt = exact_bapt + calculated_bapt + estimated_bapt + missing_bapt sum_death = exact_death + calculated_death + estimated_death + missing_death sum_burial = exact_burial + calculated_burial + estimated_burial + missing_burial #for key in peDict.keys(): # print(key, peDict[key]) #for k, v in peC.items(): # print('Item ', k, v) with open('C://Users//Frink//Documents//dict.csv', 'w') as csv_file: writer = csv.writer(csv_file) #for key, value in peDict.items(): writer.writerows(peDict.items()) self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Number of individuals: %d") % num_people) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Males: %d") % males) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Females: %d") % females) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Individuals with unknown gender: %d") % unknowns) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Incomplete names: %d") % incomp_names) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Individuals missing birth dates: %d") % mi_bday) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Individuals exact birth dates: %d") % ex_birth) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Individuals estimated birth dates: %d") % est_birth) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Individuals calculated birth dates: %d") % cal_birth) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Individuals birth dates: %d") % sum_bday) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") #print(bapt_exact, bapt_calculated, bapt_estimated, bapt_missing) #print(sum_bapt , exact_bapt, calculated_bapt, estimated_bapt, missing_bapt) self.doc.write_text(self._("Indiv birth exac: %d calc: %d est: %d miss: %d sum: %d \n") % (exact_birth, calculated_birth, estimated_birth , missing_birth, sum_birth )) self.doc.write_text(self._("Indiv bapt exac: %d calc: %d est: %d miss: %d sum: %d \n") % (exact_bapt, calculated_bapt, estimated_bapt , missing_bapt, sum_bapt )) self.doc.write_text(self._("Indiv death exac: %d calc: %d est: %d miss: %d sum: %d \n") % (exact_death, calculated_death, estimated_death , missing_death, sum_death )) self.doc.write_text(self._("Indiv burrial exac: %d calc: %d est: %d miss: %d sum: %d \n") % (exact_burial, calculated_burial, estimated_burial , missing_burial, sum_burial )) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Disconnected individuals: %d") % disconnected) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Unique surnames: %d") % len(namelist)) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("Individuals with media objects: %d") % with_media) self.doc.end_paragraph() self.doc.start_paragraph("SR-Normal") self.doc.write_text(self._("____:_bi____ba____de____bu____|\n")) for k, n in sorted(peC.items()): k1 = " ".join(str(elem) for elem in k) #print('k1 ',k1, type(k1)) self.doc.write_text(self._("Item: %s %d \n") % (k1, n)) self.doc.end_paragraph()
def listeventref(self): sc = {'source': 'S_ID', 'citalist': 'C_ID'} stc = {} citation_without_notes = 0 EMPTY = " " def toYear(date): yeartext = date.get_year() return yeartext # build citation list cl cl = [] i = 1 for ci in self.__db.iter_citations(): if ci.source_handle in self.source_handles: # sc[ci.source_handle].append(ci.handle) cl.append(ci.handle) # build citations - event dic xy #(a,b): set([('Citation', 'c4a8c46041e08799b17')]) # event: c4a8c4f95b01e38564a event: Taufe #!! # Nur Taufen ! ci = defaultdict(list) for ev in self.__db.iter_events(): if ev.type.is_baptism(): evcithandlelist = ev.get_referenced_citation_handles() for (a, b) in evcithandlelist: if b in cl: ci[b].append(ev.handle) cikeys = ci.keys() # for di in cikeys: # print ((di), di in cl) # print (len(cikeys)) # print ("CITA", len(ci.keys()), len(sc.values()) ) # print ("SOURCE", len(sc.keys()), len(sc.values()), len(sc[0]) ) # build citasource dictionary sc = defaultdict(list) for ci2 in self.__db.iter_citations(): if ci2.handle in cikeys: # print("HALLO ", ci2, ci2.source_handle) sc[ci2.source_handle].append(ci2.handle) sckeys = sc.keys() # for di in sckeys: # print ((di), sc[di]) # print (len(sckeys), len(sc[di])) # build eventpersonrole dictionary # event: c4a8c4f95b01e38564a event: Taufe refhandlelist = [] pedic = {} pedic = defaultdict(list) for pe in self.__db.get_person_handles(): for eventref in self.__db.get_person_from_handle( pe).event_ref_list: # print(eventref, eventref.ref, eventref.get_role(), pe ) # print(eventref.get_role(), pe ) ## pedic[eventref.ref].add((eventref,pe)) pedic[eventref.ref].append((eventref.get_role(), pe)) #source # skeys = sc.keys() # skeys.sort(key=lambda x:self._formatlocal_source_text(self.__db.get_source_from_handle(x))) # for s in skeys: for s in sorted(sc.keys()): self._user.step_progress() self.doc.start_paragraph("SRC-SourceTitle") self.doc.write_text( self._formatlocal_source_text( self.__db.get_source_from_handle(s))) self.doc.end_paragraph() self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" ID: %s") % self.__db.get_source_from_handle(s).gramps_id) self.doc.end_paragraph() # note in sources for sourcenotehandle in self.__db.get_source_from_handle( s).get_note_list(): self.doc.start_paragraph("SRC-NoteDetails") self.doc.write_text( _(" Type: %s") % self.__db.get_note_from_handle(sourcenotehandle).type) self.doc.write_text( _(" N-ID: %s") % self.__db.get_note_from_handle(sourcenotehandle).gramps_id) self.doc.end_paragraph() self.doc.start_paragraph("SRC-NoteText") self.doc.write_text( _(" %s") % self.__db.get_note_from_handle(sourcenotehandle).text) self.doc.end_paragraph() self.doc.start_table("EventTable", "SRC-EventTable") # column_titles = [_("LNr"), _("Source"), _("Date"),_("Person"),_("Parents"), # _("Godparents"),_("Relation")] column_titles = [ _("LNr"), _("Source"), _("Date"), _("Person"), _("Parents"), _("Paten"), _("Beziehung") ] self.doc.start_row() for title in column_titles: self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(title) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() i = 1 ckeys = sc[s] ckeys.sort( key=lambda x: self.__db.get_citation_from_handle(x).page) for c in ckeys: # c contains citationhandles self._user.step_progress() self.doc.start_row() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%d") % i) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" %s") % self.__db.get_citation_from_handle(c).page) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _(" %s ") % get_date(self.__db.get_citation_from_handle(c))) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") for e in ci[c]: event = self.__db.get_event_from_handle(e) for (a, b) in pedic[e]: if a.is_primary(): self.doc.write_text(_("%s") % event.get_type()) self.doc.write_text( _(" ( %s )") % event.gramps_id) self.doc.write_text( _(" %s") % self.__db.get_person_from_handle( b).primary_name.get_name()) primarypersonhandle = b liste = pedic[e].copy() self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") #Eltern und Ort family_handle = self.__db.get_person_from_handle( primarypersonhandle).get_main_parents_family_handle() if family_handle: fh = self.__db.get_family_from_handle( family_handle).father_handle if fh: self.doc.write_text( _("%s ") % self.__db.get_person_from_handle( fh).primary_name.get_name()) self.doc.end_paragraph() self.doc.start_paragraph("SRC-SourceDetails") mh = self.__db.get_family_from_handle( family_handle).mother_handle if mh: self.doc.write_text( _("%s ") % self.__db.get_person_from_handle( mh).primary_name.get_name()) place = '' place_handle = event.get_place_handle() if place_handle: place = place_displayer.display_event(self.database, event) # self.doc.write_text(_(" from %s") % # place) self.doc.write_text(_(" von %s") % place) self.doc.end_paragraph() self.doc.end_cell() #Godparents self.doc.start_cell("SRC-TableColumn") for e in ci[c]: for (a, b) in pedic[e]: if not a.is_primary(): self.doc.start_paragraph("SRC-SourceDetails") relation_text = "n.v." rel_calc = get_relationship_calculator() relation = rel_calc.get_one_relationship( self.__db, self.__db.get_person_from_handle( primarypersonhandle), self.__db.get_person_from_handle(b)) if relation: relation_text = _("%s" % relation) self.doc.write_text( _(" %s") % self.__db.get_person_from_handle( b).primary_name.get_name()) self.doc.write_text(_(" ( %s )") % relation_text) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") # note in citations for notehandle in self.__db.get_citation_from_handle( c).get_note_list(): self._user.step_progress() self.doc.start_paragraph("SRC-NoteText") self.doc.write_text( _(" %s") % self.__db.get_note_from_handle(notehandle).text) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() i += 1 self.doc.end_table()
def write_census(self, event, citation): """ Called for each census. """ if self.pgbrk and not self.first_page: self.doc.page_break() self.first_page = False # Date, Source, Place p_handle = event.get_place_handle() place = self.database.get_place_from_handle(p_handle) src_handle = citation.get_reference_handle() source = self.database.get_source_from_handle(src_handle) census_id = get_census_id(source) headings = [x[0] for x in get_report_columns(census_id)] # Census title self.doc.start_paragraph("CEN-Heading") self.doc.write_text(source.get_title()) self.doc.end_paragraph() self.doc.start_table("centab", "CEN-HeadingTable") # Date self.write_heading(_("Date:"), get_date(event)) # Source Reference self.write_heading(_("Citation:"), citation.get_page()) # Address if place: self.write_heading(_("Address:"), place.get_title()) else: self.write_heading(_("Address:"), "") # Blank line self.write_heading("", "") self.doc.end_table() self.doc.start_table("centab", "CEN-" + census_id) # People person_list = [] e_handle = event.get_handle() for link in self.database.find_backlink_handles( e_handle, include_classes=['Person']): person = self.database.get_person_from_handle(link[1]) person_list.append(get_attributes(person, e_handle)) # Heading row self.doc.start_row() for column in headings: self.doc.start_cell("CEN-ColumnCell") self.doc.start_paragraph("CEN-Column") self.doc.write_text(column) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for row in sorted(person_list): self.doc.start_row() for offset, column in enumerate(get_census_columns(census_id)): self.doc.start_cell("CEN-BodyCell") if column == _('Name'): self.doc.start_paragraph("CEN-Name") self.doc.write_text(row[2].get(column, row[1])) else: self.doc.start_paragraph("CEN-Normal") if column in row[2]: self.doc.write_text(row[2].get(column)) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()