Exemplo n.º 1
0
 def __write_parents(self, person):
     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._name_display.display_name(
                                                 mother.get_primary_name())
             mother_mark = ReportUtils.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._name_display.display_name(
                                                 father.get_primary_name())
             father_mark = ReportUtils.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)
Exemplo n.º 2
0
    def _write_family(self, family_handle):
        """
        Generate a table row for this family record
        """
        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_gramps_id())
        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 = ReportUtils.get_person_mark(self.database, father)
            self.doc.write_text(name_displayer.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 = ReportUtils.get_person_mark(self.database, mother)
            self.doc.write_text(name_displayer.display(mother), mark)
        self.doc.end_paragraph()
        self.doc.end_cell()

        # see if we can find a relationship event to include
        relationship_date = _PLACEHOLDER
        for evt_ref in family.get_event_ref_list():
            evt_handle = evt_ref.get_reference_handle()
            evt = self.database.get_event_from_handle(evt_handle)
            # FIXME: where are the event types defined in Gramps,
            # and are these the only important ones?
            # print repr(evt.get_type().string)
            if evt.get_type().string in ["Marriage", "Civil Union"]:
                relationship_date = gramps.gen.datehandler.get_date(evt)
        rel_msg = _("%(relationship_type)s on %(relationship_date)s") % {
            "relationship_type": family.get_relationship(),
            "relationship_date": relationship_date,
        }

        self.doc.start_cell("TR-TableCell")
        self.doc.start_paragraph("TR-Normal")
        self.doc.write_text(rel_msg)
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.end_row()
Exemplo n.º 3
0
    def write_alt_parents(self):

        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 = ReportUtils.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 = ReportUtils.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()
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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 = ReportUtils.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 = 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()
Exemplo n.º 6
0
    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 = " (%(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()
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
    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 = ReportUtils.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]) +
                    " " + ReportUtils.roman(cnt).lower() + ".")
            else:
                self.doc.start_paragraph(
                    "DDR-ChildList",
                    prefix + ReportUtils.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()
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
    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 = " (%(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()
Exemplo n.º 13
0
    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._name_display.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._name_display.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._name_display.display(child)
            if not child_name:
                child_name = self._("Unknown")
            child_mark = ReportUtils.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",
                                     ReportUtils.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()
Exemplo n.º 14
0
    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()
Exemplo n.º 15
0
    def __dump_person(self, person, short, ref):
        """
        Output all data of a person.

        @param person: Person object to output.
        @param short: If True, print only name and birth event.
        @param ref: Reference through which this person is linked into the
            Family Sheet. Can be a family object (for the spouses) or a
            child_ref object (for the children). Source references and notes
            for this reference object will also be output.
        """

        name = person.get_primary_name()
        name_text = _Name_get_styled(name, self.callname, self.placeholder)

        self.doc.start_paragraph("FSR-Name")
        mark = utils.get_person_mark(self.database, person)
        self.doc.write_text("", mark)
        self.doc.write_markup(str(name_text), name_text.get_tags())
        self.__write_sources(name)
        self.__write_notes(name)
        self.__write_sources(person)
        self.__write_notes(person)
        if ref:
            self.__write_sources(ref)
            self.__write_notes(ref)
        self.doc.end_paragraph()

        if short:
            event_ref = person.get_birth_ref()
            if event_ref:
                self.__dump_event_ref(event_ref)
        else:
            for alt_name in person.get_alternate_names():
                name_type = str(alt_name.get_type())
                name = _Name_get_styled(alt_name, self.callname, self.placeholder)
                self.__dump_line(name_type, name, alt_name)

            self.__dump_attributes(person)

            # Each person should have a birth event. If no birth event is
            # there, print the placeholders for it nevertheless.
            if not person.get_birth_ref():
                self.__dump_event(empty_birth, None)

            for event_ref in person.get_primary_event_ref_list():
                self.__dump_event_ref(event_ref)

            for addr in person.get_address_list():
                location = utils.get_address_str(addr)
                date = gramps.gen.datehandler.get_date(addr)

                self.doc.start_paragraph("FSR-Normal")
                if date:
                    self.doc.write_text(_("Address (%(date)s): %(location)s") % {"date": date, "location": location})
                else:
                    self.doc.write_text(_("Address: %(location)s") % {"location": location})
                self.__write_sources(addr)
                self.__write_notes(addr)
                self.doc.end_paragraph()
Exemplo n.º 16
0
 def print_person_summary(self, level, person):
     display_num = "%d." % level
     self.doc.start_paragraph("PE-Level%d" % min(level, 32))
     mark = ReportUtils.get_person_mark(self.database, person)
     self.doc.write_text(self._name_display.display(person), mark)
     self.doc.write_text(self.format_person_birth_and_death(person))
     self.doc.end_paragraph()
     return display_num
Exemplo n.º 17
0
 def print_person(self, level, person):
     display_num = self.numbering.number(level)
     self.doc.start_paragraph("DR-Level%d" % min(level, 32), display_num)
     mark = ReportUtils.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
Exemplo n.º 18
0
 def print_person_summary(self, level, person):
     display_num = "%d." % level
     self.doc.start_paragraph("PE-Level%d" % min(level, 32))
     mark = ReportUtils.get_person_mark(self.database, person)
     self.doc.write_text(self._name_display.display(person), mark)
     self.doc.write_text(self.format_person_birth_and_death(person))
     self.doc.end_paragraph()
     return display_num
Exemplo n.º 19
0
 def print_person(self, level, person):
     display_num = self.numbering.number(level)
     self.doc.start_paragraph("DR-Level%d" % min(level, 32), display_num)
     mark = ReportUtils.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
Exemplo n.º 20
0
 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._("%(str1)s: %(str2)s") % {
             'str1': self._(_TITLE0),
             'str2': self._get_date(Date(self.year))
         }  # localized year
     else:
         title = self._("%(str1)s: %(str2)s") % {
             'str1': str(self.titletext),
             'str2': self._get_date(Date(self.year))
         }
     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)
Exemplo n.º 21
0
 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._("%(str1)s: %(str2)s") % {
             'str1' : self._(_TITLE0),
             'str2' : self._get_date(Date(self.year))} # localized year
     else:
         title = self._("%(str1)s: %(str2)s") % {
             'str1' : str(self.titletext),
             'str2' : self._get_date(Date(self.year))}
     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)
Exemplo n.º 22
0
 def print_reference(self, level, person, display_num):
     #Person and their family have already been printed so
     #print reference here
     if person:
         mark = ReportUtils.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(_("sp. see  %(reference)s : %(spouse)s") %
             {'reference':display_num, 'spouse':name}, mark)
         self.doc.end_paragraph()
Exemplo n.º 23
0
 def print_reference(self, level, person, display_num):
     #Person and their family have already been printed so
     #print reference here
     if person:
         mark = ReportUtils.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(_("sp. see  %(reference)s : %(spouse)s") %
             {'reference':display_num, 'spouse':name}, mark)
         self.doc.end_paragraph()
Exemplo n.º 24
0
    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)

        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')
        self.doc.write_text(self.filter.get_name(self._locale))
        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):
                # FIXME check whether person or family, if a family mark BOTH
                person = self.database.get_person_from_handle(handle)
                mark = ReportUtils.get_person_mark(self.database, person)
                if value != last_value:
                    last_value = value
                    rank = number
                self.doc.start_paragraph('REC-Normal')
                # FIXME this won't work for RTL languages:
                self.doc.write_text(
                    self._("%(number)s. ") % {'number': rank + 1})
                self.doc.write_markup(str(name), name.get_tags(), 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()
Exemplo n.º 25
0
 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)
     if self.want_ids:
         self.doc.write_text(' (%s)' % person.get_gramps_id())
     self.dump_string(person)
     self.doc.end_paragraph()
     return display_num
Exemplo n.º 26
0
 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)
     if self.want_ids:
         self.doc.write_text(' (%s)' % person.get_gramps_id())
     self.dump_string(person)
     self.doc.end_paragraph()
     return display_num
Exemplo n.º 27
0
    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.want_ids:
            self.doc.write_text('(%s)' % person.get_gramps_id())

        if self.inc_paths:
            self.write_path(person)

        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)
Exemplo n.º 28
0
    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)

        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')
        self.doc.write_text(self.filter.get_name(self._locale))
        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):
                # FIXME check whether person or family, if a family mark BOTH
                person = self.database.get_person_from_handle(handle)
                mark = ReportUtils.get_person_mark(self.database, person)
                if value != last_value:
                    last_value = value
                    rank = number
                self.doc.start_paragraph('REC-Normal')
                # FIXME this won't work for RTL languages:
                self.doc.write_text(self._("%(number)s. ") % {'number': rank+1})
                self.doc.write_markup(str(name), name.get_tags(), 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()
Exemplo n.º 29
0
 def print_report_reference(self, level, person, spouse, display_num):
     if person and spouse:
         mark = ReportUtils.get_person_mark(self.database, person)
         self.doc.start_paragraph("DR-Level%d" % min(level, 32))
         pname = self._name_display.display(person)
         sname = self._name_display.display(spouse)
         self.doc.write_text(
             _("see report: %(report)s, ref: %(reference)s : "
               "%(person)s & %(spouse)s") % \
              {'report':report_titles[display_num[0]], \
               'reference':display_num[1], \
               'person':pname, \
               'spouse':sname}, mark)
         self.doc.end_paragraph()
Exemplo n.º 30
0
 def print_report_reference(self, level, person, spouse, display_num):
     if person and spouse:
         mark = ReportUtils.get_person_mark(self.database, person)
         self.doc.start_paragraph("DR-Level%d" % min(level, 32))
         pname = self._name_display.display(person)
         sname = self._name_display.display(spouse)
         self.doc.write_text(
             _("see report: %(report)s, ref: %(reference)s : "
               "%(person)s & %(spouse)s") % \
              {'report':report_titles[display_num[0]], \
               'reference':display_num[1], \
               'person':pname, \
               'spouse':sname}, mark)
         self.doc.end_paragraph()
Exemplo n.º 31
0
 def print_spouse(self, level, spouse_handle, family_handle):
     #Currently print_spouses is the same for all numbering systems.
     if spouse_handle:
         spouse = self.database.get_person_from_handle(spouse_handle)
         mark = ReportUtils.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(_("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(_("sp. %(spouse)s") % {'spouse': 'Unknown'})
         self.doc.end_paragraph()
Exemplo n.º 32
0
 def print_spouse(self, level, spouse_handle, family_handle):
     #Currently print_spouses is the same for all numbering systems.
     if spouse_handle:
         spouse = self.database.get_person_from_handle(spouse_handle)
         mark = ReportUtils.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(_("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(_("sp. %(spouse)s") % {'spouse':'Unknown'})
         self.doc.end_paragraph()
Exemplo n.º 33
0
    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))
            if self.want_ids:
                self.doc.write_text(' (%s)' % mate.get_gramps_id())
            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)
Exemplo n.º 34
0
    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 = ReportUtils.find_spouse(person,family)
            spouse = self.db.get_person_from_handle(spouse_handle)
            spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
            text = ""
            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
Exemplo n.º 35
0
    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 = ReportUtils.find_spouse(person,family)
            spouse = self.db.get_person_from_handle(spouse_handle)
            spouse_mark = ReportUtils.get_person_mark(self.db, spouse)
            text = ""
            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
Exemplo n.º 36
0
    def _write_person(self, person_handle):
        """
        Generate a table row for a person record
        """
        person = self.database.get_person_from_handle(person_handle)

        self.doc.start_row()

        self.doc.start_cell(_('TR-TableCell'))
        self.doc.start_paragraph(_('TR-Normal'))
        self.doc.write_text(person.get_gramps_id())
        self.doc.end_paragraph()
        self.doc.end_cell()

        name = name_displayer.display(person)
        mark = ReportUtils.get_person_mark(self.database, person)
        self.doc.start_cell(_('TR-TableCell'))
        self.doc.start_paragraph(_('TR-Normal'))
        self.doc.write_text(name, mark)
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.start_cell(_('TR-TableCell'))
        self.doc.start_paragraph(_('TR-Normal'))
        birth_ref = person.get_birth_ref()
        if birth_ref:
            event = self.database.get_event_from_handle(birth_ref.ref)
            self.doc.write_text(
                _("b. ") + gramps.gen.datehandler.get_date(event))
        else:
            self.doc.write_text(_("b. ") + "_" * 12)
        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(
                _("d. ") + gramps.gen.datehandler.get_date(event))
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.end_row()
Exemplo n.º 37
0
 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)
         if self.want_ids:
             self.doc.write_text(' (%s)' % spouse.get_gramps_id())
         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()
Exemplo n.º 38
0
    def _write_person(self, person_handle):
        """
        Generate a table row for a person record
        """
        person = self.database.get_person_from_handle(person_handle)

        self.doc.start_row()

        self.doc.start_cell("TR-TableCell")
        self.doc.start_paragraph("TR-Normal")
        self.doc.write_text(person.get_gramps_id())
        self.doc.end_paragraph()
        self.doc.end_cell()

        name = name_displayer.display(person)
        mark = ReportUtils.get_person_mark(self.database, person)
        self.doc.start_cell("TR-TableCell")
        self.doc.start_paragraph("TR-Normal")
        self.doc.write_text(name, mark)
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.start_cell("TR-TableCell")
        self.doc.start_paragraph("TR-Normal")
        birth_ref = person.get_birth_ref()
        if birth_ref:
            event = self.database.get_event_from_handle(birth_ref.ref)
            self.doc.write_text("b. " + gramps.gen.datehandler.get_date(event))
        else:
            self.doc.write_text("b. " + "_" * 12)
        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("d. " + gramps.gen.datehandler.get_date(event))
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.end_row()
Exemplo n.º 39
0
 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)
         if self.want_ids:
             self.doc.write_text(' (%s)' % spouse.get_gramps_id())
         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()
Exemplo n.º 40
0
    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._nd)
            if text:
                self.doc.write_text_citation(text, spouse_mark)
                if self.want_ids:
                    self.doc.write_text(' (%s)' % family.get_gramps_id())
                is_first = False
Exemplo n.º 41
0
    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._nd)
            if text:
                self.doc.write_text_citation(text, spouse_mark)
                if self.want_ids:
                    self.doc.write_text(' (%s)' % family.get_gramps_id())
                is_first = False
Exemplo n.º 42
0
    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
Exemplo n.º 43
0
    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:
                        f = self.db.get_family_from_handle(family_handle)
                        if f.get_mother_handle() or f.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]
                    ReportUtils.insert_image(self.db, self.doc, 
                                             photo, self._user)
        
                name = self._name_display.display(ind)
                if not name:
                    name = self._("Unknown")
                mark = ReportUtils.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()
Exemplo n.º 44
0
    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)
        plist = person.get_media_list()
        self.__narrator.set_subject(person)
        
        if self.addimages and len(plist) > 0:
            photo = plist[0]
            ReportUtils.insert_image(self.db, self.doc, photo, self._user)

        self.doc.start_paragraph("DAR-First-Entry", "%d." % self._get_s_s(key))

        name = self._name_display.display(person)
        if not name:
            name = self._("Unknown")
        mark = ReportUtils.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():
                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()
                    first = False
                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
                
                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()
                    first = 0
                    
                self.write_event(event_ref)
                
        if self.inc_addr:
            for addr in person.get_address_list():
                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()
                    first = False
                self.doc.start_paragraph('DAR-MoreDetails')
                
                text = ReportUtils.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 first and attrs:
                self.doc.start_paragraph('DAR-MoreHeader')
                self.doc.write_text(
                    self._('More about %(person_name)s:')
                                % { 'person_name' : name })
                self.doc.end_paragraph()
                first = False

            for attr in attrs:
                self.doc.start_paragraph('DAR-MoreDetails')
                attrName = self._get_type(attr.get_type())
                text = self._("%(type)s: %(value)s%(endnotes)s") % {
                                  'type'     : self._(attrName),
                                  'value'    : attr.get_value(),
                                  'endnotes' : self.endnotes(attr) }
                self.doc.write_text_citation( text )
                self.doc.end_paragraph()

        return 0        # Not duplicate person
Exemplo n.º 45
0
    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 = ReportUtils.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 = ReportUtils.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])
Exemplo n.º 46
0
    def dump_child(self, index, person_handle):

        person = self.database.get_person_from_handle(person_handle)
        families = len(person.get_family_handle_list())
        birth_ref = person.get_birth_ref()
        if birth_ref:
            birth = self.database.get_event_from_handle(birth_ref.ref)
        else:
            birth = None
        death_ref = person.get_death_ref()
        if death_ref:
            death = self.database.get_event_from_handle(death_ref.ref)
        else:
            death = None

        spouse_count = 0
        if self.incChiMar:
            for family_handle in person.get_family_handle_list():
                family = self.database.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.missingInfo 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 = ReportUtils.get_person_mark(self.database, person)
        self.doc.start_cell('FGR-ChildName', 3)
        self.doc.start_paragraph('FGR-ChildText')
        self.doc.write_text(name, mark)
        self.doc.end_paragraph()
        self.doc.end_cell()
        self.doc.end_row()

        if self.missingInfo or birth is not None:
            if spouse_count != 0 or self.missingInfo 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.missingInfo or death is not None:
            if spouse_count == 0 or not self.incChiMar:
                self.dump_child_event('FGR-TextChild2', self._('Death'), death)
            else:
                self.dump_child_event('FGR-TextChild1', self._('Death'), death)

        if self.incChiMar:
            index = 0
            for family_handle in person.get_family_handle_list():
                m = None
                index += 1
                family = self.database.get_family_from_handle(family_handle)

                for event_ref in family.get_event_ref_list():
                    if event_ref:
                        event = self.database.get_event_from_handle(
                            event_ref.ref)
                        if event.type == EventType.MARRIAGE:
                            m = 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 m 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.database.get_person_from_handle(spouse_id)
                    spouse_name = self._name_display.display(spouse)
                    if self.incRelDates:
                        birth = "  "
                        birth_ref = spouse.get_birth_ref()
                        if birth_ref:
                            event = self.database.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.database.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 - %s)" % (spouse_name, birth,
                                                            death)
                    mark = ReportUtils.get_person_mark(self.database, spouse)
                    self.doc.write_text(spouse_name, mark)
                    self.doc.end_paragraph()
                    self.doc.end_cell()
                    self.doc.end_row()

                if m:
                    evtName = self._("Marriage")
                    if index == families:
                        self.dump_child_event('FGR-TextChild2', evtName, m)
                    else:
                        self.dump_child_event('FGR-TextChild1', evtName, m)
Exemplo n.º 47
0
    def dump_parent(self, title, person_handle):

        if not person_handle and not self.missingInfo:
            return
        elif not person_handle:
            person = Person()
        else:
            person = self.database.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')
        self.doc.write_text(title + ': ')
        mark = ReportUtils.get_person_mark(self.database, person)
        self.doc.write_text(name, mark)
        self.doc.end_paragraph()
        self.doc.end_cell()
        self.doc.end_row()

        birth_ref = person.get_birth_ref()
        birth = None
        evtName = self._("Birth")
        if birth_ref:
            birth = self.database.get_event_from_handle(birth_ref.ref)
        if birth or self.missingInfo:
            self.dump_parent_event(evtName, birth)

        death_ref = person.get_death_ref()
        death = None
        evtName = self._("Death")
        if death_ref:
            death = self.database.get_event_from_handle(death_ref.ref)
        if death or self.missingInfo:
            self.dump_parent_event(evtName, death)

        self.dump_parent_parents(person)

        if self.incParEvents:
            for event_ref in person.get_primary_event_ref_list():
                if event_ref != birth_ref and event_ref != death_ref:
                    event = self.database.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.incParAddr:
            addrlist = person.get_address_list()[:]
            for addr in addrlist:
                location = ReportUtils.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.incParNotes:
            for notehandle in person.get_note_list():
                note = self.database.get_note_from_handle(notehandle)
                self.dump_parent_noteline(self._("Note"), note)

        if self.includeAttrs:
            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.incParNames:
            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()
Exemplo n.º 48
0
    def write_person(self, count):
        if count != 0:
            self.doc.page_break()
        self.bibli = Bibliography(Bibliography.MODE_DATE|Bibliography.MODE_PAGE)

        text = self._name_display.display(self.person)
        # feature request 2356: avoid genitive form
        title = self._("Summary of %s") % text
        mark = IndexMark(title, INDEX_TYPE_TOC, 1)
        self.doc.start_paragraph("IDS-Title")
        self.doc.write_text(title, mark)
        self.doc.end_paragraph()

        self.doc.start_paragraph("IDS-Normal")
        self.doc.end_paragraph()

        name = self.person.get_primary_name()
        text = self.get_name(self.person)
        mark = ReportUtils.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 = ReportUtils.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 = ReportUtils.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()

        self.doc.start_cell('IDS-NormalCell')
        # translators: needed for French, ignore otherwise
        ignore4 = self._("%s:")
        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:
                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_srcs_notes,
                                    elocale=self._locale)
Exemplo n.º 49
0
    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,
                               user=self._user)

        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()
Exemplo n.º 50
0
    def write_report(self):
        """
        The routine the actually creates the report. At this point, the document
        is opened and ready for writing.
        """

        name = self._name_display.display(self.center_person)
        self.title = self._("AncestorFill for %s") % name
        self.doc.start_paragraph("ANF-Title")
        mark = utils.get_person_mark(self.database, self.center_person)
        self.doc.write_text('', mark)
        mark = IndexMark(self.title, INDEX_TYPE_TOC, 1)
        self.doc.write_text(self.title, mark)
        self.doc.end_paragraph()
        total = 0
        longueur = 1
        gen = 0
        percent = 100
        nbhand = 1
        implexe = 0
        theor = ''
        self.apply_filter(self.center_person.get_handle(), 1)

        strgen = self._("Generation ")
        strfoundanc = self._("Number of Ancestors found ")
        pctfoundanc = self._("percent of Ancestors found ")
        uniqfoundanc = self._("Number of single Ancestors found ")
        strtheoanc = self._("Number of theoretical Ancestors ")
        strimplex = self._("Pedigree Collapse ")

        if self.displayth:
            form = strgen + "%2d\n" + strfoundanc + "%12d\n" + strtheoanc + str(theor) + "\n" + pctfoundanc +" %." + str(self.Filleddigit) + "f%% " + " \n" + uniqfoundanc + " %6d\n" + strimplex + "%3." + str(self.Collapsedigit) + "f%%"
        else:
            form = strgen + "%2d\n" + strfoundanc + "%12d\n" + pctfoundanc +" %." + str(self.Filleddigit) + "f%% " + " \n" + uniqfoundanc + " %6d\n" + strimplex + "%3." + str(self.Collapsedigit) + "f%%"
            text = form % (gen, longueur, percent, nbhand, implexe)
            self.doc.start_paragraph("ANF-Generation")
            self.doc.write_text(text)
            self.doc.end_paragraph()
        for gen in range(0, self.max_generations):
            nextgen = gen + 1
            for gid in self.gener[gen].keys():
                for id2 in self.index[gid]:
                    if id2:
                        self.gener[nextgen][id2] += self.gener[gen][gid]
            longueur = 0
            nbhand = 0
            msg = "GEN  " + str (nextgen)
            for hand in self.gener[nextgen].keys():
                msg = msg + " " + str(hand)
                longueur += self.gener[nextgen][hand]
                nbhand += 1
            theor = 2 ** nextgen
            percent = longueur * 100.0 / theor
            total = total + longueur
            if not nbhand:
                implexe = 0
            else:
                implexe = float(longueur-nbhand)*100.0 / longueur
            if longueur == 0:
                next
            else:
                self.doc.start_paragraph("ANF-Generation")
                if self.displayth:
                    form = strgen + "%2d\n" + strfoundanc + "%12d\n" + strtheoanc + str(theor) + "\n" + pctfoundanc +" %." + str(self.Filleddigit) + "f%% " + " \n" + uniqfoundanc + " %6d\n" + strimplex + "%3." + str(self.Collapsedigit) + "f%%"
                else:
                    form = strgen + "%2d\n" + strfoundanc + "%12d\n" + pctfoundanc +" %." + str(self.Filleddigit) + "f%% " + " \n" + uniqfoundanc + " %6d\n" + strimplex + "%3." + str(self.Collapsedigit) + "f%%"
                text = form % (nextgen, longueur, percent, nbhand, implexe)
                self.doc.write_text(text)
                self.doc.end_paragraph()
        totalnbanc = len(self.trouve)
        timplexe= ( total - totalnbanc) * 100.0 / total
        strtotalanc = self._("Total Number of Ancestors found ")
        form = strtotalanc + "%d\n"
        totaluniqfoundanc = self._("Total Number of single Ancestors found ")
        form2 = totaluniqfoundanc + "%d\n"
        form3 = strimplex + "%3." + str(self.Collapsedigit) + "f%%"
        text = (form % total) + (form2 % totalnbanc) + (form3 % timplexe)
        self.doc.start_paragraph("ANF-Generation")
        self.doc.write_text(text)
        self.doc.end_paragraph()

        name = self._name_display.display_formal(self.center_person)
Exemplo n.º 51
0
    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_gramps_id())
            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()
Exemplo n.º 52
0
    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_gramps_id())
            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()
Exemplo n.º 53
0
    def write_families(self):

        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._('Marriages/Children'),
                             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 = ReportUtils.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 = ReportUtils.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):
                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:
                    type = 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 = place_displayer.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(type, 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_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 = []
Exemplo n.º 55
0
    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 = ReportUtils.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])
                        + " "
                        + ReportUtils.roman(cnt).lower()
                        + ".")
            else:
                self.doc.start_paragraph("DDR-ChildList",
                              prefix + ReportUtils.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()
Exemplo n.º 56
0
    def dump_parent_parents(self, person):
        family_handle = person.get_main_parents_family_handle()
        father_name = ""
        mother_name = ""
        if family_handle:
            family = self.database.get_family_from_handle(family_handle)
            father_handle = family.get_father_handle()
            if father_handle:
                father = self.database.get_person_from_handle(father_handle)
                father_name = self._name_display.display(father)
                if self.incRelDates:
                    birth_ref = father.get_birth_ref()
                    birth = "  "
                    if birth_ref:
                        event = self.database.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.database.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 - %s)" % (father_name, birth,
                                                        death)
            mother_handle = family.get_mother_handle()
            if mother_handle:
                mother = self.database.get_person_from_handle(mother_handle)
                mother_name = self._name_display.display(mother)
                if self.incRelDates:
                    birth_ref = mother.get_birth_ref()
                    birth = "  "
                    if birth_ref:
                        event = self.database.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.database.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 - %s)" % (mother_name, 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 = ReportUtils.get_person_mark(self.database, father)
            self.doc.write_text(father_name, mark)
            self.doc.end_paragraph()
            self.doc.end_cell()
            self.doc.end_row()
        elif self.missingInfo:
            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 = ReportUtils.get_person_mark(self.database, mother)
            self.doc.write_text(mother_name, mark)
            self.doc.end_paragraph()
            self.doc.end_cell()
            self.doc.end_row()
        elif self.missingInfo:
            self.dump_parent_line(self._("Mother"), "")
Exemplo n.º 57
0
 def add_mark(self, database, person):
     self.__mark = utils.get_person_mark(database, person)
Exemplo n.º 58
0
    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 = ReportUtils.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)