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.º 2
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.º 3
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.º 4
0
    def number(self, level):
        if level == 1:
            dash = ""
        else:
            dash = "-"
            if len(self.childnum) < level:
                self.childnum.append(1)
        
        to_return = (ReportUtils.roman(level) + dash +
                     str(self.childnum[level-1]) + ".")

        if level > 1:
            self.childnum[level-1] += 1
        
        return to_return
Exemplo n.º 5
0
    def number(self, level):
        if level == 1:
            dash = ""
        else:
            dash = "-"
            if len(self.childnum) < level:
                self.childnum.append(1)

        to_return = (ReportUtils.roman(level) + dash +
                     str(self.childnum[level - 1]) + ".")

        if level > 1:
            self.childnum[level - 1] += 1

        return to_return
Exemplo n.º 6
0
    def number(self, level):
        """ the number of the person """
        if level == 1:
            dash = ""
        else:
            dash = "-"
            if len(self.childnum) < level:
                self.childnum.append(1)

        to_return = (utils.roman(level) + dash +
                     str(self.childnum[level-1]) + ".")

        if level > 1:
            self.childnum[level-1] += 1

        return to_return
Exemplo n.º 7
0
    def number(self, level):
        """ the number of the person """
        if level == 1:
            dash = ""
        else:
            dash = "-"
            if len(self.childnum) < level:
                self.childnum.append(1)

        to_return = (utils.roman(level) + dash +
                     str(self.childnum[level - 1]) + ".")

        if level > 1:
            self.childnum[level - 1] += 1

        return to_return
Exemplo n.º 8
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.º 9
0
    def __calc_person_key(self, person):
        """
        The person key is a unique identifier that is built from the
        relationship to the default person. It consists of the "Ahnentafel"
        number of the common ancestor of the person with the default person,
        and then a letter representing the child number for each generation
        from the common ancestor to the person.

        If more than one common ancestor exists, the common ancestor with the
        lowest "Ahnentafel" number has precedence.

        For example, the second child of the third child of the father of the
        mother of the central person gets the person key "6cb".
        """

        relationship = get_relationship_calculator()

        default_person = self.database.get_default_person()

        # No home person set.
        if default_person is None:
            return (-1, 0, "")

        # First try direct relationship.
        spousestring = ""
        info, msg = relationship.get_relationship_distance_new(self.database, default_person, person, all_dist=True)
        info = relationship.collapse_relations(info)[0]
        (rank, ancestor_handle, default_rel, default_fam, person_rel, person_fam) = info

        # Then try relationship to any spouse.
        if rank == -1:
            index = 0
            for family_handle in default_person.get_family_handle_list():
                index += 1
                family = self.database.get_family_from_handle(family_handle)
                spouse_handle = utils.find_spouse(default_person, family)
                spouse = self.database.get_person_from_handle(spouse_handle)
                info, msg = relationship.get_relationship_distance_new(self.database, spouse, person, all_dist=True)
                info = relationship.collapse_relations(info)[0]
                (rank, ancestor_handle, default_rel, default_fam, person_rel, person_fam) = info
                if rank != -1:
                    spousestring = utils.roman(index)
                    break
            # If no relationship found at all, exit here.
            if rank == -1:
                return (rank, 0, "")

        # Calculate Ahnentafel number of common ancestor.
        ahnentafel = 1
        for rel in default_rel:
            ahnentafel *= 2
            if rel in (relationship.REL_MOTHER, relationship.REL_MOTHER_NOTBIRTH):
                ahnentafel += 1

        # Find out child letters.
        child = person
        childletters = ""
        for rel in person_rel:
            family_handle = child.get_main_parents_family_handle()
            family = self.database.get_family_from_handle(family_handle)
            if rel in (relationship.REL_MOTHER, relationship.REL_MOTHER_NOTBIRTH):
                parent_handle = family.get_mother_handle()
            else:
                parent_handle = family.get_father_handle()
            parent = self.database.get_person_from_handle(parent_handle)
            # Count *all* children from this parent
            childletter = "?"
            index = 0
            for family_handle in parent.get_family_handle_list():
                family = self.database.get_family_from_handle(family_handle)
                for child_ref in family.get_child_ref_list():
                    if child_ref.ref == child.get_handle():
                        childletter = string.ascii_lowercase[index]
                        break
                    index += 1
                else:
                    continue
                break
            childletters = childletter + childletters
            child = parent

        return (rank, ahnentafel, "%s%s%s" % (spousestring, ahnentafel, childletters))
Exemplo n.º 10
0
    def __process_person(self, person, rank, ahnentafel, person_key):
        """
        Recursively build the Family Sheet for this person and all children
        with spouses.

        @param person: Person object for the key person of the Family Sheet.
        @param rank: Numerical distance between the central person in the
            database and the person in the parameter (the number of births
            needed to connect them).
        @param ahnentafel: "Ahnentafel" number of the common ancestor of the
            central person in the database and the person in the parameter,
            seen from the side of the central person in the database.
        @param person_key: Family Sheet key to be printed on the top right of
            the corner.
        """

        # List of (person, rank, ahnentafel, person_key) tuples for persons to
        # process recursively after this one.
        more_sheets = []

        # Numbering of spouses (integer, but printed in roman numbers).
        spouse_index = 0

        # Numbering of children (integer, but printed as lowercase letters).
        child_index = 0

        # Source references to print as footnotes.
        self.__citation_index = 0
        self.__citations = []

        # Notes to print as footnotes.
        self.__note_index = 0
        self.__notes = []

        # --- Now let the party begin! ---

        self.doc.start_paragraph("FSR-Key")
        self.doc.write_text(person_key)
        self.doc.end_paragraph()

        self.doc.start_table(None, "FSR-Table")

        # Main person
        self.doc.start_row()
        self.doc.start_cell("FSR-HeadCell", 3)
        self.__dump_person(person, False, None)
        self.doc.end_cell()
        self.doc.end_row()

        # Spouses
        for family_handle in person.get_family_handle_list():
            family = self.database.get_family_from_handle(family_handle)

            spouse_index += 1

            spouse_handle = utils.find_spouse(person, family)
            spouse = self.database.get_person_from_handle(spouse_handle)

            # Determine relationship between the center person and the spouse.
            # If the spouse has a closer blood relationship than the current
            # person, we refer to the Family Sheet of the spouse instead of
            # printing the child list, because all children are more closely
            # related to the center person via the spouse than via the current
            # person. The same happens if the relationship is on the same
            # level, but the relationship via the spouse goes via a common
            # ancestor with a lower Ahnentafel numbering (i.e. a relationship
            # stronger father-sided). In these cases, refer_spouse will be set
            # to True.
            (spouse_rank, spouse_at, spouse_key) = self.__calc_person_key(spouse)
            if self.recurse != RelationsOptions.RECURSE_ALL:
                refer_spouse = spouse_rank != -1 and (
                    spouse_rank < rank or (spouse_rank == rank and spouse_at < ahnentafel)
                )
            else:
                refer_spouse = False

            self.doc.start_row()

            self.doc.start_cell("FSR-NumberCell", 1)
            self.doc.start_paragraph("FSR-Number")
            self.doc.write_text(utils.roman(spouse_index))
            self.doc.end_paragraph()
            self.doc.end_cell()

            self.doc.start_cell("FSR-DataCell", 2)
            self.__dump_family(family, spouse)
            if refer_spouse:
                self.doc.start_paragraph("FSR-Normal")
                self.doc.write_text(_("\u2192 %s") % spouse_key)
                self.doc.end_paragraph()
            self.doc.end_cell()

            self.doc.end_row()

            if refer_spouse:
                # Spouse with closer relationship than current person? Don't
                # print children on this Family Sheet (but count them for the
                # numbering).
                child_index += len(family.get_child_ref_list())
                continue

            # Children
            for child_ref in family.get_child_ref_list():
                child = self.database.get_person_from_handle(child_ref.ref)
                child_letter = string.ascii_lowercase[child_index]

                self.doc.start_row()

                self.doc.start_cell("FSR-EmptyCell", 1)
                self.doc.end_cell()

                self.doc.start_cell("FSR-NumberCell", 1)
                self.doc.start_paragraph("FSR-Number")
                self.doc.write_text(child_letter)
                self.doc.end_paragraph()
                self.doc.end_cell()

                self.doc.start_cell("FSR-DataCell", 1)

                has_spouses = child.get_family_handle_list() != []

                self.__dump_person(child, has_spouses, child_ref)

                if has_spouses:
                    # We have to recalculate the key for this person, it could
                    # be closer related if it is a direct ancestor of the
                    # central person or one of its spouses.
                    (child_rank, child_at, child_key) = self.__calc_person_key(child)

                    self.doc.start_paragraph("FSR-Normal")
                    self.doc.write_text(_("\u2192 %s") % child_key)
                    self.doc.end_paragraph()

                    # We recursively print this child *only* if its
                    # relationship with the central person is closest via the
                    # current person. This way, we avoid that a person is
                    # printed recursively from more than one of its ancestors.
                    if child_key == person_key + child_letter or self.recurse == RelationsOptions.RECURSE_ALL:
                        more_sheets.append((child, child_rank, child_at, child_key))

                self.doc.end_cell()

                self.doc.end_row()

                child_index += 1

        self.doc.start_row()
        self.doc.start_cell("FSR-FootCell", 3)
        self.doc.end_cell()
        self.doc.end_row()

        self.doc.end_table()

        self.__dump_sources()
        self.__dump_notes()

        # Now print the sheets for the children.
        if self.recurse != RelationsOptions.RECURSE_NONE:
            for (child, child_rank, child_at, child_key) in more_sheets:
                self.doc.page_break()
                self.__process_person(child, child_rank, child_at, child_key)
Exemplo n.º 11
0
    def __calc_person_key(self, person):
        """
        The person key is a unique identifier that is built from the
        relationship to the default person. It consists of the "Ahnentafel"
        number of the common ancestor of the person with the default person,
        and then a letter representing the child number for each generation
        from the common ancestor to the person.

        If more than one common ancestor exists, the common ancestor with the
        lowest "Ahnentafel" number has precedence.

        For example, the second child of the third child of the father of the
        mother of the central person gets the person key "6cb".
        """

        relationship = get_relationship_calculator()

        default_person = self.database.get_default_person()

        # No home person set.
        if default_person is None:
            return (-1, 0, "")

        # First try direct relationship.
        spousestring = ""
        info, msg = relationship.get_relationship_distance_new(self.database,
                                                               default_person,
                                                               person,
                                                               all_dist=True)
        info = relationship.collapse_relations(info)[0]
        (rank, ancestor_handle, default_rel, default_fam, person_rel,
         person_fam) = info

        # Then try relationship to any spouse.
        if rank == -1:
            index = 0
            for family_handle in default_person.get_family_handle_list():
                index += 1
                family = self.database.get_family_from_handle(family_handle)
                spouse_handle = utils.find_spouse(default_person, family)
                spouse = self.database.get_person_from_handle(spouse_handle)
                info, msg = relationship.get_relationship_distance_new(
                    self.database, spouse, person, all_dist=True)
                info = relationship.collapse_relations(info)[0]
                (rank, ancestor_handle, default_rel, default_fam, person_rel,
                 person_fam) = info
                if rank != -1:
                    spousestring = utils.roman(index)
                    break
            # If no relationship found at all, exit here.
            if rank == -1:
                return (rank, 0, "")

        # Calculate Ahnentafel number of common ancestor.
        ahnentafel = 1
        for rel in default_rel:
            ahnentafel *= 2
            if rel in (relationship.REL_MOTHER,
                       relationship.REL_MOTHER_NOTBIRTH):
                ahnentafel += 1

        # Find out child letters.
        child = person
        childletters = ""
        for rel in person_rel:
            family_handle = child.get_main_parents_family_handle()
            family = self.database.get_family_from_handle(family_handle)
            if rel in (relationship.REL_MOTHER,
                       relationship.REL_MOTHER_NOTBIRTH):
                parent_handle = family.get_mother_handle()
            else:
                parent_handle = family.get_father_handle()
            parent = self.database.get_person_from_handle(parent_handle)
            # Count *all* children from this parent
            childletter = "?"
            index = 0
            for family_handle in parent.get_family_handle_list():
                family = self.database.get_family_from_handle(family_handle)
                for child_ref in family.get_child_ref_list():
                    if child_ref.ref == child.get_handle():
                        childletter = string.ascii_lowercase[index]
                        break
                    index += 1
                else:
                    continue
                break
            childletters = childletter + childletters
            child = parent

        return (rank, ahnentafel,
                "%s%s%s" % (spousestring, ahnentafel, childletters))
Exemplo n.º 12
0
    def __process_person(self, person, rank, ahnentafel, person_key):
        """
        Recursively build the Family Sheet for this person and all children
        with spouses.

        @param person: Person object for the key person of the Family Sheet.
        @param rank: Numerical distance between the central person in the
            database and the person in the parameter (the number of births
            needed to connect them).
        @param ahnentafel: "Ahnentafel" number of the common ancestor of the
            central person in the database and the person in the parameter,
            seen from the side of the central person in the database.
        @param person_key: Family Sheet key to be printed on the top right of
            the corner.
        """

        # List of (person, rank, ahnentafel, person_key) tuples for persons to
        # process recursively after this one.
        more_sheets = []

        # Numbering of spouses (integer, but printed in roman numbers).
        spouse_index = 0

        # Numbering of children (integer, but printed as lowercase letters).
        child_index = 0

        # Source references to print as footnotes.
        self.__citation_index = 0
        self.__citations = []

        # Notes to print as footnotes.
        self.__note_index = 0
        self.__notes = []

        # --- Now let the party begin! ---

        head_name = str(
            _Name_get_styled(person.get_primary_name(),
                             _Name_CALLNAME_DONTUSE))
        mark2 = docgen.IndexMark(head_name, docgen.INDEX_TYPE_TOC, 2)

        self.doc.start_paragraph('FSR-Key')
        self.doc.write_text(person_key, mark2)
        self.doc.end_paragraph()

        self.doc.start_table(None, 'FSR-Table')

        # Main person
        self.doc.start_row()
        self.doc.start_cell('FSR-HeadCell', 3)
        self.__dump_person(person, False, None)
        self.doc.end_cell()
        self.doc.end_row()

        # Spouses
        for family_handle in person.get_family_handle_list():
            family = self.database.get_family_from_handle(family_handle)

            spouse_index += 1

            spouse_handle = utils.find_spouse(person, family)
            if spouse_handle:
                spouse = self.database.get_person_from_handle(spouse_handle)
            else:
                spouse = None

            # Determine relationship between the center person and the spouse.
            # If the spouse has a closer blood relationship than the current
            # person, we refer to the Family Sheet of the spouse instead of
            # printing the child list, because all children are more closely
            # related to the center person via the spouse than via the current
            # person. The same happens if the relationship is on the same
            # level, but the relationship via the spouse goes via a common
            # ancestor with a lower Ahnentafel numbering (i.e. a relationship
            # stronger father-sided). In these cases, refer_spouse will be set
            # to True.
            (spouse_rank, spouse_at, spouse_key) = \
                    self.__calc_person_key(spouse)
            if self.recurse != FamilySheetOptions.RECURSE_ALL:
                refer_spouse = (spouse_rank != -1 and \
                        (spouse_rank < rank or
                            (spouse_rank == rank and spouse_at < ahnentafel)))
            else:
                refer_spouse = False

            self.doc.start_row()

            self.doc.start_cell('FSR-NumberCell', 1)
            self.doc.start_paragraph('FSR-Number')
            self.doc.write_text(utils.roman(spouse_index))
            self.doc.end_paragraph()
            self.doc.end_cell()

            self.doc.start_cell('FSR-DataCell', 2)
            self.__dump_family(family, spouse)
            if refer_spouse:
                self.doc.start_paragraph('FSR-Normal')
                self.doc.write_text(_("\u2192 %s") % spouse_key)
                self.doc.end_paragraph()
            self.doc.end_cell()

            self.doc.end_row()

            if refer_spouse:
                # Spouse with closer relationship than current person? Don't
                # print children on this Family Sheet (but count them for the
                # numbering).
                child_index += len(family.get_child_ref_list())
                continue

            # Children
            for child_ref in family.get_child_ref_list():
                child = self.database.get_person_from_handle(child_ref.ref)
                child_letter = string.ascii_lowercase[child_index]

                self.doc.start_row()

                self.doc.start_cell('FSR-EmptyCell', 1)
                self.doc.end_cell()

                self.doc.start_cell('FSR-NumberCell', 1)
                self.doc.start_paragraph('FSR-Number')
                self.doc.write_text(child_letter)
                self.doc.end_paragraph()
                self.doc.end_cell()

                self.doc.start_cell('FSR-DataCell', 1)

                has_spouses = (child.get_family_handle_list() != [])

                self.__dump_person(child, has_spouses, child_ref)

                if has_spouses:
                    # We have to recalculate the key for this person, it could
                    # be closer related if it is a direct ancestor of the
                    # central person or one of its spouses.
                    (child_rank, child_at, child_key) = \
                            self.__calc_person_key(child)

                    self.doc.start_paragraph('FSR-Normal')
                    self.doc.write_text(_("\u2192 %s") % child_key)
                    self.doc.end_paragraph()

                    # We recursively print this child *only* if its
                    # relationship with the central person is closest via the
                    # current person. This way, we avoid that a person is
                    # printed recursively from more than one of its ancestors.
                    if child_key == person_key + child_letter or \
                            self.recurse == FamilySheetOptions.RECURSE_ALL:
                        more_sheets.append(
                            (child, child_rank, child_at, child_key))

                self.doc.end_cell()

                self.doc.end_row()

                child_index += 1

        self.doc.start_row()
        self.doc.start_cell('FSR-FootCell', 3)
        self.doc.end_cell()
        self.doc.end_row()

        self.doc.end_table()

        self.__dump_sources()
        self.__dump_notes()

        # Now print the sheets for the children.
        if self.recurse != FamilySheetOptions.RECURSE_NONE:
            for (child, child_rank, child_at, child_key) in more_sheets:
                self.doc.page_break()
                self.__process_person(child, child_rank, child_at, child_key)
Exemplo n.º 13
0
    def write_children(self, family):
        """
        List children.
        :param family: Family
        :return:
        """

        if not family.get_child_ref_list():
            return

        mother_handle = family.get_mother_handle()
        if mother_handle:
            mother = self._db.get_person_from_handle(mother_handle)
            mother_name = self._nd.display(mother)
            if not mother_name:
                mother_name = self._("Unknown")
        else:
            mother_name = self._("Unknown")

        father_handle = family.get_father_handle()
        if father_handle:
            father = self._db.get_person_from_handle(father_handle)
            father_name = self._nd.display(father)
            if not father_name:
                father_name = self._("Unknown")
        else:
            father_name = self._("Unknown")

        self.doc.start_paragraph("DAR-ChildTitle")
        self.doc.write_text(
            self._("Children of %(mother_name)s and %(father_name)s") % {
                'father_name': father_name,
                'mother_name': mother_name
            })
        self.doc.end_paragraph()

        cnt = 1
        for child_ref in family.get_child_ref_list():
            child_handle = child_ref.ref
            child = self._db.get_person_from_handle(child_handle)
            child_name = self._nd.display(child)
            if not child_name:
                child_name = self._("Unknown")
            child_mark = utils.get_person_mark(self._db, child)

            if self.childref and self.prev_gen_handles.get(child_handle):
                value = int(self.prev_gen_handles.get(child_handle))
                child_name += " [%d]" % self._get_s_s(value)

            self.doc.start_paragraph("DAR-ChildList",
                                     utils.roman(cnt).lower() + ".")
            cnt += 1

            self.__narrator.set_subject(child)
            if child_name:
                self.doc.write_text("%s. " % child_name, child_mark)
                if self.want_ids:
                    self.doc.write_text('(%s) ' % child.get_gramps_id())
            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())
            # if the list_children_spouses option is selected:
            if self.list_children_spouses:
                # get the family of the child that contains the spouse
                # of the child.  There may be more than one spouse for each
                # child
                family_handle_list = child.get_family_handle_list()
                # for the first spouse, this is true.
                # For subsequent spouses, make it false
                is_first_family = True
                for family_handle in family_handle_list:
                    child_family = self.database.get_family_from_handle(
                        family_handle)
                    self.doc.write_text_citation(
                        self.__narrator.get_married_string(
                            child_family, is_first_family, self._name_display))
                    is_first_family = False
            self.doc.end_paragraph()
Exemplo n.º 14
0
    def write_children(self, family):
        """
        List children.
        :param family: Family
        :return:
        """

        if not family.get_child_ref_list():
            return

        mother_handle = family.get_mother_handle()
        if mother_handle:
            mother = self._db.get_person_from_handle(mother_handle)
            mother_name = self._nd.display(mother)
            if not mother_name:
                mother_name = self._("Unknown")
        else:
            mother_name = self._("Unknown")

        father_handle = family.get_father_handle()
        if father_handle:
            father = self._db.get_person_from_handle(father_handle)
            father_name = self._nd.display(father)
            if not father_name:
                father_name = self._("Unknown")
        else:
            father_name = self._("Unknown")

        self.doc.start_paragraph("DAR-ChildTitle")
        self.doc.write_text(
            self._("Children of %(mother_name)s and %(father_name)s"
                  ) % {'father_name' : father_name,
                       'mother_name' : mother_name})
        self.doc.end_paragraph()

        cnt = 1
        for child_ref in family.get_child_ref_list():
            child_handle = child_ref.ref
            child = self._db.get_person_from_handle(child_handle)
            child_name = self._nd.display(child)
            if not child_name:
                child_name = self._("Unknown")
            child_mark = utils.get_person_mark(self._db, child)

            if self.childref and self.prev_gen_handles.get(child_handle):
                value = int(self.prev_gen_handles.get(child_handle))
                child_name += " [%d]" % self._get_s_s(value)

            self.doc.start_paragraph("DAR-ChildList",
                                     utils.roman(cnt).lower() + ".")
            cnt += 1

            self.__narrator.set_subject(child)
            if child_name:
                self.doc.write_text("%s. " % child_name, child_mark)
                if self.want_ids:
                    self.doc.write_text('(%s) ' % child.get_gramps_id())
            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())
            # if the list_children_spouses option is selected:
            if self.list_children_spouses:
                # get the family of the child that contains the spouse
                # of the child.  There may be more than one spouse for each
                # child
                family_handle_list = child.get_family_handle_list()
                # for the first spouse, this is true.
                # For subsequent spouses, make it false
                is_first_family = True
                for family_handle in family_handle_list:
                    child_family = self.database.get_family_from_handle(
                        family_handle
                    )
                    self.doc.write_text_citation(
                        self.__narrator.get_married_string(
                            child_family, is_first_family, self._name_display
                        )
                    )
                    is_first_family = False
            self.doc.end_paragraph()