class PlaceFamilyReport(Report): """ Place Report class """ def __init__(self, database, options, user): """ Create the PlaceFamilyReport object produces the PlaceFamily report. The arguments are: database - the GRAMPS database instance options - instance of the Options class for this report user - instance of a gen.user.User class This report needs the following parameters (class variables) that come in the options class. places - List of places to report on. place_fmt - Place Fromat used incpriv - Whether to include private data showgodparents - Whether to include and show godparents """ Report.__init__(self, database, options, user) self._user = user menu = options.menu places = menu.get_option_by_name('places').get_value() self.place_fmt = menu.get_option_by_name("place_format").get_value() print("self.place_fmt ", self.place_fmt) self.incpriv = menu.get_option_by_name('incpriv').get_value() self.showgodparents = menu.get_option_by_name( 'showgodparents').get_value() self.set_locale(menu.get_option_by_name('trans').get_value()) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) self._nd = self._name_display if self.incpriv: self.db = database else: self.db = PrivateProxyDb(database) filter_option = menu.get_option_by_name('filter') self.filter = filter_option.get_filter() self.sort = Sort(self.db) if self.filter.get_name() != '': # Use the selected filter to provide a list of place handles plist = self.db.iter_place_handles() self.place_handles = self.filter.apply(self.db, plist) else: # Use the place handles selected without a filter self.place_handles = self.__get_place_handles(places) self.place_handles.sort(key=self.sort.by_place_title_key) def write_report(self): """ The routine that actually creates the report. At this point, the document is opened and ready for writing. """ # Write the title line. Set in INDEX marker so that this section will be # identified as a major category if this is included in a Book report. title = self._("PlaceFamily Report") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("PLC-ReportTitle") self.doc.write_text(title, mark) self.doc.end_paragraph() self.__write_all_places() self.__write_referenced_families() def __write_all_places(self): """ This procedure writes out each of the selected places. """ place_nbr = 1 subtitle = self._("Places") mark = IndexMark(subtitle, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("PLC-ReportSubtitle") self.doc.write_text(subtitle, mark) self.doc.end_paragraph() self.doc.start_paragraph("PLC-Section") self.doc.write_text( "Enthält alle Familien mit Hochzeitsereignis in diesen Orten") self.doc.end_paragraph() pl_list = [] pl_list = [ _pd.display(self.db, self.db.get_place_from_handle(handle)) for handle in self.place_handles ] for p in pl_list: self.doc.start_paragraph("PLC-Section") self.doc.write_text(" %s " % place_nbr) self.doc.write_text(p) self.doc.end_paragraph() place_nbr += 1 subtitle = self._("Families") mark = IndexMark(subtitle, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("PLC-ReportSubtitle") self.doc.write_text(subtitle, mark) self.doc.end_paragraph() def __format_date_place(self, eventref): estr = " " event = self.db.get_event_from_handle(eventref.ref) if event: #e_date = event.get_date_object() e_date = self._get_date(event.get_date_object()) place_handle = event.get_place_handle() if place_handle: # feature requests 2356, 1657: avoid genitive form place_title = _pd.display_event(self.db, event, fmt=self.place_fmt) estr = (_(" %s in %s") % (e_date, place_title)) #print(estr) #print(_(" %s in ") % e_date, place_title) else: estr = (_(" %s") % e_date) else: estr = "leer" return estr def __add_grampsID_to_index(self, list, person): """ This procedure adds the (gramps_id, _nd(Person)) tuple to person_tuple = tuple() """ list.append((self._nd.display_name(person.get_primary_name()), person.get_gramps_id())) def __write_referenced_families(self): """ This procedure writes out each of the families related to the place """ i = 0 iw = 0 ifam = 0 marrevt_handle_list = [] marr = [] fam_list = [] fam_index = {} person_index = [] Patenlist = [] with self._user.progress(_("PlaceFamily Report"), _("preparing Dictionaries"), len(self.place_handles)) as step: if self.showgodparents: 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: if not eventref.get_role().is_primary(): pedic[eventref.ref].append( (eventref.get_role(), pe)) for handle in self.place_handles: # first all events event_handles = [ event_handle for (object_type, event_handle ) in self.db.find_backlink_handles(handle, ['Event']) ] event_handles.sort(key=self.sort.by_date_key) # increment progress bar step() # only marriage for evt_handle in event_handles: if self.db.get_event_from_handle( evt_handle).get_type().is_marriage(): marrevt_handle_list.append(evt_handle) # print(len(marrevt_handle_list)) # no dups marr = list(OrderedDict.fromkeys(marrevt_handle_list)) # print(len(marr)) mi = 0 for evt_handle in marr: event = self.db.get_event_from_handle(evt_handle) date = self._get_date(event.get_date_object()) date_sort = event.get_date_object().get_sort_value() descr = event.get_description() ref_handles = [ x for x in self.db.find_backlink_handles(evt_handle) ] # print(mi, evt_handle) mi += 1 for (ref_type, ref_handle) in ref_handles: if ref_type == 'Person': continue else: family = self.db.get_family_from_handle(ref_handle) ifam += 1 father_handle = family.get_father_handle() # now from the families only fathers if father_handle: fp = self.db.get_person_from_handle(father_handle) father_name = \ self._nd.display_name(fp.get_primary_name()).lower() else: father_name = _("unknown") place_d = _pd.display_event(self.db, event) event_details = [ father_handle, father_name, date, ref_handle, descr, place_d, family, date_sort ] fam_list.append(event_details) fam_index_keys = fam_index.keys() printsurname = "NOW" index = 0 for fn in sorted(fam_list, key=lambda t: (locale.strxfrm(t[1]), t[7])): index += 1 fam_index[fn[6].get_gramps_id()] = index for fn in sorted(fam_list, key=lambda t: (locale.strxfrm(t[1]), t[7])): if fn[0] is None: surname = _("unknown") else: surname = self.db.get_person_from_handle( fn[0]).get_primary_name().get_surname() if printsurname == surname: pass else: #Family Surname printsurname = surname self.doc.start_paragraph("PLC-PlaceTitle") mark = IndexMark(surname, INDEX_TYPE_ALP) self.doc.write_text(surname, mark) self.doc.end_paragraph() i += 1 # weddingdetails family = fn[6] iw += 1 self.doc.start_paragraph("PLC-Details") self.doc.start_bold() # self.doc.write_text("<%s> " % iw) self.doc.write_text(" <%s>" % fam_index[fn[6].gramps_id]) # self.doc.write_text("Heirat %s " % fn[1]) self.doc.write_text("%s " % u'\u26AD') self.doc.write_text("%s " % fn[2]) self.doc.end_bold() # wedding place self.doc.write_text("in %s." % fn[5]) # FamID self.doc.write_text(" [%s]" % fn[6].gramps_id) self.doc.end_paragraph() ################################################## # fatherdetails if fn[6].father_handle: father = self.db.get_person_from_handle( fn[6].father_handle) self.doc.start_paragraph("PLC-PlaceDetails") #given Name self.doc.start_bold() mark = ReportUtils.get_person_mark(self.db, father) text = father.get_primary_name().get_first_name() self.doc.write_text(text, mark) self.doc.write_text( " %s" % father.get_primary_name().get_surname()) self.doc.end_bold() self.doc.write_text(" [%s] " % father.get_gramps_id()) #ggf familyID for fam in father.get_family_handle_list(): if self.db.get_family_from_handle( fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text( " [%s]" % self.db.get_family_from_handle(fam).gramps_id) if self.db.get_family_from_handle( fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text( " <%s>" % fam_index[self.db.get_family_from_handle( fam).gramps_id]) self.doc.end_bold() self.__add_grampsID_to_index(person_index, father) #birth date birth_ref = father.get_birth_ref() if birth_ref: self.doc.write_text(" *") self.doc.write_text( self.__format_date_place(birth_ref)) #bapt date for eventref in father.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.db.get_event_from_handle( eventref.ref).get_type( ) == EventType.BAPTISM: self.doc.write_text(" %s " % u'\u2053') self.doc.write_text( self.__format_date_place(eventref)) #death date death_ref = father.get_death_ref() if death_ref: self.doc.write_text(" † ") self.doc.write_text( self.__format_date_place(death_ref)) #burr date for eventref in father.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.db.get_event_from_handle( eventref.ref).get_type( ) == EventType.BURIAL: self.doc.write_text("%s " % u'\u26B0') self.doc.write_text( self.__format_date_place(eventref)) self.doc.end_paragraph() # motherdetails # print(fn[6].gramps_id,fn[6]) print(' handle', fn[6].mother_handle) if fn[6].mother_handle: mother = self.db.get_person_from_handle( fn[6].mother_handle) self.doc.start_paragraph("PLC-PlaceDetails") #given Name self.doc.write_text("und ") self.doc.start_bold() mark = ReportUtils.get_person_mark(self.db, mother) text = mother.get_primary_name().get_surname() self.doc.write_text(text, mark) self.doc.end_bold() self.doc.write_text( " %s " % mother.get_primary_name().get_first_name()) self.doc.write_text("[%s] " % mother.get_gramps_id()) #ggf familyID for fam in mother.get_family_handle_list(): if self.db.get_family_from_handle( fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text( " [%s]" % self.db.get_family_from_handle(fam).gramps_id) if self.db.get_family_from_handle( fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text( " <%s>" % fam_index[self.db.get_family_from_handle( fam).gramps_id]) self.doc.end_bold() self.__add_grampsID_to_index(person_index, mother) #birth date birth_ref = mother.get_birth_ref() if birth_ref: self.doc.write_text(" *") self.doc.write_text( self.__format_date_place(birth_ref)) #bapt date for eventref in mother.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.db.get_event_from_handle( eventref.ref).get_type( ) == EventType.BAPTISM: self.doc.write_text(" %s " % u'\u2053') self.doc.write_text( self.__format_date_place(eventref)) #death date death_ref = mother.get_death_ref() if death_ref: self.doc.write_text(" † ") self.doc.write_text( self.__format_date_place(death_ref)) #burr date for eventref in mother.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.db.get_event_from_handle( eventref.ref).get_type( ) == EventType.BURIAL: self.doc.write_text("%s " % u'\u26B0') self.doc.write_text( self.__format_date_place(eventref)) self.doc.end_paragraph() # Children fc = 0 for ch in fn[6].get_child_ref_list(): self.doc.start_paragraph("PLC-PlaceDetailsChildren") fc += 1 child = self.db.get_person_from_handle(ch.ref) if child: #lnr self.doc.write_text(" %s " % fc) #given Name mark = ReportUtils.get_person_mark(self.db, child) text = child.get_primary_name().get_first_name() self.doc.write_text(text, mark) self.doc.write_text(" [%s] " % child.get_gramps_id()) #ggf familyID for fam in child.get_family_handle_list(): if self.db.get_family_from_handle( fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text( " [%s]" % self.db.get_family_from_handle( fam).gramps_id) if self.db.get_family_from_handle( fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text(" <%s>" % fam_index[ self.db.get_family_from_handle( fam).gramps_id]) self.doc.end_bold() self.__add_grampsID_to_index(person_index, child) #birth date birth_ref = child.get_birth_ref() if birth_ref: self.doc.write_text(" * ") self.doc.write_text( self.__format_date_place(birth_ref)) #bapt date for eventref in child.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.db.get_event_from_handle( eventref.ref).get_type( ) == EventType.BAPTISM: self.doc.write_text(" %s " % u'\u2053') self.doc.write_text( self.__format_date_place(eventref)) if self.showgodparents: Patenlist = [] Patenlist = pedic[eventref.ref] #death date death_ref = child.get_death_ref() if death_ref: self.doc.write_text(" † ") self.doc.write_text( self.__format_date_place(death_ref)) #burr date for eventref in child.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.db.get_event_from_handle( eventref.ref).get_type( ) == EventType.BURIAL: self.doc.write_text("%s " % u'\u26B0') self.doc.write_text( self.__format_date_place(eventref)) self.doc.end_paragraph() if self.showgodparents: if len(Patenlist) > 0: self.doc.start_paragraph("PLC-Godparents") self.doc.write_text(" Paten: ") for i, (pa_a, pa_b) in enumerate(Patenlist): self.doc.write_text(" (%s) " % str(i + 1)) pate = self.db.get_person_from_handle(pa_b) mark = ReportUtils.get_person_mark( self.db, pate) self.doc.write_text( pate.get_primary_name().get_first_name( ) + " " + pate.get_primary_name().get_surname(), mark) self.doc.end_paragraph() Patenlist = [] person_index = list(set(person_index)) for (indname, pi) in sorted(person_index): print(indname, pi) self.doc.start_paragraph("PLC-Details") self.doc.write_text("%s [%s]" % (indname, pi)) self.doc.end_paragraph() self.doc.start_paragraph("PLC-Details") self.doc.write_text("Anzahl: %s" % len(person_index)) self.doc.end_paragraph() ########## def __get_place_handles(self, places): """ This procedure converts a string of place GIDs to a list of handles """ place_handles = [] for place_gid in places.split(): place = self.db.get_place_from_gramps_id(place_gid) if place is not None: place_handles.append(place.get_handle()) return place_handles
class PlaceFamilyReport(Report): """ Place Report class """ def __init__(self, database, options, user): """ Create the PlaceFamilyReport object produces the PlaceFamily report. The arguments are: database - the GRAMPS database instance options - instance of the Options class for this report user - instance of a gen.user.User class This report needs the following parameters (class variables) that come in the options class. places - List of places to report on. # placeformat - Format of Place to display incpriv - Whether to include private data showgodparents - Whether to include and show godparents """ Report.__init__(self, database, options, user) self._user = user menu = options.menu places = menu.get_option_by_name('places').get_value() self.pl_format = menu.get_option_by_name('placeformat').get_value() #U self.placeformat = get_value('placeformat') self.incpriv = menu.get_option_by_name('incpriv').get_value() self.showgodparents = menu.get_option_by_name( 'showgodparents').get_value() self.set_locale(menu.get_option_by_name('trans').get_value()) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) self._nd = self._name_display if self.incpriv: self.database = database else: self.database = PrivateProxyDb(database) filter_option = menu.get_option_by_name('filter') self.filter = filter_option.get_filter() self.sort = Sort(self.database) if self.filter.get_name() != '': # Use the selected filter to provide a list of place handles plist = self.database.iter_place_handles() self.place_handles = self.filter.apply(self.database, plist) else: # Use the place handles selected without a filter self.place_handles = self.__get_place_handles(places) self.place_handles.sort(key=self.sort.by_place_title_key) def write_report(self): """ The routine that actually creates the report. At this point, the document is opened and ready for writing. """ # Write the title line. Set in INDEX marker so that this section will be # identified as a major category if this is included in a Book report. pl_format = self.pl_format title = self._("PlaceFamily Report") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("PLC-ReportTitle") self.doc.write_text(title, mark) self.doc.end_paragraph() self.__write_all_places(pl_format) self.__write_referenced_families(pl_format) def __write_all_places(self, pl_format): """ This procedure writes out each of the selected places. """ place_nbr = 1 with self._user.progress(_("PlaceFamily Report"), _("Generating report"), len(self.place_handles)) as step: subtitle = self._("Places") mark = IndexMark(subtitle, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("PLC-ReportSubtitle") self.doc.write_text(subtitle, mark) self.doc.end_paragraph() self.doc.start_paragraph("PLC-Section") self.doc.write_text( "Enthält alle Familien mit Hochzeitsereignis in diesem Ort") self.doc.end_paragraph() for handle in self.place_handles: if handle: self.doc.start_paragraph("PLC-Section") printplace = self.database.get_place_from_handle( handle).get_title() indexplace = printplace + " L_INDEX" # indexplace = printplace+" ' \f 'O'" mark = IndexMark(indexplace, INDEX_TYPE_ALP) #mark = IndexMark(indexplace, INDEX_TYPE_ALP, iname="HUHUHU") print(mark.key, mark.type, mark.level) self.doc.write_text(printplace, mark) # self.doc.write_text(self.database.get_place_from_handle(handle).get_title(),mark) self.doc.end_paragraph() place_nbr += 1 # increment progress bar step() subtitle = self._("Families") mark = IndexMark(subtitle, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("PLC-ReportSubtitle") self.doc.write_text(subtitle, mark) self.doc.end_paragraph() def __format_date(self, date_object): if not date_object: return d = date_object.get_day() m = date_object.get_month() y = date_object.get_year() if (d == 0) and (m == 0): date_f = (" %s" % y) elif (d == 0) and not (m == 0): date_f = (" %s.%s" % (m, y)) else: date_f = (" %s.%s.%s" % (d, m, y)) return date_f # def __format_place(self, place_string, pl_format): # if (len(place_string) <=0): return place_string # if (pl_format == "default"): # # Default # place_string = (" in %s " % place_string) # elif (pl_format == "one"): # # one # place_list = place_string.split(',') # place_string = (" in %s " % place_list[0].strip()) # elif (pl_format == "place-country"): # # place-country # place_list = place_string.split(',') # place_string = (" in %s " % place_list[0].strip()+", "+place_list[-1].strip()) # elif (pl_format == "long"): # # long # place_string = (" in %s " % place_string) # return place_string def __write_referenced_families(self, pl_format): """ This procedure writes out each of the families related to the place """ i = 0 iw = 0 ifam = 0 marrevt_handle_list = [] marr = [] fam_list = [] fam_index = {} # Paten_list = [] if self.showgodparents: pedic = {} pedic = defaultdict(list) for pe in self.database.get_person_handles(): for eventref in self.database.get_person_from_handle( pe).event_ref_list: if not eventref.get_role().is_primary(): pedic[eventref.ref].append((eventref.get_role(), pe)) with self._user.progress(_("PlaceFamily Report"), ("Generating report"), len(self.place_handles)) as step: for handle in self.place_handles: # first all events event_handles = [ event_handle for (object_type, event_handle) in self.database.find_backlink_handles(handle, ['Event']) ] event_handles.sort(key=self.sort.by_date_key) # only marriage for evt_handle in event_handles: if self.database.get_event_from_handle( evt_handle).get_type().is_marriage(): marrevt_handle_list.append(evt_handle) # no dups marr = list(OrderedDict.fromkeys(marrevt_handle_list)) # print(len(marr)) mi = 0 for evt_handle in marr: event = self.database.get_event_from_handle(evt_handle) date = self._get_date(event.get_date_object()) date_sort = event.get_date_object().get_sort_value() descr = event.get_description() # event_type = self._(self._get_type(event.get_type())) # event_place = event.place ref_handles = [ x for x in self.database.find_backlink_handles(evt_handle) ] # print(mi, evt_handle) mi += 1 for (ref_type, ref_handle) in ref_handles: if ref_type == 'Person': continue else: family = self.database.get_family_from_handle( ref_handle) ifam += 1 father_handle = family.get_father_handle() # now from the families only fathers if father_handle: fp = self.database.get_person_from_handle( father_handle) father_name = \ self._name_display.display_name(fp.get_primary_name()).lower() else: father_name = _("unknown") place_d = place_displayer.display_event( self.database, event, pl_format) # print(place_d) event_details = [ father_handle, father_name, date, ref_handle, descr, place_d, family, date_sort ] fam_list.append(event_details) # print(sorted(fam_list, key=itemgetter(1,7))) # print(len(fam_list)) printsurname = "NOW" index = 0 ########################## #for fn in sorted(fam_list, key=itemgetter(1,7)): #fam_list_name # TEST FOR SORTING # lastnames = ["Bange", "Änger", "Amman", "Änger", "Zelch", "Ösbach"] # print(sorted(lastnames, key=locale.strxfrm)) # print() # # lastnames_firstnames_groups =[ # ["Bange", "Michael", 2], # ["Änger", "Ämma", 2], # ["Amman", "Anton", 1], # ["Änger", "Chris", 2], # ["Zelch", "Sven", 1], # ["Ösbach", "Carl", 1] # ] # print(sorted(lastnames_firstnames_groups, key=operator.itemgetter(2,0,1))) # print( # sorted( # lastnames_firstnames_groups, # key=lambda t: (t[2], locale.strxfrm(t[0]), locale.strxfrm(t[1])) # ) # ) #************************** for fn in sorted(fam_list, key=lambda t: (locale.strxfrm(t[1]), t[7])): index += 1 fam_index[fn[6].get_gramps_id()] = index # print(index) # for ifn in fam_index.keys(): # print(ifn, fam_index[ifn]) fam_index_keys = fam_index.keys() for fn in sorted(fam_list, key=lambda t: (locale.strxfrm(t[1]), t[7])): if fn[0] is None: surname = _("unknown") else: surname = self.database.get_person_from_handle( fn[0]).get_primary_name().get_surname() # print(fn[0], surname) if printsurname == surname: pass else: #Family Surname printsurname = surname # S_Name = ("%s " % surname) # mark = IndexMark(S_Name, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("PLC-PlaceTitle") # self.doc.write_text("%s " % surname) # mark = ReportUtils.get_person_mark(self.database,surname) # mark = IndexMark( surname, INDEX_TYPE_ALP ) # indexname = surname+" P_INDEX" indexname = surname + " P_INDEX" mark = IndexMark(indexname, INDEX_TYPE_ALP, 2) self.doc.write_text(surname, mark) self.doc.end_paragraph() i += 1 # weddingdetails family = fn[6] iw += 1 self.doc.start_paragraph("PLC-Details") self.doc.start_bold() # self.doc.write_text("<%s> " % iw) self.doc.write_text(" <%s>" % fam_index[fn[6].gramps_id]) # self.doc.write_text("Heirat %s " % fn[1]) self.doc.write_text("%s " % u'\u26AD') self.doc.write_text("%s " % fn[2]) self.doc.end_bold() # increment progress bar step() #given Name # wedding place #UINDEX self.doc.write_text(" %s." % fn[5]+" P_INDEX"+" LLL") self.doc.write_text(" %s." % fn[5]) # FamID self.doc.write_text(" [%s]" % fn[6].gramps_id) self.doc.end_paragraph() ################################################## # fatherdetails father = self.database.get_person_from_handle( fn[6].father_handle) if father: self.doc.start_paragraph("PLC-PlaceDetails") #given Name self.doc.start_bold() # self.doc.write_text("%s " % father.get_primary_name().get_first_name()) mark = ReportUtils.get_person_mark(self.database, father) text = father.get_primary_name().get_first_name() self.doc.write_text(text, mark) self.doc.write_text( " %s" % father.get_primary_name().get_surname()) self.doc.end_bold() self.doc.write_text("[%s] " % father.get_gramps_id()) #ggf familyID for fam in father.get_family_handle_list(): if self.database.get_family_from_handle( fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text( " [%s]" % self.database.get_family_from_handle( fam).gramps_id) if self.database.get_family_from_handle( fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text(" <%s>" % fam_index[ self.database.get_family_from_handle( fam).gramps_id]) self.doc.end_bold() #birth date birth_ref = father.get_birth_ref() if birth_ref: # erst event birth_event = self.database.get_event_from_handle( birth_ref.ref) self.doc.write_text(" * ") self.doc.write_text( self.__format_date(birth_event.get_date_object())) #birth place # dann display place #P print("HIER") #p print(place_displayer.display_event(self.database, birth_event, pl_format)) self.doc.write_text( " " + place_displayer.display_event( self.database, birth_event, pl_format)) #bapt date for eventref in father.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle( eventref.ref).get_type( ) == EventType.BAPTISM: # erst event bapt_event = self.database.get_event_from_handle( eventref.ref) self.doc.write_text(" %s " % u'\u2053') self.doc.write_text( self.__format_date( bapt_event.get_date_object())) #bapt place # # erst event bapt_event = self.database.get_event_from_handle( eventref.ref) # dann display place self.doc.write_text( " " + place_displayer.display_event( self.database, bapt_event, pl_format)) #death date death_ref = father.get_death_ref() if death_ref: # erst event death_event = self.database.get_event_from_handle( death_ref.ref) self.doc.write_text(" † ") self.doc.write_text( self.__format_date(death_event.get_date_object())) #death place self.doc.write_text( " " + place_displayer.display_event( self.database, death_event, pl_format)) #burr date for eventref in father.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle( eventref.ref).get_type( ) == EventType.BURIAL: # erst event burr_event = self.database.get_event_from_handle( eventref.ref) self.doc.write_text("%s " % u'\u26B0') self.doc.write_text( self.__format_date( burr_event.get_date_object())) #burr place # dann display place self.doc.write_text( " " + place_displayer.display_event( self.database, burr_event, pl_format)) self.doc.end_paragraph() ############################################################ # motherdetails mother = self.database.get_person_from_handle( fn[6].mother_handle) if mother: self.doc.start_paragraph("PLC-PlaceDetails") #given Name self.doc.write_text("und ") self.doc.start_bold() mark = ReportUtils.get_person_mark(self.database, mother) text = mother.get_primary_name().get_surname() self.doc.write_text(text, mark) # self.doc.write_text("%s, " % mother.get_primary_name().get_surname()) self.doc.end_bold() self.doc.write_text( " %s " % mother.get_primary_name().get_first_name()) self.doc.write_text("[%s] " % mother.get_gramps_id()) #ggf familyID for fam in mother.get_family_handle_list(): if self.database.get_family_from_handle( fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text( " [%s]" % self.database.get_family_from_handle( fam).gramps_id) if self.database.get_family_from_handle( fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text(" <%s>" % fam_index[ self.database.get_family_from_handle( fam).gramps_id]) self.doc.end_bold() #birth date birth_ref = mother.get_birth_ref() if birth_ref: # erst event birth_event = self.database.get_event_from_handle( birth_ref.ref) self.doc.write_text(" * ") self.doc.write_text( self.__format_date(birth_event.get_date_object())) #birth place # dann display place place_string = place_displayer.display_event( self.database, birth_event, pl_format) self.doc.write_text(" " + place_string) #bapt date for eventref in mother.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle( eventref.ref).get_type( ) == EventType.BAPTISM: # erst event bapt_event = self.database.get_event_from_handle( eventref.ref) self.doc.write_text(" %s " % u'\u2053') self.doc.write_text( self.__format_date( bapt_event.get_date_object())) #bapt place # dann display place place_string = place_displayer.display_event( self.database, bapt_event, pl_format) self.doc.write_text(" " + place_string) #death date death_ref = mother.get_death_ref() if death_ref: # erst event death_event = self.database.get_event_from_handle( death_ref.ref) self.doc.write_text(" † ") self.doc.write_text( self.__format_date(death_event.get_date_object())) #death place place_string = place_displayer.display_event( self.database, death_event, pl_format) self.doc.write_text(" " + place_string) #burr date for eventref in mother.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle( eventref.ref).get_type( ) == EventType.BURIAL: # erst event burr_event = self.database.get_event_from_handle( eventref.ref) self.doc.write_text("%s " % u'\u26B0') self.doc.write_text( self.__format_date( burr_event.get_date_object())) #burr place # dann display place place_string = place_displayer.display_event( self.database, burr_event, pl_format) self.doc.write_text(" " + place_string) self.doc.end_paragraph() ############################################################ # Children fc = 0 for ch in fn[6].get_child_ref_list(): self.doc.start_paragraph("PLC-PlaceDetailsChildren") fc += 1 child = self.database.get_person_from_handle(ch.ref) if child: #lnr self.doc.write_text(" %s " % fc) #given Name mark = ReportUtils.get_person_mark( self.database, child) text = child.get_primary_name().get_first_name() self.doc.write_text(text, mark) # self.doc.write_text("%s " % child.get_primary_name().get_first_name()) self.doc.write_text("[%s] " % child.get_gramps_id()) #ggf familyID for fam in child.get_family_handle_list(): if self.database.get_family_from_handle( fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text( " [%s]" % self.database.get_family_from_handle( fam).gramps_id) if self.database.get_family_from_handle( fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text(" <%s>" % fam_index[ self.database.get_family_from_handle( fam).gramps_id]) self.doc.end_bold() #birth date birth_ref = child.get_birth_ref() if birth_ref: # erst event birth_event = self.database.get_event_from_handle( birth_ref.ref) self.doc.write_text(" * ") self.doc.write_text( self.__format_date( birth_event.get_date_object())) #birth place place_string = place_displayer.display_event( self.database, birth_event, pl_format) self.doc.write_text(" " + place_string) #bapt date for eventref in child.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle( eventref.ref).get_type( ) == EventType.BAPTISM: # erst event bapt_event = self.database.get_event_from_handle( eventref.ref) self.doc.write_text(" %s " % u'\u2053') self.doc.write_text( self.__format_date( bapt_event.get_date_object())) #bapt place # dann display place place_string = place_displayer.display_event( self.database, bapt_event, pl_format) self.doc.write_text(" " + place_string) if self.showgodparents: Patenlist = [] Patenlist = pedic[eventref.ref] #death date death_ref = child.get_death_ref() if death_ref: # erst event death_event = self.database.get_event_from_handle( death_ref.ref) self.doc.write_text(" † ") self.doc.write_text( self.__format_date( death_event.get_date_object())) #death place # dann display place place_string = place_displayer.display_event( self.database, death_event, pl_format) self.doc.write_text(" " + place_string) #burr date for eventref in child.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle( eventref.ref).get_type( ) == EventType.BURIAL: # erst event burr_event = self.database.get_event_from_handle( eventref.ref) self.doc.write_text("%s " % u'\u26B0') self.doc.write_text( self.__format_date( burr_event.get_date_object())) #burr place # dann display place place_string = place_displayer.display_event( self.database, burr_event, pl_format) # dann drucken self.doc.write_text(" " + place_string) self.doc.end_paragraph() # print(len(Patenlist)) if self.showgodparents: if len(Patenlist) > 0: self.doc.start_paragraph("PLC-Godparents") self.doc.write_text(" Paten: ") for i, (pa_a, pa_b) in enumerate(Patenlist): self.doc.write_text(" (%s) " % str(i + 1)) pate_name = self.database.get_person_from_handle( pa_b ).get_primary_name().get_first_name( ) + " " + self.database.get_person_from_handle( pa_b).get_primary_name().get_surname() pate = self.database.get_person_from_handle( pa_b) # print(pate, pate_name) mark = ReportUtils.get_person_mark( self.database, pate) self.doc.write_text( pate.get_primary_name().get_first_name( ) + " " + pate.get_primary_name().get_surname(), mark) self.doc.end_paragraph() Patenlist = [] # print(ifam, "family") def __get_place_handles(self, places): """ This procedure converts a string of place GIDs to a list of handles """ place_handles = [] for place_gid in places.split(): place = self.database.get_place_from_gramps_id(place_gid) if place is not None: place_handles.append(place.get_handle()) return place_handles
class PlaceFamilyReport(Report): """ Place Report class """ def __init__(self, database, options, user): """ Create the PlaceFamilyReport object produces the PlaceFamily report. The arguments are: database - the GRAMPS database instance options - instance of the Options class for this report user - instance of a gen.user.User class This report needs the following parameters (class variables) that come in the options class. places - List of places to report on. # center - Center of report, person or event incpriv - Whether to include private data showgodparents - Whether to include and show godparents """ Report.__init__(self, database, options, user) self._user = user menu = options.menu places = menu.get_option_by_name('places').get_value() # self.center = menu.get_option_by_name('center').get_value() self.incpriv = menu.get_option_by_name('incpriv').get_value() self.showgodparents = menu.get_option_by_name('showgodparents').get_value() self.set_locale(menu.get_option_by_name('trans').get_value()) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) self._nd = self._name_display if self.incpriv: self.database = database else: self.database = PrivateProxyDb(database) filter_option = menu.get_option_by_name('filter') self.filter = filter_option.get_filter() self.sort = Sort(self.database) if self.filter.get_name() != '': # Use the selected filter to provide a list of place handles plist = self.database.iter_place_handles() self.place_handles = self.filter.apply(self.database, plist) else: # Use the place handles selected without a filter self.place_handles = self.__get_place_handles(places) self.place_handles.sort(key=self.sort.by_place_title_key) def write_report(self): """ The routine that actually creates the report. At this point, the document is opened and ready for writing. """ # Write the title line. Set in INDEX marker so that this section will be # identified as a major category if this is included in a Book report. title = self._("PlaceFamily Report") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("PLC-ReportTitle") self.doc.write_text(title, mark) self.doc.end_paragraph() self.__write_all_places() self.__write_referenced_families() def __write_all_places(self): """ This procedure writes out each of the selected places. """ place_nbr = 1 with self._user.progress(_("PlaceFamily Report"), _("Generating report"), len(self.place_handles)) as step: subtitle = self._("Places") mark = IndexMark(subtitle, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("PLC-ReportSubtitle") self.doc.write_text(subtitle, mark) self.doc.end_paragraph() self.doc.start_paragraph("PLC-Section") self.doc.write_text("Enthält alle Familien mit Hochzeitsereignis in diesem Ort") self.doc.end_paragraph() for handle in self.place_handles: if handle: self.doc.start_paragraph("PLC-Section") self.doc.write_text(self.database.get_place_from_handle(handle).get_title()) self.doc.end_paragraph() place_nbr += 1 # increment progress bar step() subtitle = self._("Families") mark = IndexMark(subtitle, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("PLC-ReportSubtitle") self.doc.write_text(subtitle, mark) self.doc.end_paragraph() def __format_date(self, date_object): if not date_object: return d=date_object.get_day() m=date_object.get_month() y=date_object.get_year() if (d == 0) and (m == 0): date_f = (" %s" % y) elif (d == 0) and not (m == 0): date_f = (" %s.%s" % (m, y)) else: date_f = (" %s.%s.%s" % (d, m, y)) return date_f def __write_referenced_families(self): """ This procedure writes out each of the families related to the place """ i = 0 iw = 0 ifam = 0 marrevt_handle_list =[] marr =[] fam_list=[] fam_index={} Paten_list =[] if self.showgodparents: pedic ={} pedic = defaultdict(list) for pe in self.database.get_person_handles(): for eventref in self.database.get_person_from_handle(pe).event_ref_list: if not eventref.get_role().is_primary(): pedic[eventref.ref].append((eventref.get_role(),pe)) with self._user.progress(_("PlaceFamily Report"), _("Generating report"), len(self.place_handles)) as step: for handle in self.place_handles: # first all events event_handles = [event_handle for (object_type, event_handle) in self.database.find_backlink_handles(handle, ['Event'])] event_handles.sort(key=self.sort.by_date_key) # if event_handles: # self.doc.start_paragraph("PLC-Section") # self.doc.write_text(self.database.get_place_from_handle(handle).get_title()) # self.doc.end_paragraph() # # print(len(event_handles)) # only marriage for evt_handle in event_handles: if self.database.get_event_from_handle(evt_handle).get_type().is_marriage(): marrevt_handle_list.append(evt_handle) # print(len(marrevt_handle_list)) # no dups marr = list(OrderedDict.fromkeys(marrevt_handle_list)) # print(len(marr)) mi = 0 for evt_handle in marr: event = self.database.get_event_from_handle(evt_handle) date = self._get_date(event.get_date_object()) date_sort = event.get_date_object().get_sort_value() descr = event.get_description() event_type = self._(self._get_type(event.get_type())) event_place = event.place ref_handles = [x for x in self.database.find_backlink_handles(evt_handle)] # print(mi, evt_handle) mi += 1 for (ref_type, ref_handle) in ref_handles: if ref_type == 'Person': continue else: family = self.database.get_family_from_handle(ref_handle) ifam +=1 father_handle = family.get_father_handle() # now from the families only fathers if father_handle: fp = self.database.get_person_from_handle(father_handle) father_name = \ self._name_display.display_name(fp.get_primary_name()).lower() else: father_name = _("unknown") place_d = place_displayer.display_event(self.database, event) event_details = [ father_handle, father_name, date, ref_handle, descr, place_d, family, date_sort] fam_list.append(event_details) # print(sorted(fam_list, key=itemgetter(1,7))) # print(len(fam_list)) printsurname = "NOW" index=0 for fn in sorted(fam_list, key=itemgetter(1,7)): index +=1 fam_index[fn[6].get_gramps_id()]=index # print(index) # for ifn in fam_index.keys(): # print(ifn, fam_index[ifn]) fam_index_keys = fam_index.keys() for fn in sorted(fam_list, key=itemgetter(1,7)): if fn[0] is None: surname = _("unknown") else: surname = self.database.get_person_from_handle(fn[0]).get_primary_name().get_surname() # print(fn[0], surname) if printsurname == surname: pass else: #Family Surname printsurname = surname # S_Name = ("%s " % surname) # mark = IndexMark(S_Name, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("PLC-PlaceTitle") # self.doc.write_text("%s " % surname) # mark = ReportUtils.get_person_mark(self.database,surname) mark = IndexMark( surname, INDEX_TYPE_ALP ) self.doc.write_text(surname,mark) self.doc.end_paragraph() i +=1 # weddingdetails family = fn[6] iw += 1 self.doc.start_paragraph("PLC-Details") self.doc.start_bold() # self.doc.write_text("<%s> " % iw) self.doc.write_text(" <%s>" % fam_index[fn[6].gramps_id]) # self.doc.write_text("Heirat %s " % fn[1]) self.doc.write_text("%s " % u'\u26AD') self.doc.write_text("%s " % fn[2]) self.doc.end_bold() # increment progress bar step() #given Name # wedding place self.doc.write_text("in %s." % fn[5]) # FamID self.doc.write_text(" [%s]" % fn[6].gramps_id) self.doc.end_paragraph() ################################################## # fatherdetails father = self.database.get_person_from_handle(fn[6].father_handle) if father: self.doc.start_paragraph("PLC-PlaceDetails") #given Name self.doc.start_bold() # self.doc.write_text("%s " % father.get_primary_name().get_first_name()) mark = ReportUtils.get_person_mark(self.database,father) text = father.get_primary_name().get_first_name() self.doc.write_text(text,mark) self.doc.write_text(" %s" % father.get_primary_name().get_surname()) self.doc.end_bold() self.doc.write_text("[%s] " % father.get_gramps_id()) #ggf familyID for fam in father.get_family_handle_list(): if self.database.get_family_from_handle(fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text(" [%s]" % self.database.get_family_from_handle(fam).gramps_id) if self.database.get_family_from_handle(fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text(" <%s>" % fam_index[self.database.get_family_from_handle(fam).gramps_id]) self.doc.end_bold() #birth date birth_ref = father.get_birth_ref() if birth_ref: self.doc.write_text(" * ") self.doc.write_text(self.__format_date(self.database.get_event_from_handle(birth_ref.ref).get_date_object())) #birth place place_handle = self.database.get_event_from_handle(birth_ref.ref).get_place_handle() if place_handle: birth_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % birth_place_string) #bapt date for eventref in father.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle(eventref.ref).get_type() == EventType.BAPTISM: self.doc.write_text(" %s " % u'\u2053') self.doc.write_text(self.__format_date(self.database.get_event_from_handle(eventref.ref).get_date_object())) #bapt place place_handle = self.database.get_event_from_handle(eventref.ref).get_place_handle() if place_handle: bapt_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % bapt_place_string) #death date death_ref = father.get_death_ref() if death_ref: self.doc.write_text(" † ") self.doc.write_text(self.__format_date(self.database.get_event_from_handle(death_ref.ref).get_date_object())) #death place place_handle = self.database.get_event_from_handle(death_ref.ref).get_place_handle() if place_handle: death_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % death_place_string) #burr date for eventref in father.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle(eventref.ref).get_type() == EventType.BURIAL: self.doc.write_text("%s " % u'\u26B0') self.doc.write_text(self.__format_date(self.database.get_event_from_handle(eventref.ref).get_date_object())) #burr place place_handle = self.database.get_event_from_handle(eventref.ref).get_place_handle() if place_handle: bur_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % bur_place_string) self.doc.end_paragraph() ############################################################ # motherdetails mother = self.database.get_person_from_handle(fn[6].mother_handle) if mother: self.doc.start_paragraph("PLC-PlaceDetails") #given Name self.doc.write_text("und ") self.doc.start_bold() mark = ReportUtils.get_person_mark(self.database,mother) text = mother.get_primary_name().get_surname() self.doc.write_text(text,mark) # self.doc.write_text("%s, " % mother.get_primary_name().get_surname()) self.doc.end_bold() self.doc.write_text(" %s " % mother.get_primary_name().get_first_name()) self.doc.write_text("[%s] " % mother.get_gramps_id()) #ggf familyID for fam in mother.get_family_handle_list(): if self.database.get_family_from_handle(fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text(" [%s]" % self.database.get_family_from_handle(fam).gramps_id) if self.database.get_family_from_handle(fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text(" <%s>" % fam_index[self.database.get_family_from_handle(fam).gramps_id]) self.doc.end_bold() birth_ref = mother.get_birth_ref() if birth_ref: self.doc.write_text(" * ") self.doc.write_text(self.__format_date(self.database.get_event_from_handle(birth_ref.ref).get_date_object())) #birth place place_handle = self.database.get_event_from_handle(birth_ref.ref).get_place_handle() if place_handle: birth_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % birth_place_string) #bapt date for eventref in mother.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle(eventref.ref).get_type() == EventType.BAPTISM: self.doc.write_text(" %s " % u'\u2053') self.doc.write_text(self.__format_date(self.database.get_event_from_handle(eventref.ref).get_date_object())) #bapt place place_handle = self.database.get_event_from_handle(eventref.ref).get_place_handle() if place_handle: bapt_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % bapt_place_string) #death date death_ref = mother.get_death_ref() if death_ref: self.doc.write_text(" † ") self.doc.write_text(self.__format_date(self.database.get_event_from_handle(death_ref.ref).get_date_object())) #death place place_handle = self.database.get_event_from_handle(death_ref.ref).get_place_handle() if place_handle: death_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % death_place_string) #burr date for eventref in mother.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle(eventref.ref).get_type() == EventType.BURIAL: self.doc.write_text("%s " % u'\u26B0') self.doc.write_text(self.__format_date(self.database.get_event_from_handle(eventref.ref).get_date_object())) #burr place place_handle = self.database.get_event_from_handle(eventref.ref).get_place_handle() if place_handle: bur_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % bur_place_string) self.doc.end_paragraph() ############################################################ # Children fc = 0 for ch in fn[6].get_child_ref_list(): self.doc.start_paragraph("PLC-PlaceDetailsChildren") fc +=1 child = self.database.get_person_from_handle(ch.ref) if child: #lnr self.doc.write_text(" %s " % fc) #given Name mark = ReportUtils.get_person_mark(self.database, child) text = child.get_primary_name().get_first_name() self.doc.write_text(text, mark) # self.doc.write_text("%s " % child.get_primary_name().get_first_name()) self.doc.write_text("[%s] " % child.get_gramps_id()) #ggf familyID for fam in child.get_family_handle_list(): if self.database.get_family_from_handle(fam).gramps_id == fn[6].gramps_id: pass else: self.doc.write_text(" [%s]" % self.database.get_family_from_handle(fam).gramps_id) if self.database.get_family_from_handle(fam).gramps_id in fam_index_keys: self.doc.start_bold() self.doc.write_text(" <%s>" % fam_index[self.database.get_family_from_handle(fam).gramps_id]) self.doc.end_bold() #birth date birth_ref = child.get_birth_ref() if birth_ref: self.doc.write_text(" * ") self.doc.write_text(self.__format_date(self.database.get_event_from_handle(birth_ref.ref).get_date_object())) #birth place place_handle = self.database.get_event_from_handle(birth_ref.ref).get_place_handle() if place_handle: birth_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % birth_place_string) #bapt date for eventref in child.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle(eventref.ref).get_type() == EventType.BAPTISM: BaptEvt = self.database.get_event_from_handle(eventref.ref) self.doc.write_text(" %s " % u'\u2053') self.doc.write_text(self.__format_date(self.database.get_event_from_handle(eventref.ref).get_date_object())) #bapt place place_handle = self.database.get_event_from_handle(eventref.ref).get_place_handle() if place_handle: bapt_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % bapt_place_string) if self.showgodparents: Patenlist = [] # if len(pedic[eventref.ref])>0: # # self.doc.start_superscript() # # self.doc.write_text(" Paten: ") # for i,(pa_a,pa_b) in enumerate(pedic[eventref.ref]): # # self.doc.write_text(" (%s) " % str(i+1)) # # pate_name = self.database.get_person_from_handle(pa_b).get_primary_name().get_first_name() +" "+ self.database.get_person_from_handle(pa_b).get_primary_name().get_surname() # pate = self.database.get_person_from_handle(pa_b) # # # mark = ReportUtils.get_person_mark(self.database, pate) # # text = self.database.get_person_from_handle(pa_b).get_primary_name().get_first_name() +" "+ self.database.get_person_from_handle(pa_b).get_primary_name().get_surname() # # # self.doc.write_text(text, mark) # # self.doc.write_text("%s " % child.get_primary_name().get_first_name()) # # self.doc.write_text("[%s] " % pate.get_gramps_id()) # # self.doc.write_text(" %s;" % pate_name) # Patenlist.append(pate) # # self.doc.end_superscript() Patenlist = pedic[eventref.ref] #death date death_ref = child.get_death_ref() if death_ref: self.doc.write_text(" † ") self.doc.write_text(self.__format_date(self.database.get_event_from_handle(death_ref.ref).get_date_object())) #death place place_handle = self.database.get_event_from_handle(death_ref.ref).get_place_handle() if place_handle: death_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % death_place_string) #burr date for eventref in child.event_ref_list: if eventref.role == EventRoleType.PRIMARY: if self.database.get_event_from_handle(eventref.ref).get_type() == EventType.BURIAL: self.doc.write_text("%s " % u'\u26B0') self.doc.write_text(self.__format_date(self.database.get_event_from_handle(eventref.ref).get_date_object())) #burr place place_handle = self.database.get_event_from_handle(eventref.ref).get_place_handle() if place_handle: bur_place_string = self.database.get_place_from_handle( place_handle).get_title() self.doc.write_text(" in %s " % bur_place_string) self.doc.end_paragraph() if self.showgodparents: self.doc.start_paragraph("PLC-Godparents") self.doc.write_text(" Paten: ") for i,(pa_a,pa_b) in enumerate(Patenlist): self.doc.write_text(" (%s) " % str(i+1)) pate_name = self.database.get_person_from_handle(pa_b).get_primary_name().get_first_name() +" "+ self.database.get_person_from_handle(pa_b).get_primary_name().get_surname() pate = self.database.get_person_from_handle(pa_b) mark = ReportUtils.get_person_mark(self.database, pate) self.doc.write_text(pate.get_primary_name().get_first_name() +" "+ pate.get_primary_name().get_surname() ,mark) self.doc.end_paragraph() Patenlist =[] # print(ifam, "family") def __get_place_handles(self, places): """ This procedure converts a string of place GIDs to a list of handles """ place_handles = [] for place_gid in places.split(): place = self.database.get_place_from_gramps_id(place_gid) if place is not None: place_handles.append(place.get_handle()) return place_handles
class ListeEclairReport(Report): def __init__(self, database, options_class, user): Report.__init__(self, database, options_class, user) menu = options_class.menu places = menu.get_option_by_name('places').get_value() self.reporttype = menu.get_option_by_name('reporttype').get_value() self.incpriv = menu.get_option_by_name('incpriv').get_value() #self.incliving = menu.get_option_by_name('incliving').get_value() if self.incpriv: self.database = database else: self.database = PrivateProxyDb(database) #self.database = LivingProxyDb(database, LivingProxyDb.MODE_EXCLUDE_ALL) filter_option = menu.get_option_by_name('filter') self.filter = filter_option.get_filter() self.sort = Sort(self.database) if self.filter.get_name() != '': # Use the selected filter to provide a list of place handles plist = self.database.iter_place_handles() self.place_handles = self.filter.apply(self.database, plist) else: # Use the place handles selected without a filter self.place_handles = self.__get_place_handles(places) self.place_handles.sort(key=self.sort.by_place_title_key) def write_report(self): """ The routine the actually creates the report. At this point, the document is opened and ready for writing. """ # Create progress meter bar self.progress = ProgressMeter(_("Liste Eclair"), '') # Write the title line. Set in INDEX marker so that this section will be # identified as a major category if this is included in a Book report. title = _("Liste Eclair") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("Eclair-ReportTitle") self.doc.write_text(title, mark) self.doc.end_paragraph() self.__write_all_places() # Close the progress meter self.progress.close() def __write_all_places(self): """ This procedure writes out each of the selected places. """ place_nbr = 1 self.doc.start_paragraph("Eclair-Report") self.progress.set_pass(_("Generating report"), len(self.place_handles)) self.result=[] for handle in self.place_handles: city = self.__write_place(handle, place_nbr) self.__write_referenced_events(handle, city) place_nbr += 1 # increment progress bar self.progress.step() self.result.sort() for msg in self.result: # AttributeError: 'GtkDocDocument' object has no attribute 'add_text self.doc.write_text("%s\n" % msg) self.doc.end_paragraph() def __write_place(self, handle, place_nbr): """ This procedure writes out the details of a single place """ place = self.database.get_place_from_handle(handle) location = get_main_location(self.database, place) city = location.get(PlaceType.CITY) place_title = _pd.display(self.database, place) if city == '' and place_title: city = place_title return city def __write_referenced_events(self, handle , city): """ This procedure writes out each of the events related to the place """ event_handles = [event_handle for (object_type, event_handle) in self.database.find_backlink_handles(handle)] #event_handles.sort(self.sort.by_date) self.debut = defaultdict(lambda: defaultdict(dict)) self.fin = defaultdict(lambda: defaultdict(dict)) for evt_handle in event_handles: event = self.database.get_event_from_handle(evt_handle) if event: date = event.get_date_object() if date: year = int(date.get_year()) else: next() person_list = [] ref_handles = [x for x in self.database.find_backlink_handles(evt_handle)] for (ref_type, ref_handle) in ref_handles: if ref_type == 'Person': person_list.append(ref_handle) else: family = self.database.get_family_from_handle(ref_handle) # bug 8584 if family: father = family.get_father_handle() if father: person_list.append(father) mother = family.get_mother_handle() if mother: person_list.append(mother) people = "" person_list = list(set(person_list)) for p_handle in person_list: person = self.database.get_person_from_handle(p_handle) if person: people = person.get_primary_name().get_surname() if not self.debut[city][people]: self.debut[city][people] = year self.fin[city][people] = year if self.debut[city][people] > year: self.debut[city][people] = year if self.fin[city][people] < year: self.fin[city][people] = year event_details = [year, people] keylist = self.debut.keys() #keylist.sort() sorted(list(keylist)) # bug 8437 for city in keylist: for people in sorted(self.debut[city].keys()): if self.reporttype == "ListeEclair": if self.debut[city][people] == 0: msg = city + ":" + people else: msg = city + ":" + people + ":" + str(self.debut[city][people]) + ":" + str(self.fin[city][people]) else: msg = people + ":" + city if msg: self.result.append(str(msg)) def __get_place_handles(self, places): """ This procedure converts a string of place GIDs to a list of handles """ place_handles = [] for place_gid in places.split(): place = self.database.get_place_from_gramps_id(place_gid) if place is not None: #place can be None if option is gid of other fam tree place_handles.append(place.get_handle()) return place_handles
class ListeEclairReport(Report): def __init__(self, database, options_class, user): Report.__init__(self, database, options_class, user) menu = options_class.menu places = menu.get_option_by_name('places').get_value() self.reporttype = menu.get_option_by_name('reporttype').get_value() self.incpriv = menu.get_option_by_name('incpriv').get_value() #self.incliving = menu.get_option_by_name('incliving').get_value() if self.incpriv: self.database = database else: self.database = PrivateProxyDb(database) #self.database = LivingProxyDb(database, LivingProxyDb.MODE_EXCLUDE_ALL) filter_option = menu.get_option_by_name('filter') self.filter = filter_option.get_filter() self.sort = Sort(self.database) if self.filter.get_name() != '': # Use the selected filter to provide a list of place handles plist = self.database.iter_place_handles() self.place_handles = self.filter.apply(self.database, plist) else: # Use the place handles selected without a filter self.place_handles = self.__get_place_handles(places) self.place_handles.sort(key=self.sort.by_place_title_key) def write_report(self): """ The routine the actually creates the report. At this point, the document is opened and ready for writing. """ # Create progress meter bar self.progress = ProgressMeter(_("Liste Eclair"), '') # Write the title line. Set in INDEX marker so that this section will be # identified as a major category if this is included in a Book report. title = _("Liste Eclair") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("Eclair-ReportTitle") self.doc.write_text(title, mark) self.doc.end_paragraph() self.__write_all_places() # Close the progress meter self.progress.close() def __write_all_places(self): """ This procedure writes out each of the selected places. """ place_nbr = 1 self.doc.start_paragraph("Eclair-Report") self.progress.set_pass(_("Generating report"), len(self.place_handles)) self.result = [] for handle in self.place_handles: city = self.__write_place(handle, place_nbr) self.__write_referenced_events(handle, city) place_nbr += 1 # increment progress bar self.progress.step() self.result.sort() for msg in self.result: # AttributeError: 'GtkDocDocument' object has no attribute 'add_text self.doc.write_text("%s\n" % msg) self.doc.end_paragraph() def __write_place(self, handle, place_nbr): """ This procedure writes out the details of a single place """ place = self.database.get_place_from_handle(handle) location = get_main_location(self.database, place) city = location.get(PlaceType.CITY) place_title = _pd.display(self.database, place) if city == '' and place_title: city = place_title return city def __write_referenced_events(self, handle, city): """ This procedure writes out each of the events related to the place """ event_handles = [ event_handle for (object_type, event_handle) in self.database.find_backlink_handles(handle) ] #event_handles.sort(self.sort.by_date) self.debut = defaultdict(lambda: defaultdict(dict)) self.fin = defaultdict(lambda: defaultdict(dict)) for evt_handle in event_handles: event = self.database.get_event_from_handle(evt_handle) if event: date = event.get_date_object() if date: year = int(date.get_year()) else: next() person_list = [] ref_handles = [ x for x in self.database.find_backlink_handles(evt_handle) ] for (ref_type, ref_handle) in ref_handles: if ref_type == 'Person': person_list.append(ref_handle) else: family = self.database.get_family_from_handle(ref_handle) # bug 8584 if family: father = family.get_father_handle() if father: person_list.append(father) mother = family.get_mother_handle() if mother: person_list.append(mother) people = "" person_list = list(set(person_list)) for p_handle in person_list: person = self.database.get_person_from_handle(p_handle) if person: people = person.get_primary_name().get_surname() if not self.debut[city][people]: self.debut[city][people] = year self.fin[city][people] = year if self.debut[city][people] > year: self.debut[city][people] = year if self.fin[city][people] < year: self.fin[city][people] = year event_details = [year, people] keylist = self.debut.keys() #keylist.sort() sorted(list(keylist)) # bug 8437 for city in keylist: for people in sorted(self.debut[city].keys()): if self.reporttype == "ListeEclair": if self.debut[city][people] == 0: msg = city + ":" + people else: msg = city + ":" + people + ":" + str( self.debut[city][people]) + ":" + str( self.fin[city][people]) else: msg = people + ":" + city if msg: self.result.append(str(msg)) def __get_place_handles(self, places): """ This procedure converts a string of place GIDs to a list of handles """ place_handles = [] for place_gid in places.split(): place = self.database.get_place_from_gramps_id(place_gid) if place is not None: #place can be None if option is gid of other fam tree place_handles.append(place.get_handle()) return place_handles
class ledigquote(Report): """ ledigquote Report class """ def __init__(self, database, options, user): """ Create the ledigquote Report object produces the ledigquote report. The arguments are: database - the GRAMPS database instance options - instance of the Options class for this report user - instance of a gen.user.User class This report needs the following parameters (class variables) that come in the options class. places - List of places to report on. # center - Center of report, person or event incpriv - Whether to include private data """ Report.__init__(self, database, options, user) self._user = user menu = options.menu places = menu.get_option_by_name('places').get_value() # self.center = menu.get_option_by_name('center').get_value() self.incpriv = menu.get_option_by_name('incpriv').get_value() self.set_locale(menu.get_option_by_name('trans').get_value()) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) self._nd = self._name_display if self.incpriv: self.database = database else: self.database = PrivateProxyDb(database) filter_option = menu.get_option_by_name('filter') self.filter = filter_option.get_filter() self.sort = Sort(self.database) if self.filter.get_name() != '': # Use the selected filter to provide a list of place handles plist = self.database.iter_place_handles() self.place_handles = self.filter.apply(self.database, plist) else: # Use the place handles selected without a filter self.place_handles = self.__get_place_handles(places) self.place_handles.sort(key=self.sort.by_place_title_key) def write_report(self): """ The routine that actually creates the report. At this point, the document is opened and ready for writing. """ # Write the title line. Set in INDEX marker so that this section will be # identified as a major category if this is included in a Book report. title = self._("Ledigenquote und Verheiratetenanteile ") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("PLC-ReportTitle") self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_paragraph("PLC-Section") self.doc.write_text( "Enthält alle Personen, die in diesem Ort geboren oder getauft wurden" ) self.doc.end_paragraph() self.doc.start_table("LEQUODETTable", "SRC-LEQUODETTable") column_titles = [ _("person"), _("name"), _("ID"), _("m/w"), _("birth"), _("death"), ("marriage"), _("place") ] 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() self.__write_data() self.doc.end_table() def __write_data(self): """ This procedure writes out each of the families related to the place """ i = 0 iw = 0 ifam = 0 p_set = set() pdet_list = [] QUAL_ESTIMATED = 1 gender_dict = {0: "w", 1: "m", 2: "u"} for handle in self.place_handles: # first all events event_handles = [ event_handle for (object_type, event_handle) in self.database.find_backlink_handles(handle, ['Event']) ] if event_handles: self.doc.start_paragraph("PLC-Section") self.doc.write_text( self.database.get_place_from_handle(handle).get_title()) self.doc.end_paragraph() print(len(event_handles)) mi = 0 for evt_handle in event_handles: event = self.database.get_event_from_handle(evt_handle) if (event.get_type().is_baptism() or event.get_type().is_birth()): #Alle Personen mit birth oder Bapt pevt_list = [ ref_handle for (ref_type, ref_handle) in self.database.find_backlink_handles(event.handle) if ref_type == 'Person' ] for pevt in pevt_list: p_found = self.database.get_person_from_handle(pevt) for ev_ref in p_found.event_ref_list: if ev_ref.role.is_primary(): e_det = self.database.get_event_from_handle( ev_ref.ref) if (e_det.get_type().is_baptism() or e_det.get_type().is_birth()): p_set.add(pevt) p_list = list(p_set) for ph in p_set: m_role = "Rolle" person = self.database.get_person_from_handle(ph) person_name = person.get_primary_name().get_surname() person_ID = person.get_gramps_id() gender = gender_dict[person.get_gender()] m_date = "" birth_ref = person.get_birth_ref() b_year = 0 if birth_ref: birth_obj = self.database.get_event_from_handle( birth_ref.ref).get_date_object() if birth_obj.get_quality() is not QUAL_ESTIMATED: b_year = birth_obj.get_year() m_year = 0 for evt_ref in person.get_primary_event_ref_list(): evt = self.database.get_event_from_handle(evt_ref.ref) if evt and evt.type.is_birth_fallback(): birth_obj = evt.get_date_object() m_year = birth_obj.get_year() m_role = "ROLLE " + str(evt_ref.role) m_date = self._get_date(evt.get_date_object()) diff = m_year - b_year death_ref = person.get_death_ref() d_year = 0 if death_ref: death_obj = self.database.get_event_from_handle( death_ref.ref).get_date_object() if death_obj.get_quality() is not QUAL_ESTIMATED: d_year = death_obj.get_year() place_d = place_displayer.display_event(self.database, evt) # b_year = event.get_date_object().to_calendar(cal).get_year() # d_year = event.get_date_object().to_calendar(cal).get_year() #m_year = event.get_date_object().to_calendar(cal).get_year() person_details = [ person, person_name, person_ID, gender, b_year, d_year, m_year, m_role, m_date, diff, place_d ] print(person_details[1], person_details[2], person_details[3], person_details[4], person_details[5], person_details[6]) pdet_list.append(person_details) i = 1 for pn in pdet_list: self.doc.start_row() # self.doc.start_cell("SRC-TableColumn") # self.doc.start_paragraph("SRC-ColumnTitle") # ST = "PN"+ str(pn[0]) # self.doc.write_text(_("%s") % ST) # # self.doc.write_text(_("Hallo0")) # self.doc.end_paragraph() # self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[1]) # self.doc.write_text(_("Hallo1")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[2]) # self.doc.write_text(_("Hallo2")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[3]) # self.doc.write_text(_("Hallo3")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[4]) # self.doc.write_text(_("Hallo4")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[5]) # self.doc.write_text(_("Hallo5")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[6]) # self.doc.write_text(_("Hallo6")) self.doc.end_paragraph() self.doc.end_cell() # self.doc.start_cell("SRC-TableColumn") # self.doc.start_paragraph("SRC-ColumnTitle") # self.doc.write_text(_("%s") % pn[7]) # # self.doc.write_text(_("Hallo7")) # self.doc.end_paragraph() # self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[8]) # self.doc.write_text(_("Hallo8")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[9]) # self.doc.write_text(_("Hallo9")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") # diff= pn[6] - pn[4] self.doc.write_text(_("%s") % pn[10]) # self.doc.write_text(diff) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % i) # self.doc.write_text(i) # self.doc.write_text(_("LNR")) self.doc.end_paragraph() self.doc.end_cell() i += 1 self.doc.end_row() def __format_date(self, date_object): if not date_object: return d = date_object.get_day() m = date_object.get_month() y = date_object.get_year() if (d == 0) and (m == 0): date_f = (" %s" % y) elif (d == 0) and not (m == 0): date_f = (" %s.%s" % (m, y)) else: date_f = (" %s.%s.%s" % (d, m, y)) return date_f def __get_place_handles(self, places): """ This procedure converts a string of place GIDs to a list of handles """ place_handles = [] for place_gid in places.split(): place = self.database.get_place_from_gramps_id(place_gid) if place is not None: place_handles.append(place.get_handle()) return place_handles
class ledigquote(Report): """ ledigquote Report class """ def __init__(self, database, options, user): """ Create the ledigquote Report object produces the ledigquote report. The arguments are: database - the GRAMPS database instance options - instance of the Options class for this report user - instance of a gen.user.User class This report needs the following parameters (class variables) that come in the options class. places - List of places to report on. # center - Center of report, person or event incpriv - Whether to include private data """ Report.__init__(self, database, options, user) self._user = user menu = options.menu places = menu.get_option_by_name('places').get_value() # self.center = menu.get_option_by_name('center').get_value() self.incpriv = menu.get_option_by_name('incpriv').get_value() self.set_locale(menu.get_option_by_name('trans').get_value()) name_format = menu.get_option_by_name("name_format").get_value() if name_format != 0: self._name_display.set_default_format(name_format) self._nd = self._name_display if self.incpriv: self.database = database else: self.database = PrivateProxyDb(database) filter_option = menu.get_option_by_name('filter') self.filter = filter_option.get_filter() self.sort = Sort(self.database) if self.filter.get_name() != '': # Use the selected filter to provide a list of place handles plist = self.database.iter_place_handles() self.place_handles = self.filter.apply(self.database, plist) else: # Use the place handles selected without a filter self.place_handles = self.__get_place_handles(places) self.place_handles.sort(key=self.sort.by_place_title_key) def write_report(self): """ The routine that actually creates the report. At this point, the document is opened and ready for writing. """ # Write the title line. Set in INDEX marker so that this section will be # identified as a major category if this is included in a Book report. title = self._("Ledigenquote und Verheiratetenanteile ") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.start_paragraph("PLC-ReportTitle") self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_paragraph("PLC-Section") self.doc.write_text("Enthält alle Personen, die in diesem Ort geboren oder getauft wurden") self.doc.end_paragraph() self.doc.start_table("LEQUODETTable", "SRC-LEQUODETTable") column_titles = [_("person"), _("name"), _("ID"), _("m/w"), _("birth"), _("death"),("marriage"), _("place")] 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() self.__write_data() self.doc.end_table() def __write_all_places(self): """ This procedure writes out each of the selected places. """ place_nbr = 1 with self._user.progress(_("Ledigenquote"), _("Generating report"), len(self.place_handles)) as step: for handle in self.place_handles: # self.__write_place(handle, place_nbr) self.__write_data(handle) place_nbr += 1 # increment progress bar step() def __format_date(self, date_object): if not date_object: return d=date_object.get_day() m=date_object.get_month() y=date_object.get_year() if (d == 0) and (m == 0): date_f = (" %s" % y) elif (d == 0) and not (m == 0): date_f = (" %s.%s" % (m, y)) else: date_f = (" %s.%s.%s" % (d, m, y)) return date_f def __write_data(self): """ This procedure writes out each of the families related to the place """ i = 0 iw = 0 ifam = 0 pe ={} marr =[] pn_list=[] p_list=[] QUAL_ESTIMATED = 1 with self._user.progress(_("Ledigenquote Report"), _("Generating report"), len(self.place_handles)) as step: for handle in self.place_handles: # first all events event_handles = [event_handle for (object_type, event_handle) in self.database.find_backlink_handles(handle, ['Event'])] # event_handles.sort(key=self.sort.by_date_key) if event_handles: self.doc.start_paragraph("PLC-Section") self.doc.write_text(self.database.get_place_from_handle(handle).get_title()) self.doc.end_paragraph() print(len(event_handles)) mi = 0 for evt_handle in event_handles: event = self.database.get_event_from_handle(evt_handle) date = self._get_date(event.get_date_object()) date_sort = event.get_date_object().get_sort_value() descr = event.get_description() event_type = self._(self._get_type(event.get_type())) event_place = event.place ref_handles = [x for x in self.database.find_backlink_handles(evt_handle)] ######################## # person_list = [ # item[1] for item in # self.dbstate.db.find_backlink_handles(handle,['Person']) ] ######################## # print(mi, evt_handle) ######################### if ( event.get_type().is_baptism() or event.get_type().is_birth() ): pn_list = [ ref_handle for (ref_type, ref_handle) in self.database.find_backlink_handles(event.handle) if ref_type == 'Person' ] person_list = list(set(pn_list)) print("Liste",len(pn_list),len(person_list)) if person_list: for ph in person_list: # print(pn) pn = self.database.get_person_from_handle(ph) person_name = pn.get_primary_name().get_surname() person_ID = pn.get_gramps_id() gender = pn.get_gender() birth_ref = pn.get_birth_ref() b_year = 0 if birth_ref: birth_obj = self.database.get_event_from_handle(birth_ref.ref).get_date_object() if birth_obj.get_quality() is not QUAL_ESTIMATED: b_year = birth_obj.get_year() m_year = 0 ############################## # if not b_year: for evt_ref in pn.get_primary_event_ref_list(): evt = self.database.get_event_from_handle(evt_ref.ref) if evt and evt.type.is_birth_fallback(): birth_obj = evt.get_date_object() m_year = birth_obj.get_year() m_role = "ROLLE "+ str(evt_ref.role) m_date = self._get_date(evt.get_date_object()) diff = m_year - b_year death_ref = pn.get_death_ref() d_year = 0 if death_ref: death_obj = self.database.get_event_from_handle(death_ref.ref).get_date_object() if death_obj.get_quality() is not QUAL_ESTIMATED: d_year = death_obj.get_year() place_d = place_displayer.display_event(self.database, event) # b_year = event.get_date_object().to_calendar(cal).get_year() # d_year = event.get_date_object().to_calendar(cal).get_year() #m_year = event.get_date_object().to_calendar(cal).get_year() person_details = [ pn, person_name, person_ID, gender, b_year, d_year, m_year, m_role, m_date, diff,place_d] print(person_details[1],person_details[2],person_details[3],person_details[4],person_details[5],person_details[6]) p_list.append(person_details) i=1 for pn in p_list: self.doc.start_row() # self.doc.start_cell("SRC-TableColumn") # self.doc.start_paragraph("SRC-ColumnTitle") # ST = "PN"+ str(pn[0]) # self.doc.write_text(_("%s") % ST) # # self.doc.write_text(_("Hallo0")) # self.doc.end_paragraph() # self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[1]) # self.doc.write_text(_("Hallo1")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[2]) # self.doc.write_text(_("Hallo2")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[3]) # self.doc.write_text(_("Hallo3")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[4]) # self.doc.write_text(_("Hallo4")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[5]) # self.doc.write_text(_("Hallo5")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[6]) # self.doc.write_text(_("Hallo6")) self.doc.end_paragraph() self.doc.end_cell() # self.doc.start_cell("SRC-TableColumn") # self.doc.start_paragraph("SRC-ColumnTitle") # self.doc.write_text(_("%s") % pn[7]) # # self.doc.write_text(_("Hallo7")) # self.doc.end_paragraph() # self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[8]) # self.doc.write_text(_("Hallo8")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[9]) # self.doc.write_text(_("Hallo9")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") # diff= pn[6] - pn[4] self.doc.write_text(_("%s") % pn[10]) # self.doc.write_text(diff) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % i) # self.doc.write_text(i) # self.doc.write_text(_("LNR")) self.doc.end_paragraph() self.doc.end_cell() i +=1 self.doc.end_row() def __get_place_handles(self, places): """ This procedure converts a string of place GIDs to a list of handles """ place_handles = [] for place_gid in places.split(): place = self.database.get_place_from_gramps_id(place_gid) if place is not None: place_handles.append(place.get_handle()) return place_handles