def write_parents(self, person): """ write the parents """ family_handle = person.get_main_parents_family_handle() if family_handle: family = self._db.get_family_from_handle(family_handle) mother_handle = family.get_mother_handle() father_handle = family.get_father_handle() if mother_handle: mother = self._db.get_person_from_handle(mother_handle) mother_name = self._nd.display_name(mother.get_primary_name()) mother_mark = utils.get_person_mark(self._db, mother) else: mother_name = "" mother_mark = "" if father_handle: father = self._db.get_person_from_handle(father_handle) father_name = self._nd.display_name(father.get_primary_name()) father_mark = utils.get_person_mark(self._db, father) else: father_name = "" father_mark = "" text = self.__narrator.get_child_string(father_name, mother_name) if text: self.doc.write_text(text) if father_mark: self.doc.write_text("", father_mark) if mother_mark: self.doc.write_text("", mother_mark)
def write_alt_parents(self): """ write any alternate parents """ family_handle_list = self.person.get_parent_family_handle_list() if len(family_handle_list) < 2: return self.doc.start_table("altparents", "IDS-IndTable") self.doc.start_row() self.doc.start_cell("IDS-TableHead", 2) self.write_paragraph(self._('Alternate Parents'), style='IDS-TableTitle') self.doc.end_cell() self.doc.end_row() for family_handle in family_handle_list: if family_handle == self.person.get_main_parents_family_handle(): continue family = self._db.get_family_from_handle(family_handle) # Get the mother and father relationships frel = "" mrel = "" child_handle = self.person.get_handle() child_ref_list = family.get_child_ref_list() for child_ref in child_ref_list: if child_ref.ref == child_handle: frel = str(child_ref.get_father_relation()) mrel = str(child_ref.get_mother_relation()) father_handle = family.get_father_handle() if father_handle: father = self._db.get_person_from_handle(father_handle) fname = self._name_display.display(father) mark = utils.get_person_mark(self._db, father) self.write_p_entry(self._('Father'), fname, frel, mark) else: self.write_p_entry(self._('Father'), '', '') mother_handle = family.get_mother_handle() if mother_handle: mother = self._db.get_person_from_handle(mother_handle) mname = self._name_display.display(mother) mark = utils.get_person_mark(self._db, mother) self.write_p_entry(self._('Mother'), mname, mrel, mark) else: self.write_p_entry(self._('Mother'), '', '') self.doc.end_table() self.doc.start_paragraph("IDS-Normal") self.doc.end_paragraph()
def draw_radial(self, _x_, _y_, start_angle, max_angle, size, generation): segments = 2**generation delta = max_angle / segments end_angle = start_angle text_angle = start_angle - delta / 2.0 graphic_style = self.graphic_style[generation] rad1, rad2 = self.get_radial_radius(size, generation, self.circle) for index in range(segments - 1, 2 * segments - 1): start_angle = end_angle end_angle = start_angle + delta (_xc, _yc) = draw_wedge(self.doc, graphic_style, _x_, _y_, rad2, start_angle, end_angle, self.map[index] or self.draw_empty, rad1) text_angle += delta if self.map[index]: person = self.database.get_person_from_handle(self.map[index]) mark = utils.get_person_mark(self.database, person) if (self.radial == RADIAL_UPRIGHT and (start_angle >= 90) and (start_angle < 270)): self.doc.rotate_text(graphic_style, self.text[index], _xc, _yc, text_angle + 180, mark) else: self.doc.rotate_text(graphic_style, self.text[index], _xc, _yc, text_angle, mark)
def write_children(self, family): """ List children. """ if not family.get_child_ref_list(): return mother_handle = family.get_mother_handle() if mother_handle: mother = self._db.get_person_from_handle(mother_handle) mother_name = self._nd.display(mother) if not mother_name: mother_name = self._("Unknown") else: mother_name = self._("Unknown") father_handle = family.get_father_handle() if father_handle: father = self._db.get_person_from_handle(father_handle) father_name = self._nd.display(father) if not father_name: father_name = self._("Unknown") else: father_name = self._("Unknown") self.doc.start_paragraph("DAR-ChildTitle") self.doc.write_text( self._("Children of %(mother_name)s and %(father_name)s" ) % {'father_name' : father_name, 'mother_name' : mother_name}) self.doc.end_paragraph() cnt = 1 for child_ref in family.get_child_ref_list(): child_handle = child_ref.ref child = self._db.get_person_from_handle(child_handle) child_name = self._nd.display(child) if not child_name: child_name = self._("Unknown") child_mark = utils.get_person_mark(self._db, child) if self.childref and self.prev_gen_handles.get(child_handle): value = int(self.prev_gen_handles.get(child_handle)) child_name += " [%d]" % self._get_s_s(value) self.doc.start_paragraph("DAR-ChildList", utils.roman(cnt).lower() + ".") cnt += 1 self.__narrator.set_subject(child) if child_name: self.doc.write_text("%s. " % child_name, child_mark) self.doc.write_text_citation( self.__narrator.get_born_string() or self.__narrator.get_christened_string() or self.__narrator.get_baptised_string()) self.doc.write_text_citation( self.__narrator.get_died_string() or self.__narrator.get_buried_string()) self.doc.end_paragraph()
def write_person(self, person_handle): """ Write information about the given person. """ person = self.database.get_person_from_handle(person_handle) name = self._name_display.display(person) mark = utils.get_person_mark(self.database, person) birth_date = "" birth = get_birth_or_fallback(self.database, person) if birth: birth_date = self._get_date(birth.get_date_object()) death_date = "" death = get_death_or_fallback(self.database, person) if death: death_date = self._get_date(death.get_date_object()) dates = '' if birth_date or death_date: dates = self._(" (%(birth_date)s - %(death_date)s)" ) % {'birth_date' : birth_date, 'death_date' : death_date} self.doc.start_paragraph('KIN-Normal') self.doc.write_text(name, mark) self.doc.write_text(dates) self.doc.end_paragraph()
def write_person_row(self, person_handle): """ Write a row in the table with information about the given person. """ person = self.database.get_person_from_handle(person_handle) name = self._name_display.display(person) mark = utils.get_person_mark(self.database, person) birth_date = "" birth_ref = person.get_birth_ref() if birth_ref: event = self.database.get_event_from_handle(birth_ref.ref) birth_date = self._get_date(event.get_date_object()) death_date = "" death_ref = person.get_death_ref() if death_ref: event = self.database.get_event_from_handle(death_ref.ref) death_date = self._get_date(event.get_date_object()) dates = '' if birth_date or death_date: dates = self._(" (%(birth_date)s - %(death_date)s)") % { 'birth_date': birth_date, 'death_date': death_date } self.doc.start_row() self.doc.start_cell('EOL-TableCell', 2) self.doc.start_paragraph('EOL-Normal') self.doc.write_text(name, mark) self.doc.write_text(dates) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row()
def print_page(self, month): """ Prints a month as a page """ year = self.year dd = self._locale.date_displayer self.doc.start_paragraph('BIR-Monthstyle') self.doc.write_text(dd.long_months[month].capitalize()) self.doc.end_paragraph() current_date = datetime.date(year, month, 1) current_ord = current_date.toordinal() started_day = {} for i in range(31): thisday = current_date.fromordinal(current_ord) if thisday.month == month: list = self.calendar.get(month, {}).get(thisday.day, []) for p, p_obj in list: mark = utils.get_person_mark(self.database, p_obj) p = p.replace("\n", " ") if thisday not in started_day: self.doc.start_paragraph("BIR-Daystyle") self.doc.write_text(str(thisday.day)) self.doc.end_paragraph() started_day[thisday] = 1 self.doc.start_paragraph("BIR-Datastyle") self.doc.write_text(p, mark) self.doc.end_paragraph() current_ord += 1
def __write_children(self, family): """ List the children for the given family. """ if not family.get_child_ref_list(): return mother_name, father_name = self.__get_mate_names(family) self.doc.start_paragraph("DDR-ChildTitle") self.doc.write_text( self._("Children of %(mother_name)s and %(father_name)s") % { 'father_name': father_name, 'mother_name': mother_name }) self.doc.end_paragraph() cnt = 1 for child_ref in family.get_child_ref_list(): child_handle = child_ref.ref child = self._db.get_person_from_handle(child_handle) child_name = self._name_display.display(child) if not child_name: child_name = self._("Unknown") child_mark = utils.get_person_mark(self._db, child) if self.childref and self.prev_gen_handles.get(child_handle): value = str(self.prev_gen_handles.get(child_handle)) child_name += " [%s]" % value if self.inc_ssign: prefix = " " for family_handle in child.get_family_handle_list(): family = self._db.get_family_from_handle(family_handle) if family.get_child_ref_list(): prefix = "+ " break else: prefix = "" if child_handle in self.dnumber: self.doc.start_paragraph( "DDR-ChildList", prefix + str(self.dnumber[child_handle]) + " " + utils.roman(cnt).lower() + ".") else: self.doc.start_paragraph( "DDR-ChildList", prefix + utils.roman(cnt).lower() + ".") cnt += 1 self.doc.write_text("%s. " % child_name, child_mark) self.__narrator.set_subject(child) self.doc.write_text_citation( self.__narrator.get_born_string() or self.__narrator.get_christened_string() or self.__narrator.get_baptised_string()) self.doc.write_text_citation( self.__narrator.get_died_string() or self.__narrator.get_buried_string()) self.doc.end_paragraph()
def print_person(self, level, person): """ print the person """ display_num = self.numbering.number(level) self.doc.start_paragraph("DR-Level%d" % min(level, 32), display_num) mark = utils.get_person_mark(self.database, person) self.doc.write_text(self._name_display.display(person), mark) self.dump_string(person) self.doc.end_paragraph() return display_num
def write_report(self): """ The short method that runs through each month and creates a page. """ # initialize the dict to fill: self.calendar = {} # get the information, first from holidays: if self.country != 0: self.__get_holidays() # get data from database: self.collect_data() # generate the report: self.doc.start_paragraph('BIR-Title') if self.titletext == _(_TITLE0): title = self._(_TITLE0) + ": " + str(self.year) else: title = str(self.titletext) + ": " + str(self.year) # FIXME those concatenated strings won't work for RTL languages mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() if self.text1.strip() != "": self.doc.start_paragraph('BIR-Text1style') text1 = str(self.text1) if text1 == _(_TITLE1): text1 = self._(_TITLE1) self.doc.write_text(text1) self.doc.end_paragraph() if self.text2.strip() != "": self.doc.start_paragraph('BIR-Text2style') text2 = str(self.text2) if text2 == _(_TITLE2): text2 = self._(_TITLE2) self.doc.write_text(text2) self.doc.end_paragraph() if self.text3.strip() != "": self.doc.start_paragraph('BIR-Text3style') self.doc.write_text(str(self.text3)) self.doc.end_paragraph() if self.relationships: name = self.center_person.get_primary_name() self.doc.start_paragraph('BIR-Text3style') mark = utils.get_person_mark(self.database, self.center_person) # feature request 2356: avoid genitive form self.doc.write_text( self._("Relationships shown are to %s") % self._name_display.display_name(name), mark) self.doc.end_paragraph() with self._user.progress(_('Birthday and Anniversary Report'), _('Formatting months...'), 12) as step: for month in range(1, 13): step() self.print_page(month)
def print_reference(self, level, person, display_num): """ print the reference """ #Person and their family have already been printed so #print reference here if person: mark = utils.get_person_mark(self.database, person) self.doc.start_paragraph("DR-Spouse%d" % min(level, 32)) name = self._name_display.display(person) self.doc.write_text( self._("sp. see %(reference)s: %(spouse)s") % { 'reference': display_num, 'spouse': name }, mark) self.doc.end_paragraph()
def print_spouse(self, level, spouse_handle, family_handle): """ print the spouse """ #Currently print_spouses is the same for all numbering systems. if spouse_handle: spouse = self.database.get_person_from_handle(spouse_handle) mark = utils.get_person_mark(self.database, spouse) self.doc.start_paragraph("DR-Spouse%d" % min(level, 32)) name = self._name_display.display(spouse) self.doc.write_text( self._("sp. %(spouse)s") % {'spouse': name}, mark) self.dump_string(spouse, family_handle) self.doc.end_paragraph() else: self.doc.start_paragraph("DR-Spouse%d" % min(level, 32)) self.doc.write_text( self._("sp. %(spouse)s") % {'spouse': self._('Unknown')}) self.doc.end_paragraph()
def __write_mate(self, person, family): """ Write information about the person's spouse/mate. """ if person.get_gender() == Person.MALE: mate_handle = family.get_mother_handle() else: mate_handle = family.get_father_handle() if mate_handle: mate = self._db.get_person_from_handle(mate_handle) self.doc.start_paragraph("DDR-MoreHeader") name = self._name_display.display(mate) if not name: name = self._("Unknown") mark = utils.get_person_mark(self._db, mate) if family.get_relationship() == FamilyRelType.MARRIED: self.doc.write_text(self._("Spouse: %s") % name, mark) else: self.doc.write_text( self._("Relationship with: %s") % name, mark) if name[-1:] != '.': self.doc.write_text(".") self.doc.write_text_citation(self.endnotes(mate)) self.doc.end_paragraph() if not self.inc_materef: # Don't want to just print reference self.write_person_info(mate) else: # Check to see if we've married a cousin if mate_handle in self.dnumber: self.doc.start_paragraph('DDR-MoreDetails') self.doc.write_text_citation( self._("Ref: %(number)s. %(name)s") % { 'number': self.dnumber[mate_handle], 'name': name }) self.doc.end_paragraph() else: self.dmates[mate_handle] = person.get_handle() self.write_person_info(mate)
def write_marriage(self, person): """ Output marriage sentence. """ is_first = True for family_handle in person.get_family_handle_list(): family = self._db.get_family_from_handle(family_handle) spouse_handle = utils.find_spouse(person, family) if spouse_handle: spouse = self._db.get_person_from_handle(spouse_handle) spouse_mark = utils.get_person_mark(self._db, spouse) else: spouse_mark = None text = self.__narrator.get_married_string(family, is_first, self._name_display) if text: self.doc.write_text_citation(text, spouse_mark) is_first = False
def draw_circular(self, _x_, _y_, start_angle, max_angle, size, generation): segments = 2**generation delta = max_angle / segments end_angle = start_angle text_angle = start_angle - 270 + (delta / 2.0) rad1, rad2 = self.get_circular_radius(size, generation, self.circle) graphic_style = self.graphic_style[generation] for index in range(segments - 1, 2 * segments - 1): start_angle = end_angle end_angle = start_angle + delta (_xc, _yc) = draw_wedge(self.doc, graphic_style, _x_, _y_, rad2, start_angle, end_angle, self.map[index] or self.draw_empty, rad1) if self.map[index]: if (generation == 0) and self.circle == FULL_CIRCLE: _yc = _y_ person = self.database.get_person_from_handle(self.map[index]) mark = utils.get_person_mark(self.database, person) self.doc.rotate_text(graphic_style, self.text[index], _xc, _yc, text_angle, mark) text_angle += delta
def dump_parent(self, title, person_handle): if not person_handle and not self.missing_info: return elif not person_handle: person = Person() else: person = self.db.get_person_from_handle(person_handle) name = self._name_display.display(person) self.doc.start_table(title, 'FGR-ParentTable') self.doc.start_row() self.doc.start_cell('FGR-ParentHead', 3) self.doc.start_paragraph('FGR-ParentName') mark = utils.get_person_mark(self.db, person) # translators: needed for French, ignore otherwise self.doc.write_text( self._("%(str1)s: %(str2)s") % { 'str1': title, 'str2': name }, mark) if self.gids: gid = person.get_gid() if gid: self.doc.write_text(" (%s)" % gid) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() birth_ref = person.get_birth_ref() birth = None ev_name = self._("Birth") if birth_ref: birth = self.db.get_event_from_handle(birth_ref.ref) if birth or self.missing_info: self.dump_parent_event(ev_name, birth) death_ref = person.get_death_ref() death = None ev_name = self._("Death") if death_ref: death = self.db.get_event_from_handle(death_ref.ref) if death or self.missing_info: self.dump_parent_event(ev_name, death) self.dump_parent_parents(person) if self.inc_par_events: for event_ref in person.get_primary_event_ref_list(): if event_ref != birth_ref and event_ref != death_ref: event = self.db.get_event_from_handle(event_ref.ref) event_type = self._get_type(event.get_type()) self.dump_parent_event(self._(event_type), event) if self.inc_par_addr: addrlist = person.get_address_list()[:] for addr in addrlist: location = utils.get_address_str(addr) date = self._get_date(addr.get_date_object()) self.doc.start_row() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(self._("Address")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(date) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContentsEnd") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(location) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() if self.inc_par_notes: for notehandle in person.get_note_list(): note = self.db.get_note_from_handle(notehandle) self.dump_parent_noteline(self._("Note"), note) if self.include_attrs: for attr in person.get_attribute_list(): attr_type = self._get_type(attr.get_type()) self.dump_parent_line(self._(attr_type), attr.get_value()) if self.inc_par_names: for alt_name in person.get_alternate_names(): name_type = self._get_type(alt_name.get_type()) name = self._name_display.display_name(alt_name) self.dump_parent_line(self._(name_type), name) self.doc.end_table()
def write_person(self, key): """ Output birth, death, parentage, marriage and notes information """ def write_more_header(first, name): """ convenience function """ if first: self.doc.start_paragraph('DAR-MoreHeader') self.doc.write_text(self._('More about %(person_name)s:' ) % {'person_name' : name}) self.doc.end_paragraph() return False person_handle = self.map[key] person = self._db.get_person_from_handle(person_handle) plist = person.get_media_list() self.__narrator.set_subject(person) if self.addimages and len(plist) > 0: photo = plist[0] utils.insert_image(self._db, self.doc, photo, self._user) self.doc.start_paragraph("DAR-First-Entry", "%d." % self._get_s_s(key)) name = self._nd.display(person) if not name: name = self._("Unknown") mark = utils.get_person_mark(self._db, person) self.doc.start_bold() self.doc.write_text(name, mark) if name[-1:] == '.': self.doc.write_text_citation("%s " % self.endnotes(person)) elif name: self.doc.write_text_citation("%s. " % self.endnotes(person)) self.doc.end_bold() if self.dupperson: # Check for duplicate record (result of distant cousins marrying) for dkey in sorted(self.map): if dkey >= key: break if self.map[key] == self.map[dkey]: self.doc.write_text( self._("%(name)s is the same person as [%(id_str)s]." ) % {'name' : '', 'id_str' : str(dkey)}) self.doc.end_paragraph() return 1 # Duplicate person if not self.verbose: self.write_parents(person) text = self.__narrator.get_born_string() if text: self.doc.write_text_citation(text) text = self.__narrator.get_baptised_string() if text: self.doc.write_text_citation(text) text = self.__narrator.get_christened_string() if text: self.doc.write_text_citation(text) text = self.__narrator.get_died_string(self.calcageflag) if text: self.doc.write_text_citation(text) text = self.__narrator.get_buried_string() if text: self.doc.write_text_citation(text) if self.verbose: self.write_parents(person) if not key % 2 or key == 1: self.write_marriage(person) self.doc.end_paragraph() if key == 1: self.write_mate(person) notelist = person.get_note_list() if len(notelist) > 0 and self.includenotes: self.doc.start_paragraph("DAR-NoteHeader") # feature request 2356: avoid genitive form self.doc.write_text(self._("Notes for %s") % name) self.doc.end_paragraph() for notehandle in notelist: note = self._db.get_note_from_handle(notehandle) self.doc.write_styled_note( note.get_styledtext(), note.get_format(), "DAR-Entry", contains_html=(note.get_type() == NoteType.HTML_CODE) ) first = True if self.inc_names: for alt_name in person.get_alternate_names(): first = write_more_header(first, name) self.doc.start_paragraph('DAR-MoreDetails') atype = self._get_type(alt_name.get_type()) self.doc.write_text_citation( self._('%(name_kind)s: %(name)s%(endnotes)s' ) % {'name_kind' : self._(atype), 'name' : alt_name.get_regular_name(), 'endnotes' : self.endnotes(alt_name)}) self.doc.end_paragraph() if self.inc_events: birth_ref = person.get_birth_ref() death_ref = person.get_death_ref() for event_ref in person.get_primary_event_ref_list(): if event_ref == birth_ref or event_ref == death_ref: continue first = write_more_header(first, name) self.write_event(event_ref) if self.other_events: for event_ref in person.get_event_ref_list(): role = event_ref.get_role() if role in (EventRoleType.PRIMARY, EventRoleType.FAMILY): continue first = write_more_header(first, name) self.write_event(event_ref) if self.inc_addr: for addr in person.get_address_list(): first = write_more_header(first, name) self.doc.start_paragraph('DAR-MoreDetails') text = utils.get_address_str(addr) self.doc.write_text(self._('Address: ')) if self.fulldate: date = self._get_date(addr.get_date_object()) else: date = addr.get_date_object().get_year() if date: # translators: needed for Arabic, ignore otherwise self.doc.write_text(self._('%s, ') % date) self.doc.write_text(text) self.doc.write_text_citation(self.endnotes(addr)) self.doc.end_paragraph() if self.inc_attrs: attrs = person.get_attribute_list() if attrs: first = write_more_header(first, name) for attr in attrs: self.doc.start_paragraph('DAR-MoreDetails') attr_name = attr.get_type().type2base() # translators: needed for French, ignore otherwise text = self._("%(type)s: %(value)s%(endnotes)s" ) % {'type' : self._(attr_name), 'value' : attr.get_value(), 'endnotes' : self.endnotes(attr)} self.doc.write_text_citation(text) self.doc.end_paragraph() return 0 # Not duplicate person
def add_mark(self, database, person): self.__mark = utils.get_person_mark(database, person)
def collect_data(self): """ This method runs through the data, and collects the relevant dates and text. """ db = self.database people = db.iter_person_handles() with self._user.progress(_('Calendar Report'), _('Applying Filter...'), db.get_number_of_people()) as step: people = self.filter.apply(self.database, people, step) ngettext = self._locale.translation.ngettext # to see "nearby" comments with self._user.progress(_('Calendar Report'), _('Reading database...'), len(people)) as step: for person_handle in people: step() person = db.get_person_from_handle(person_handle) mark = utils.get_person_mark(db, person) birth_ref = person.get_birth_ref() birth_date = None if birth_ref: birth_event = db.get_event_from_handle(birth_ref.ref) birth_date = birth_event.get_date_object() if (self.birthdays and birth_date is not None and birth_date.is_valid()): birth_date = gregorian(birth_date) year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() prob_alive_date = Date(self.year, month, day) nyears = self.year - year # add some things to handle maiden name: father_lastname = None # husband, actually if self.maiden_name in ['spouse_first', 'spouse_last' ]: # get husband's last name: if person.get_gender() == Person.FEMALE: family_list = person.get_family_handle_list() if family_list: if self.maiden_name == 'spouse_first': fhandle = family_list[0] else: fhandle = family_list[-1] fam = db.get_family_from_handle(fhandle) father_handle = fam.get_father_handle() mother_handle = fam.get_mother_handle() if mother_handle == person_handle: if father_handle: father = db.get_person_from_handle( father_handle) if father: father_lastname = father.get_primary_name( ).get_surname() short_name = self.get_name(person, father_lastname) alive = probably_alive(person, db, prob_alive_date) if not self.alive or alive: if nyears == 0: text = self._('%(person)s, birth') % { 'person': short_name } else: # translators: leave all/any {...} untranslated text = ngettext('{person}, {age}', '{person}, {age}', nyears).format(person=short_name, age=nyears) self.add_day_item(text, month, day, marks=[mark]) if self.anniversaries: family_list = person.get_family_handle_list() for fhandle in family_list: fam = db.get_family_from_handle(fhandle) father_handle = fam.get_father_handle() mother_handle = fam.get_mother_handle() if father_handle == person.get_handle(): spouse_handle = mother_handle else: continue # with next person if the father is not "person" # this will keep from duplicating the anniversary if spouse_handle: spouse = db.get_person_from_handle(spouse_handle) if spouse: s_m = utils.get_person_mark(db, spouse) spouse_name = self.get_name(spouse) short_name = self.get_name(person) # TEMP: this will handle ordered events # Gramps 3.0 will have a new mechanism for start/stop events are_married = None for event_ref in fam.get_event_ref_list(): event = db.get_event_from_handle( event_ref.ref) et = EventType rt = EventRoleType if event.type in [et.MARRIAGE, et.MARR_ALT] and \ (event_ref.get_role() == rt.FAMILY or event_ref.get_role() == rt.PRIMARY ): are_married = event elif event.type in [et.DIVORCE, et.ANNULMENT, et.DIV_FILING] and \ (event_ref.get_role() == rt.FAMILY or event_ref.get_role() == rt.PRIMARY ): are_married = None if are_married is not None: for event_ref in fam.get_event_ref_list(): event = db.get_event_from_handle( event_ref.ref) event_obj = event.get_date_object() if event_obj.is_valid(): event_obj = gregorian(event_obj) year = event_obj.get_year() month = event_obj.get_month() day = event_obj.get_day() prob_alive_date = Date( self.year, month, day) nyears = self.year - year if nyears == 0: text = self._( '%(spouse)s and\n %(person)s, wedding' ) % { 'spouse': spouse_name, 'person': short_name, } else: # translators: leave all/any {...} untranslated text = ngettext( "{spouse} and\n {person}, {nyears}", "{spouse} and\n {person}, {nyears}", nyears).format( spouse=spouse_name, person=short_name, nyears=nyears) alive1 = probably_alive( person, self.database, prob_alive_date) alive2 = probably_alive( spouse, self.database, prob_alive_date) if ((self.alive and alive1 and alive2) or not self.alive): self.add_day_item( text, month, day, marks=[mark, s_m])
def write_person(self, count): """ write a person """ if count != 0: self.doc.page_break() self.bibli = Bibliography( Bibliography.MODE_DATE|Bibliography.MODE_PAGE) title1 = self._("Complete Individual Report") text2 = self._name_display.display(self.person) mark1 = IndexMark(title1, INDEX_TYPE_TOC, 1) mark2 = IndexMark(text2, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("IDS-Title") self.doc.write_text(title1, mark1) self.doc.end_paragraph() self.doc.start_paragraph("IDS-Title") self.doc.write_text(text2, mark2) self.doc.end_paragraph() self.doc.start_paragraph("IDS-Normal") self.doc.end_paragraph() name = self.person.get_primary_name() text = self.get_name(self.person) mark = utils.get_person_mark(self._db, self.person) endnotes = self._cite_endnote(self.person) endnotes = self._cite_endnote(name, prior=endnotes) family_handle = self.person.get_main_parents_family_handle() if family_handle: family = self._db.get_family_from_handle(family_handle) father_inst_id = family.get_father_handle() if father_inst_id: father_inst = self._db.get_person_from_handle( father_inst_id) father = self.get_name(father_inst) fmark = utils.get_person_mark(self._db, father_inst) else: father = "" fmark = None mother_inst_id = family.get_mother_handle() if mother_inst_id: mother_inst = self._db.get_person_from_handle(mother_inst_id) mother = self.get_name(mother_inst) mmark = utils.get_person_mark(self._db, mother_inst) else: mother = "" mmark = None else: father = "" fmark = None mother = "" mmark = None media_list = self.person.get_media_list() p_style = 'IDS-PersonTable2' self.mime0 = None if self.use_images and len(media_list) > 0: media0 = media_list[0] media_handle = media0.get_reference_handle() media = self._db.get_media_from_handle(media_handle) self.mime0 = media.get_mime_type() if self.mime0 and self.mime0.startswith("image"): image_filename = media_path_full(self._db, media.get_path()) if os.path.exists(image_filename): p_style = 'IDS-PersonTable' # this is tested for, also else: self._user.warn(_("Could not add photo to page"), # translators: for French, else ignore _("%(str1)s: %(str2)s" ) % {'str1' : image_filename, 'str2' : _('File does not exist')}) self.doc.start_table('person', p_style) self.doc.start_row() # translators: needed for French, ignore otherwise ignore = self._("%s:") self.doc.start_cell('IDS-NormalCell') self.write_paragraph(self._("%s:") % self._("Name")) self.write_paragraph(self._("%s:") % self._("Gender")) self.write_paragraph(self._("%s:") % self._("Father")) self.write_paragraph(self._("%s:") % self._("Mother")) self.doc.end_cell() self.doc.start_cell('IDS-NormalCell') self.write_paragraph(text, endnotes, mark) if self.person.get_gender() == Person.MALE: self.write_paragraph(self._("Male")) elif self.person.get_gender() == Person.FEMALE: self.write_paragraph(self._("Female")) else: self.write_paragraph(self._("Unknown")) self.write_paragraph(father, mark=fmark) self.write_paragraph(mother, mark=mmark) self.doc.end_cell() if p_style == 'IDS-PersonTable': self.doc.start_cell('IDS-NormalCell') self.doc.add_media(image_filename, "right", 4.0, 4.0, crop=media0.get_rectangle()) endnotes = self._cite_endnote(media0) attr_list = media0.get_attribute_list() if len(attr_list) == 0 or not self.use_attrs: text = _('(image)') else: for attr in attr_list: attr_type = attr.get_type().type2base() # translators: needed for French, ignore otherwise text = self._("%(str1)s: %(str2)s" ) % {'str1' : self._(attr_type), 'str2' : attr.get_value()} endnotes = self._cite_endnote(attr, prior=endnotes) self.write_paragraph("(%s)" % text, endnotes=endnotes, style='IDS-ImageNote') endnotes = '' if endnotes and len(attr_list) == 0: self.write_paragraph(text, endnotes=endnotes, style='IDS-ImageNote') self.doc.end_cell() self.doc.end_row() self.doc.end_table() self.doc.start_paragraph("IDS-Normal") self.doc.end_paragraph() self.write_alt_names() self.write_events() self.write_alt_parents() self.write_families() self.write_addresses() self.write_associations() self.write_attributes() self.write_LDS_ordinances() self.write_tags() self.write_images() self.write_note() if self.use_srcs: if self.use_pagebreak and self.bibli.get_citation_count(): self.doc.page_break() Endnotes.write_endnotes(self.bibli, self._db, self.doc, printnotes=self.use_src_notes, elocale=self._locale)
def write_families(self): """ write any families the person has """ family_handle_list = self.person.get_family_handle_list() if not len(family_handle_list): return self.doc.start_table("three", "IDS-IndTable") self.doc.start_row() self.doc.start_cell("IDS-TableHead", 2) self.write_paragraph(self._('Families'), style='IDS-TableTitle') self.doc.end_cell() self.doc.end_row() self.doc.end_table() for family_handle in family_handle_list: self.doc.start_table("three", "IDS-IndTable") family = self._db.get_family_from_handle(family_handle) self.family_notes_list += family.get_note_list() if self.person.get_handle() == family.get_father_handle(): spouse_id = family.get_mother_handle() else: spouse_id = family.get_father_handle() self.doc.start_row() self.doc.start_cell("IDS-NormalCell", 2) if spouse_id: spouse = self._db.get_person_from_handle(spouse_id) text = self.get_name(spouse) mark = utils.get_person_mark(self._db, spouse) else: spouse = None text = self._("unknown") mark = None endnotes = self._cite_endnote(family) self.write_paragraph(text, endnotes=endnotes, mark=mark, style='IDS-Spouse') self.doc.end_cell() self.doc.end_row() event_ref_list = family.get_event_ref_list() for event_ref, event in self.get_event_list(event_ref_list): self.write_fact(event_ref, event) child_ref_list = family.get_child_ref_list() if len(child_ref_list): self.doc.start_row() self.write_cell(self._("Children")) self.doc.start_cell("IDS-ListCell") for child_ref in child_ref_list: child = self._db.get_person_from_handle(child_ref.ref) name = self.get_name(child) mark = utils.get_person_mark(self._db, child) endnotes = self._cite_endnote(child_ref) self.write_paragraph(name, endnotes=endnotes, mark=mark) self.doc.end_cell() self.doc.end_row() attr_list = family.get_attribute_list() if len(attr_list) and self.use_attrs: self.doc.start_row() self.write_cell(self._("Attributes")) self.doc.start_cell("IDS-ListCell") self.do_attributes(attr_list) self.doc.end_cell() self.doc.end_row() self.doc.end_table() ord_list = family.get_lds_ord_list() if len(ord_list): self.doc.start_table("ordinances2", "IDS-OrdinanceTable2") self.doc.start_row() self.write_cell(self._('LDS Ordinance')) self.write_cell(self._('Type'), style='IDS-Section') self.write_cell(self._('Date'), style='IDS-Section') self.write_cell(self._('Status'), style='IDS-Section') self.write_cell(self._('Temple'), style='IDS-Section') self.write_cell(self._('Place'), style='IDS-Section') self.doc.end_row() for lds_ord in ord_list: otype = self._(lds_ord.type2str()) date = self._get_date(lds_ord.get_date_object()) status = self._(lds_ord.status2str()) temple = TEMPLES.name(lds_ord.get_temple()) place_name = '' place_endnote = '' place_handle = lds_ord.get_place_handle() if place_handle: place = self._db.get_place_from_handle(place_handle) place_name = _pd.display_event(self._db, lds_ord) place_endnote = self._cite_endnote(place) endnotes = self._cite_endnote(lds_ord, prior=place_endnote) self.doc.start_row() self.write_cell('') self.write_cell(otype, endnotes) self.write_cell(date) self.write_cell(status) self.write_cell(temple) self.write_cell(place_name) self.doc.end_row() self.doc.end_table() self.doc.start_paragraph('IDS-Normal') self.doc.end_paragraph()
def write_mate(self, person): """Output birth, death, parentage, marriage and notes information """ ind = None has_info = False for family_handle in person.get_family_handle_list(): family = self._db.get_family_from_handle(family_handle) ind_handle = None if person.get_gender() == Person.MALE: ind_handle = family.get_mother_handle() else: ind_handle = family.get_father_handle() if ind_handle: ind = self._db.get_person_from_handle(ind_handle) for event_ref in ind.get_primary_event_ref_list(): event = self._db.get_event_from_handle(event_ref.ref) if event: etype = event.get_type() if (etype == EventType.BAPTISM or etype == EventType.BURIAL or etype == EventType.BIRTH or etype == EventType.DEATH): has_info = True break if not has_info: family_handle = ind.get_main_parents_family_handle() if family_handle: fam = self._db.get_family_from_handle(family_handle) if fam.get_mother_handle() or fam.get_father_handle(): has_info = True break if has_info: self.doc.start_paragraph("DAR-MoreHeader") plist = ind.get_media_list() if self.addimages and len(plist) > 0: photo = plist[0] utils.insert_image(self._db, self.doc, photo, self._user) name = self._nd.display(ind) if not name: name = self._("Unknown") mark = utils.get_person_mark(self._db, ind) if family.get_relationship() == FamilyRelType.MARRIED: self.doc.write_text(self._("Spouse: %s" ) % name, mark) else: self.doc.write_text(self._("Relationship with: %s" ) % name, mark) if name[-1:] != '.': self.doc.write_text(".") self.doc.write_text_citation(self.endnotes(ind)) self.doc.end_paragraph() self.doc.start_paragraph("DAR-Entry") self.__narrator.set_subject(ind) text = self.__narrator.get_born_string() if text: self.doc.write_text_citation(text) text = self.__narrator.get_baptised_string() if text: self.doc.write_text_citation(text) text = self.__narrator.get_christened_string() if text: self.doc.write_text_citation(text) text = self.__narrator.get_died_string(self.calcageflag) if text: self.doc.write_text_citation(text) text = self.__narrator.get_buried_string() if text: self.doc.write_text_citation(text) self.write_parents(ind) self.doc.end_paragraph()
def write_families(self): """ write the families associated with the tag """ flist = self.database.iter_family_handles() filter_class = GenericFilterFactory('Family') a_filter = filter_class() a_filter.add_rule(rules.family.HasTag([self.tag])) fam_list = a_filter.apply(self.database, flist) if not fam_list: return self.doc.start_paragraph("TR-Heading") header = self._("Families") mark = IndexMark(header, INDEX_TYPE_TOC, 2) self.doc.write_text(header, mark) self.doc.end_paragraph() self.doc.start_table('FamilyTable', '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._("Father")) 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._("Mother")) 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._("Relationship")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for family_handle in fam_list: family = self.database.get_family_from_handle(family_handle) self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(family.get_gid()) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') father_handle = family.get_father_handle() if father_handle: father = self.database.get_person_from_handle(father_handle) mark = utils.get_person_mark(self.database, father) self.doc.write_text(self._name_display.display(father), mark) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') mother_handle = family.get_mother_handle() if mother_handle: mother = self.database.get_person_from_handle(mother_handle) mark = utils.get_person_mark(self.database, mother) self.doc.write_text(self._name_display.display(mother), mark) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') relation = family.get_relationship() self.doc.write_text(str(relation)) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def generate_timeline(self, low, high): """ generate the timeline """ st_size = self.name_size() style_sheet = self.doc.get_style_sheet() font = style_sheet.get_paragraph_style('TLG-Name').get_font() incr = utils.pt2cm(font.get_size()) pad = incr * 0.75 _x1, _x2, _y1, _y2 = (0, 0, 0, 0) start = st_size + 0.5 stop = self.doc.get_usable_width() - 0.5 size = stop - start self.header = 2.6 # Sort the people as requested with self._user.progress(_('Timeline'), _('Sorting dates...'), 0) as step: self.plist.sort(key=self.sort_func) self.doc.start_page() self.build_grid(low, high, start, stop, True) index = 1 current = 1 length = len(self.plist) with self._user.progress(_('Timeline'), _('Calculating timeline...'), length) as step: for p_id in self.plist: person = self.database.get_person_from_handle(p_id) birth = get_birth_or_fallback(self.database, person) if birth: bth = birth.get_date_object() bth = bth.to_calendar(self.calendar).get_year() else: bth = None death = get_death_or_fallback(self.database, person) if death: dth = death.get_date_object() dth = dth.to_calendar(self.calendar).get_year() else: dth = None dname = self._name_display.display(person) mark = utils.get_person_mark(self.database, person) self.doc.draw_text('TLG-text', dname, incr + pad, self.header + (incr + pad) * index, mark) _y1 = self.header + (pad + incr) * index _y2 = self.header + ((pad + incr) * index) + incr _y3 = (_y1 + _y2) / 2.0 w05 = 0.05 if bth: start_offset = ((float(bth - low) / float(high - low)) * size) _x1 = start + start_offset path = [(_x1, _y1), (_x1 + w05, _y3), (_x1, _y2), (_x1 - w05, _y3)] self.doc.draw_path('TLG-line', path) if dth: start_offset = ((float(dth - low) / float(high - low)) * size) _x1 = start + start_offset path = [(_x1, _y1), (_x1 + w05, _y3), (_x1, _y2), (_x1 - w05, _y3)] self.doc.draw_path('TLG-solid', path) if bth and dth: start_offset = ( (float(bth - low) / float(high - low)) * size) + w05 stop_offset = ( (float(dth - low) / float(high - low)) * size) - w05 _x1 = start + start_offset _x2 = start + stop_offset self.doc.draw_line('open', _x1, _y3, _x2, _y3) if (_y2 + incr) >= self.doc.get_usable_height(): if current != length: self.doc.end_page() self.doc.start_page() self.build_grid(low, high, start, stop) index = 1 _x1, _x2, _y1, _y2 = (0, 0, 0, 0) else: index += 1 current += 1 step() self.doc.end_page()
def dump_parent_parents(self, person): family_handle = person.get_main_parents_family_handle() father_name = "" mother_name = "" if family_handle: family = self.db.get_family_from_handle(family_handle) father_handle = family.get_father_handle() if father_handle: father = self.db.get_person_from_handle(father_handle) father_name = self._name_display.display(father) if self.gids: gid = father.get_gid() if gid: father_name += " (%s)" % gid if self.inc_rel_dates: birth_ref = father.get_birth_ref() birth = " " if birth_ref: event = self.db.get_event_from_handle(birth_ref.ref) birth = self._get_date(event.get_date_object()) death_ref = father.get_death_ref() death = " " if death_ref: event = self.db.get_event_from_handle(death_ref.ref) death = self._get_date(event.get_date_object()) if birth_ref or death_ref: father_name += " (%s - %s)" % (birth, death) mother_handle = family.get_mother_handle() if mother_handle: mother = self.db.get_person_from_handle(mother_handle) mother_name = self._name_display.display(mother) if self.gids: gid = mother.get_gid() if gid: mother_name += " (%s)" % gid if self.inc_rel_dates: birth_ref = mother.get_birth_ref() birth = " " if birth_ref: event = self.db.get_event_from_handle(birth_ref.ref) birth = self._get_date(event.get_date_object()) death_ref = mother.get_death_ref() death = " " if death_ref: event = self.db.get_event_from_handle(death_ref.ref) death = self._get_date(event.get_date_object()) if birth_ref or death_ref: mother_name += " (%s - %s)" % (birth, death) if father_name != "": self.doc.start_row() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(self._("Father")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContentsEnd", 2) self.doc.start_paragraph('FGR-Normal') mark = utils.get_person_mark(self.db, father) self.doc.write_text(father_name, mark) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() elif self.missing_info: self.dump_parent_line(self._("Father"), "") if mother_name != "": self.doc.start_row() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(self._("Mother")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContentsEnd", 2) self.doc.start_paragraph('FGR-Normal') mark = utils.get_person_mark(self.db, mother) self.doc.write_text(mother_name, mark) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() elif self.missing_info: self.dump_parent_line(self._("Mother"), "")
def write_report(self): """ Build the actual report. """ records = find_records(self.database, self.filter, self.top_size, self.callname, trans_text=self._, name_format=self._nf, living_mode=self._lv) self.doc.start_paragraph('REC-Title') title = self._("Records") mark = IndexMark(title, INDEX_TYPE_TOC, 1) self.doc.write_text(title, mark) self.doc.end_paragraph() self.doc.start_paragraph('REC-Subtitle') filter_name = self.filter.get_name(self._locale) self.doc.write_text("(%s)" % filter_name) self.doc.end_paragraph() if self._lv != LivingProxyDb.MODE_INCLUDE_ALL: self.doc.start_paragraph('REC-Subtitle') self.doc.write_text(self.living_desc) self.doc.end_paragraph() for (text, varname, top) in records: if not self.include[varname]: continue self.doc.start_paragraph('REC-Heading') self.doc.write_text(self._(text)) self.doc.end_paragraph() last_value = None rank = 0 for (number, (sort, value, name, handletype, handle)) in enumerate(top): mark = None if handletype == 'Person': person = self.database.get_person_from_handle(handle) mark = utils.get_person_mark(self.database, person) elif handletype == 'Family': family = self.database.get_family_from_handle(handle) # librecords.py checks that the family has both # a father and a mother and also that each one is # in the filter if any filter was used, so we don't # have to do any similar checking here, it's been done f_handle = family.get_father_handle() dad = self.database.get_person_from_handle(f_handle) f_mark = utils.get_person_mark(self.database, dad) m_handle = family.get_mother_handle() mom = self.database.get_person_from_handle(m_handle) m_mark = utils.get_person_mark(self.database, mom) else: raise ReportError( _("Option '%(opt_name)s' is present " "in %(file)s\n but is not known to " "the module. Ignoring...") % { 'opt_name': handletype, 'file': 'libnarrate.py' }) # since the error is very unlikely I reused the string if value != last_value: last_value = value rank = number self.doc.start_paragraph('REC-Normal') self.doc.write_text( self._("%(number)s. ") % {'number': rank + 1}) self.doc.write_markup(str(name), name.get_tags(), mark) if handletype == 'Family': self.doc.write_text('', f_mark) self.doc.write_text('', m_mark) if isinstance(value, Span): tvalue = value.get_repr(dlocale=self._locale) else: tvalue = value self.doc.write_text(" (%s)" % tvalue) self.doc.end_paragraph() self.doc.start_paragraph('REC-Footer') self.doc.write_text(self.footer) self.doc.end_paragraph()
def dump_child(self, index, person_handle): person = self.db.get_person_from_handle(person_handle) families = len(person.get_family_handle_list()) birth_ref = person.get_birth_ref() if birth_ref: birth = self.db.get_event_from_handle(birth_ref.ref) else: birth = None death_ref = person.get_death_ref() if death_ref: death = self.db.get_event_from_handle(death_ref.ref) else: death = None spouse_count = 0 if self.inc_chi_mar: for family_handle in person.get_family_handle_list(): family = self.db.get_family_from_handle(family_handle) spouse_id = None if person_handle == family.get_father_handle(): spouse_id = family.get_mother_handle() else: spouse_id = family.get_father_handle() if spouse_id: spouse_count += 1 self.doc.start_row() if (spouse_count != 0 or self.missing_info or death is not None or birth is not None): self.doc.start_cell('FGR-TextChild1') else: self.doc.start_cell('FGR-TextChild2') self.doc.start_paragraph('FGR-ChildText') index_str = ("%d" % index) if person.get_gender() == Person.MALE: self.doc.write_text(index_str + self._("acronym for male|M")) elif person.get_gender() == Person.FEMALE: self.doc.write_text(index_str + self._("acronym for female|F")) else: self.doc.write_text(self._("acronym for unknown|%dU") % index) self.doc.end_paragraph() self.doc.end_cell() name = self._name_display.display(person) mark = utils.get_person_mark(self.db, person) self.doc.start_cell('FGR-ChildName', 3) self.doc.start_paragraph('FGR-ChildText') self.doc.write_text(name, mark) if self.gids: self.doc.write_text(" (%s)" % person.get_gid()) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() if self.missing_info or birth is not None: if spouse_count != 0 or self.missing_info or death is not None: self.dump_child_event('FGR-TextChild1', self._('Birth'), birth) else: self.dump_child_event('FGR-TextChild2', self._('Birth'), birth) if self.missing_info or death is not None: if spouse_count == 0 or not self.inc_chi_mar: self.dump_child_event('FGR-TextChild2', self._('Death'), death) else: self.dump_child_event('FGR-TextChild1', self._('Death'), death) if self.inc_chi_mar: index = 0 for family_handle in person.get_family_handle_list(): mrg = None index += 1 family = self.db.get_family_from_handle(family_handle) for event_ref in family.get_event_ref_list(): if event_ref: event = self.db.get_event_from_handle(event_ref.ref) if event.type == EventType.MARRIAGE: mrg = event break spouse_id = None if person_handle == family.get_father_handle(): spouse_id = family.get_mother_handle() else: spouse_id = family.get_father_handle() if spouse_id: self.doc.start_row() if mrg or index != families: self.doc.start_cell('FGR-TextChild1') else: self.doc.start_cell('FGR-TextChild2') self.doc.start_paragraph('FGR-Normal') self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('FGR-TextContents') self.doc.start_paragraph('FGR-Normal') self.doc.write_text(self._("Spouse")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('FGR-TextContentsEnd', 2) self.doc.start_paragraph('FGR-Normal') spouse = self.db.get_person_from_handle(spouse_id) spouse_name = self._name_display.display(spouse) if self.gids: gid = spouse.get_gid() if gid: spouse_name += " (%s)" % gid if self.inc_rel_dates: birth = " " birth_ref = spouse.get_birth_ref() if birth_ref: event = self.db.get_event_from_handle( birth_ref.ref) birth = self._get_date(event.get_date_object()) death = " " death_ref = spouse.get_death_ref() if death_ref: event = self.db.get_event_from_handle( death_ref.ref) death = self._get_date(event.get_date_object()) if birth_ref or death_ref: spouse_name += " (%s - %s)" % (birth, death) if self.gids: fid = family.get_gid() if fid: spouse_name += " (%s)" % fid mark = utils.get_person_mark(self.db, spouse) self.doc.write_text(spouse_name, mark) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() if mrg: ev_name = self._("Marriage") if index == families: self.dump_child_event('FGR-TextChild2', ev_name, mrg) else: self.dump_child_event('FGR-TextChild1', ev_name, mrg)
def write_people(self): """ write the people associated with the tag """ plist = self.database.iter_person_handles() filter_class = GenericFilterFactory('Person') a_filter = filter_class() a_filter.add_rule(rules.person.HasTag([self.tag])) ind_list = a_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_gid()) self.doc.end_paragraph() self.doc.end_cell() name = self._name_display.display(person) mark = utils.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(self._get_date(event.get_date_object())) 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(self._get_date(event.get_date_object())) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def write_person(self, key): """Output birth, death, parentage, marriage and notes information """ person_handle = self.map[key] person = self._db.get_person_from_handle(person_handle) val = self.dnumber[person_handle] if val in self.numbers_printed: return else: self.numbers_printed.append(val) self.doc.start_paragraph("DDR-First-Entry", "%s." % val) name = self._name_display.display(person) if not name: name = self._("Unknown") mark = utils.get_person_mark(self._db, person) self.doc.start_bold() self.doc.write_text(name, mark) if name[-1:] == '.': self.doc.write_text_citation("%s " % self.endnotes(person)) elif name: self.doc.write_text_citation("%s. " % self.endnotes(person)) self.doc.end_bold() if self.inc_paths: self.write_path(person) if self.dubperson: # Check for duplicate record (result of distant cousins marrying) for dkey in sorted(self.map): if dkey >= key: break if self.map[key] == self.map[dkey]: self.doc.write_text( self._("%(name)s is the same person as [%(id_str)s].") % { 'name': '', 'id_str': self.dnumber[self.map[dkey]] }) self.doc.end_paragraph() return self.doc.end_paragraph() self.write_person_info(person) if (self.inc_mates or self.listchildren or self.inc_notes or self.inc_events or self.inc_attrs): for family_handle in person.get_family_handle_list(): family = self._db.get_family_from_handle(family_handle) if self.inc_mates: self.__write_mate(person, family) if self.listchildren: self.__write_children(family) if self.inc_notes: self.__write_family_notes(family) first = True if self.inc_events: first = self.__write_family_events(family) if self.inc_attrs: self.__write_family_attrs(family, first)