Ejemplo n.º 1
0
 def __write_parents(self, person):
     family_handle = person.get_main_parents_family_handle()
     if family_handle:
         family = self.database.get_family_from_handle(family_handle)
         mother_handle = family.get_mother_handle()
         father_handle = family.get_father_handle()
         if mother_handle:
             mother = self.database.get_person_from_handle(mother_handle)
             mother_name = \
                 self._name_display.display_name(mother.get_primary_name())
             mother_mark = ReportUtils.get_person_mark(
                 self.database, mother)
         else:
             mother_name = ""
             mother_mark = ""
         if father_handle:
             father = self.database.get_person_from_handle(father_handle)
             father_name = \
                 self._name_display.display_name(father.get_primary_name())
             father_mark = ReportUtils.get_person_mark(
                 self.database, 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)
Ejemplo n.º 2
0
    def write_families(self):

        if not len(self.person.get_family_handle_list()):
            return

        self.doc.start_table("three", "IDS-IndTable")
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", 2)
        self.doc.start_paragraph("IDS-TableTitle")
        self.doc.write_text(_("Marriages/Children"))
        self.doc.end_paragraph()
        self.doc.end_cell()
        self.doc.end_row()

        for family_handle in self.person.get_family_handle_list():
            family = self.database.get_family_from_handle(family_handle)
            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)
            self.doc.start_paragraph("IDS-Spouse")
            if spouse_id:
                spouse = self.database.get_person_from_handle(spouse_id)
                text = self._name_display.display(spouse)
                mark = ReportUtils.get_person_mark(self.database, spouse)
            else:
                text = _("unknown")
                mark = None
            self.doc.write_text(text, mark)
            self.doc.end_paragraph()
            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.normal_cell(_("Children"))

                self.doc.start_cell("IDS-ListCell")

                for child_ref in child_ref_list:
                    self.doc.start_paragraph("IDS-Normal")
                    child = self.database.get_person_from_handle(child_ref.ref)
                    name = self._name_display.display(child)
                    mark = ReportUtils.get_person_mark(self.database, child)
                    self.doc.write_text(name, mark)
                    self.doc.end_paragraph()
                self.doc.end_cell()
                self.doc.end_row()
        self.doc.end_table()
        self.doc.start_paragraph('IDS-Normal')
        self.doc.end_paragraph()
Ejemplo n.º 3
0
    def write_alt_parents(self):

        if len(self.person.get_parent_family_handle_list()) < 2:
            return

        self.doc.start_table("altparents", "IDS-IndTable")
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", 2)
        self.doc.start_paragraph("IDS-TableTitle")
        self.doc.write_text(_("Alternate Parents"))
        self.doc.end_paragraph()
        self.doc.end_cell()
        self.doc.end_row()

        family_handle_list = self.person.get_parent_family_handle_list()
        for family_handle in family_handle_list:
            if (family_handle == self.person.get_main_parents_family_handle()):
                continue

            family = self.database.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.database.get_person_from_handle(father_handle)
                fname = self._name_display.display(father)
                mark = ReportUtils.get_person_mark(self.database, father)
                self.write_p_entry(_('Father'), fname, frel, mark)
            else:
                self.write_p_entry(_('Father'), '', '')

            mother_handle = family.get_mother_handle()
            if mother_handle:
                mother = self.database.get_person_from_handle(mother_handle)
                mname = self._name_display.display(mother)
                mark = ReportUtils.get_person_mark(self.database, mother)
                self.write_p_entry(_('Mother'), mname, mrel, mark)
            else:
                self.write_p_entry(_('Mother'), '', '')

        self.doc.end_table()
        self.doc.start_paragraph("IDS-Normal")
        self.doc.end_paragraph()
Ejemplo n.º 4
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 = DateHandler.get_date(birth)
        
        death_date = ""
        death = get_death_or_fallback(self.database, person)
        if death:
            death_date = DateHandler.get_date(death)
        dates = _(" (%(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()
Ejemplo n.º 5
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 = ReportUtils.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 = DateHandler.get_date( event )
        
        death_date = ""
        death_ref = person.get_death_ref()
        if death_ref:
            event = self.database.get_event_from_handle(death_ref.ref)
            death_date = DateHandler.get_date( event )
        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()
Ejemplo n.º 6
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.database.get_person_from_handle(child_handle)
            child_name = self._name_display.display(child)
            child_mark = ReportUtils.get_person_mark(self.database, 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.database.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()
Ejemplo n.º 7
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
Ejemplo n.º 8
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()
Ejemplo n.º 9
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()
Ejemplo n.º 10
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.database.get_person_from_handle(mate_handle)

            self.doc.start_paragraph("DDR-MoreHeader")
            name = self._name_display.display_formal(mate)
            mark = ReportUtils.get_person_mark(self.database, mate)
            if family.get_relationship() == FamilyRelType.MARRIED:
                self.doc.write_text(self._("Spouse: %s") % name, mark)
            else:
                self.doc.write_text(
                    self._("Relationship with: %s") % name, mark)
            if name[-1:] != '.':
                self.doc.write_text(".")
            self.doc.write_text_citation(self.endnotes(mate))
            self.doc.end_paragraph()

            if not self.inc_materef:
                # Don't want to just print reference
                self.write_person_info(mate)
            else:
                # Check to see if we've married a cousin
                if mate_handle in self.dnumber:
                    self.doc.start_paragraph('DDR-MoreDetails')
                    self.doc.write_text_citation(
                        self._("Ref: %s. %s") %
                        (self.dnumber[mate_handle], name))
                    self.doc.end_paragraph()
                else:
                    self.dmates[mate_handle] = person.get_handle()
                    self.write_person_info(mate)
Ejemplo n.º 11
0
    def write_marriage(self, person):
        """ 
        Output marriage sentence.
        """
        is_first = True
        for family_handle in person.get_family_handle_list():
            family = self.database.get_family_from_handle(family_handle)
            spouse_handle = ReportUtils.find_spouse(person, family)
            spouse = self.database.get_person_from_handle(spouse_handle)
            if spouse:
                name = self._name_display.display_formal(spouse)
            else:
                name = ""
            text = ""
            spouse_mark = ReportUtils.get_person_mark(self.database, spouse)

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

        # Call apply_filter to build the self.map array of people in the
        # database that match the ancestry.

        self.apply_filter(self.center_person.get_handle(), 1)

        # Write the title line. Set in INDEX marker so that this section will be
        # identified as a major category if this is included in a Book report.

        name = self._name_display.display_formal(self.center_person)
        # feature request 2356: avoid genitive form
        title = self._("Ahnentafel Report for %s") % name
        mark = IndexMark(title, INDEX_TYPE_TOC, 1)
        self.doc.start_paragraph("AHN-Title")
        self.doc.write_text(title, mark)
        self.doc.end_paragraph()

        # get the entries out of the map, and sort them.

        generation = 0

        for key in sorted(self.map):

            # check the index number to see if we need to start a new generation
            if generation == log2(key):

                # generate a page break if requested
                if self.pgbrk and generation > 0:
                    self.doc.page_break()
                generation += 1

                # Create the Generation title, set an index marker
                mark = IndexMark(title, INDEX_TYPE_TOC, 2)
                self.doc.start_paragraph("AHN-Generation")
                self.doc.write_text(self._("Generation %d") % generation, mark)
                self.doc.end_paragraph()

            # Build the entry

            self.doc.start_paragraph("AHN-Entry", "%d." % key)
            person = self.database.get_person_from_handle(self.map[key])
            name = self._name_display.display(person)
            mark = ReportUtils.get_person_mark(self.database, person)

            # write the name in bold
            self.doc.start_bold()
            self.doc.write_text(name.strip(), mark)
            self.doc.end_bold()

            # terminate with a period if it is not already terminated.
            # This can happen if the person's name ends with something 'Jr.'
            if name[-1:] == '.':
                self.doc.write_text(" ")
            else:
                self.doc.write_text(". ")

            # Add a line break if requested (not implemented yet)
            if self.opt_namebrk:
                self.doc.write_text('\n')

            self.__narrator.set_subject(person)
            self.doc.write_text(self.__narrator.get_born_string())
            self.doc.write_text(self.__narrator.get_baptised_string())
            self.doc.write_text(self.__narrator.get_christened_string())
            self.doc.write_text(self.__narrator.get_died_string())
            self.doc.write_text(self.__narrator.get_buried_string())

            self.doc.end_paragraph()
Ejemplo n.º 13
0
    def write_people(self):
        plist = self.database.iter_person_handles()
        FilterClass = GenericFilterFactory('Person')
        filter = FilterClass()
        filter.add_rule(Rules.Person.HasTag([self.tag]))
        ind_list = filter.apply(self.database, plist)

        if not ind_list:
            return

        self.doc.start_paragraph("TR-Heading")
        header = _("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(_("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(_("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(_("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(_("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 = 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(DateHandler.get_date(event))
            self.doc.end_paragraph()
            self.doc.end_cell()

            self.doc.start_cell('TR-TableCell')
            self.doc.start_paragraph('TR-Normal')
            death_ref = person.get_death_ref()
            if death_ref:
                event = self.database.get_event_from_handle(death_ref.ref)
                self.doc.write_text(DateHandler.get_date(event))
            self.doc.end_paragraph()
            self.doc.end_cell()

            self.doc.end_row()

        self.doc.end_table()
Ejemplo n.º 14
0
    def dump_parent(self, title, person_handle):

        if not person_handle and not self.missingInfo:
            return
        elif not person_handle:
            person = gen.lib.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 = str(gen.lib.EventType())
        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 = str(gen.lib.EventType(gen.lib.EventType.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)
                    evtType = event.get_type()
                    name = str(evtType)
                    self.dump_parent_event(name, event)

        if self.incParAddr:
            addrlist = person.get_address_list()[:]
            for addr in addrlist:
                location = ReportUtils.get_address_str(addr)
                date = DateHandler.get_date(addr)

                self.doc.start_row()
                self.doc.start_cell("FGR-TextContents")
                self.doc.start_paragraph('FGR-Normal')
                self.doc.write_text(_("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(_("Note"), note)

        if self.includeAttrs:
            for attr in person.get_attribute_list():
                self.dump_parent_line(str(attr.get_type()), attr.get_value())

        if self.incParNames:
            for alt_name in person.get_alternate_names():
                name_type = str(alt_name.get_type())
                name = self._name_display.display_name(alt_name)
                self.dump_parent_line(name_type, name)

        self.doc.end_table()
Ejemplo n.º 15
0
    def write_person(self, count):
        if count != 0:
            self.doc.page_break()
        self.bibli = Bibliography(Bibliography.MODE_DATE
                                  | Bibliography.MODE_PAGE)

        media_list = self.person.get_media_list()
        name = self._name_display.display(self.person)
        # feature request 2356: avoid genitive form
        title = _("Summary of %s") % name
        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._name_display.display_name(name)
        mark = ReportUtils.get_person_mark(self.database, self.person)
        endnotes = ""
        if self.use_srcs:
            endnotes = Endnotes.cite_source(self.bibli, self.database, name)

        family_handle = self.person.get_main_parents_family_handle()
        if family_handle:
            family = self.database.get_family_from_handle(family_handle)
            father_inst_id = family.get_father_handle()
            if father_inst_id:
                father_inst = self.database.get_person_from_handle(
                    father_inst_id)
                father = self._name_display.display(father_inst)
                fmark = ReportUtils.get_person_mark(self.database, father_inst)
            else:
                father = ""
                fmark = None
            mother_inst_id = family.get_mother_handle()
            if mother_inst_id:
                mother_inst = self.database.get_person_from_handle(
                    mother_inst_id)
                mother = self._name_display.display(mother_inst)
                mmark = ReportUtils.get_person_mark(self.database, mother_inst)
            else:
                mother = ""
                mmark = None
        else:
            father = ""
            fmark = None
            mother = ""
            mmark = None

        self.doc.start_table('person', 'IDS-PersonTable')
        self.doc.start_row()

        self.doc.start_cell('IDS-NormalCell')
        self.normal_paragraph("%s:" % _("Name"))
        self.normal_paragraph("%s:" % _("Gender"))
        self.normal_paragraph("%s:" % _("Father"))
        self.normal_paragraph("%s:" % _("Mother"))
        self.doc.end_cell()

        self.doc.start_cell('IDS-NormalCell')
        self.normal_paragraph(text, endnotes, mark)
        if self.person.get_gender() == Person.MALE:
            self.normal_paragraph(_("Male"))
        elif self.person.get_gender() == Person.FEMALE:
            self.normal_paragraph(_("Female"))
        else:
            self.normal_paragraph(_("Unknown"))
        self.normal_paragraph(father, mark=fmark)
        self.normal_paragraph(mother, mark=mmark)
        self.doc.end_cell()

        self.doc.start_cell('IDS-NormalCell')
        if self.use_images and len(media_list) > 0:
            media0 = media_list[0]
            media_handle = media0.get_reference_handle()
            media = self.database.get_object_from_handle(media_handle)
            mime_type = media.get_mime_type()
            if mime_type and mime_type.startswith("image"):
                filename = media_path_full(self.database, media.get_path())
                if os.path.exists(filename):
                    self.doc.add_media_object(filename,
                                              "right",
                                              4.0,
                                              4.0,
                                              crop=media0.get_rectangle())
                else:
                    self._user.warn(
                        _("Could not add photo to page"),
                        "%s: %s" % (filename, _('File does not exist')))
        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_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.database,
                                    self.doc,
                                    printnotes=self.use_srcs_notes)
Ejemplo n.º 16
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 = DateHandler.get_date(event)
                    death_ref = father.get_death_ref()
                    death = "  "
                    if death_ref:
                        event = self.database.get_event_from_handle(
                            death_ref.ref)
                        death = DateHandler.get_date(event)
                    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 = DateHandler.get_date(event)
                    death_ref = mother.get_death_ref()
                    death = "  "
                    if death_ref:
                        event = self.database.get_event_from_handle(
                            death_ref.ref)
                        death = DateHandler.get_date(event)
                    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(_("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(_("Father"), "")

        if mother_name != "":
            self.doc.start_row()
            self.doc.start_cell("FGR-TextContents")
            self.doc.start_paragraph('FGR-Normal')
            self.doc.write_text(_("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(_("Mother"), "")
Ejemplo n.º 17
0
    def write_families(self):
        flist = self.database.iter_family_handles()
        FilterClass = GenericFilterFactory('Family')
        filter = FilterClass()
        filter.add_rule(Rules.Family.HasTag([self.tag]))
        fam_list = filter.apply(self.database, flist)

        if not fam_list:
            return

        self.doc.start_paragraph("TR-Heading")
        header = _("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(_("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(_("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(_("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(_("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 = 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()

            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()
Ejemplo n.º 18
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() == gen.lib.Person.MALE:
            self.doc.write_text(index_str + _("acronym for male|M"))
        elif person.get_gender() == gen.lib.Person.FEMALE:
            self.doc.write_text(index_str + _("acronym for female|F"))
        else:
            self.doc.write_text(_("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', _('Birth'), birth)
            else:
                self.dump_child_event('FGR-TextChild2', _('Birth'), birth)

        if self.missingInfo or death is not None:
            if spouse_count == 0 or not self.incChiMar:
                self.dump_child_event('FGR-TextChild2', _('Death'), death)
            else:
                self.dump_child_event('FGR-TextChild1', _('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 == gen.lib.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(_("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 = DateHandler.get_date(event)
                        death = "  "
                        death_ref = spouse.get_death_ref()
                        if death_ref:
                            event = self.database.get_event_from_handle(
                                death_ref.ref)
                            death = DateHandler.get_date(event)
                        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 = str(gen.lib.EventType(
                        gen.lib.EventType.MARRIAGE))
                    if index == families:
                        self.dump_child_event('FGR-TextChild2', evtName, m)
                    else:
                        self.dump_child_event('FGR-TextChild1', evtName, m)
Ejemplo n.º 19
0
    def write_person(self, key):
        """Output birth, death, parentage, marriage and notes information """

        person_handle = self.map[key]
        person = self.database.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_formal(person)
        mark = ReportUtils.get_person_mark(self.database, person)

        self.doc.start_bold()
        self.doc.write_text(name, mark)
        if name[-1:] == '.':
            self.doc.write_text_citation("%s " % self.endnotes(person))
        else:
            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.database.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)