def __write_referenced_media(self, photos, media_handle):
        """
        This procedure writes out each of the media related to the source.
        """

        # see indivcomplete textual report

        self.doc.start_table("images", 'REPO-MediaTab')
        cells = 3 # the GalleryTable has 3 cells
        self.doc.start_row()

        count = 0
        total = len(photos)

        for image in photos[0:3]: # only one line
            count += 1

            # check if not multiple references (citations) ???
            # TOFIX

            self.doc.start_cell('REPO-MediaCell')
            if image not in self.black_list:
                ReportUtils.insert_image(self.database, self.doc, image, self.user)
                self.black_list.append(image)
            self.doc.end_cell()

        self.doc.end_row()
        self.doc.end_table()
Beispiel #2
0
    def __write_referenced_media(self, photos, media_handle):
        """
        This procedure writes out each of the media related to the source.
        """

        # see indivcomplete textual report

        self.doc.start_table("images", 'REPO-MediaTab')
        cells = 3  # the GalleryTable has 3 cells
        self.doc.start_row()

        count = 0
        total = len(photos)

        for image in photos[0:3]:  # only one line
            count += 1

            # check if not multiple references (citations) ???
            # TOFIX

            self.doc.start_cell('REPO-MediaCell')
            if image not in self.black_list:
                ReportUtils.insert_image(self.database, self.doc, image,
                                         self.user)
                self.black_list.append(image)
            self.doc.end_cell()

        self.doc.end_row()
        self.doc.end_table()
Beispiel #3
0
    def __write_referenced_media(self, photo, media_handle):
        """
        This procedure writes out each of the media related to the source.
        """

        for image in photo:

            # check if not multiple references (citations) ???
            # TOFIX

            ReportUtils.insert_image(self.database, self.doc, image, self.user)
    def __write_referenced_media(self, photo, media_handle):
        """
        This procedure writes out each of the media related to the source.
        """

        for image in photo:
            
            # check if not multiple references (citations) ???
            # TOFIX

            ReportUtils.insert_image(self.database, self.doc, image, self.user)
Beispiel #5
0
    def write_images(self):

        media_list = self.person.get_media_list()
        if (not self.use_images) or (len(media_list) <
                                     2):  # only show if > one
            return

        self.doc.start_table("images", "IDS-GalleryTable")
        cells = 3  # the GalleryTable has 3 cells
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", cells)
        self.write_paragraph(self._('Images'), style='IDS-TableTitle')
        self.doc.end_cell()
        self.doc.end_row()
        count = 0
        while (count < len(media_list)):
            media_ref = media_list[count]
            media_handle = media_ref.get_reference_handle()
            media = self._db.get_object_from_handle(media_handle)
            if media is None:
                from gramps.gui.dialog import RunDatabaseRepair
                RunDatabaseRepair(_('Non existing media found in the Gallery'))
                return
            mime_type = media.get_mime_type()
            if not mime_type or not mime_type.startswith("image"):
                count += 1
                continue
            description = media.get_description()
            if count % cells == 0:
                self.doc.start_row()
            self.doc.start_cell('IDS-NormalCell')
            self.write_paragraph(description, style='IDS-ImageCaptionCenter')
            ReportUtils.insert_image(self._db,
                                     self.doc,
                                     media_ref,
                                     self._user,
                                     align='center',
                                     w_cm=5.0,
                                     h_cm=5.0)
            self.doc.end_cell()
            if count % cells == cells - 1:
                self.doc.end_row()
            count += 1
        if count % cells != 0:
            self.doc.end_row()
        self.doc.end_table()
        self.doc.start_paragraph('IDS-Normal')
        self.doc.end_paragraph()
Beispiel #6
0
    def write_images(self):

        media_list = self.person.get_media_list()
        if (not self.use_images) or (len(media_list) < 2): # only show if > one
            return
        
        self.doc.start_table("images","IDS-GalleryTable")
        cells = 3 # the GalleryTable has 3 cells
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", cells)
        self.write_paragraph(self._('Images'), style='IDS-TableTitle')
        self.doc.end_cell()
        self.doc.end_row()
        count = 0
        while ( count < len(media_list) ):
            media_ref = media_list[count]
            media_handle = media_ref.get_reference_handle()
            media = self._db.get_object_from_handle(media_handle)
            if media is None:
                from gramps.gui.dialog import RunDatabaseRepair
                RunDatabaseRepair(_('Non existing media found in the Gallery'))
                return
            mime_type = media.get_mime_type()
            if not mime_type or not mime_type.startswith("image"):
                count += 1
                continue
            description = media.get_description()
            if count % cells == 0:
                self.doc.start_row()
            self.doc.start_cell('IDS-NormalCell')
            self.write_paragraph(description, style='IDS-ImageCaptionCenter')
            ReportUtils.insert_image(self._db, self.doc, media_ref, self._user,
                                     align='center', w_cm=5.0, h_cm=5.0)
            self.doc.end_cell()
            if count % cells == cells - 1:
                self.doc.end_row()
            count += 1
        if count % cells != 0:
            self.doc.end_row()
        self.doc.end_table()
        self.doc.start_paragraph('IDS-Normal')
        self.doc.end_paragraph()
Beispiel #7
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()
Beispiel #8
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
    def write_person_info(self, person):
        name = self._name_display.display(person)
        if not name:
            name = self._("Unknown")
        self.__narrator.set_subject(person)

        plist = person.get_media_list()
        if self.addimages and len(plist) > 0:
            photo = plist[0]
            ReportUtils.insert_image(self.db, self.doc, photo, self._user)

        self.doc.start_paragraph("DDR-Entry")

        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)
        self.write_marriage(person)
        self.doc.end_paragraph()

        notelist = person.get_note_list()
        if len(notelist) > 0 and self.inc_notes:
            self.doc.start_paragraph("DDR-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(),"DDR-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('DDR-MoreHeader')
                    self.doc.write_text(self._('More about %(person_name)s:')
                                                    % {'person_name' : name })
                    self.doc.end_paragraph()
                    first = False
                self.doc.start_paragraph('DDR-MoreDetails')
                atype = self._get_type(alt_name.get_type())
                aname = alt_name.get_regular_name()
                self.doc.write_text_citation(
                    self._('%(name_kind)s: %(name)s%(endnotes)s')
                                % {'name_kind' : self._(atype),
                                   'name' : aname,
                                   'endnotes' : self.endnotes(alt_name),
                                  })
                self.doc.end_paragraph()

        if self.inc_events:
            for event_ref in person.get_primary_event_ref_list():
                if first:
                    self.doc.start_paragraph('DDR-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('DDR-MoreHeader')
                    self.doc.write_text(self._('More about %(person_name)s:')
                                                    % {'person_name' : name })
                    self.doc.end_paragraph()
                    first = False
                self.doc.start_paragraph('DDR-MoreDetails')

                text = ReportUtils.get_address_str(addr)

                if self.fulldate:
                    date = self._get_date(addr.get_date_object())
                else:
                    date = addr.get_date_object().get_year()

                self.doc.write_text(self._('Address: '))
                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('DDR-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('DDR-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()
Beispiel #10
0
    def write_images(self):

        media_list = self.person.get_media_list()
        if (not self.use_images) or (not media_list):
            return

        i_total = 0
        for media_ref in media_list:
            media_handle = media_ref.get_reference_handle()
            if media_handle:
                media = self._db.get_media_from_handle(media_handle)
                if media and media.get_mime_type():
                    if media.get_mime_type().startswith("image"):
                        i_total += 1
        if i_total == 0:
            return
        # if there is only one image, and it is the first Gallery item, it
        # will be shown up at the top, so there's no reason to show it here;
        # but if there's only one image and it is not the first Gallery
        # item (maybe the first is a PDF, say), then we need to show it
        if ((i_total == 1) and self.mime0 and self.mime0.startswith("image")):
            return

        self.doc.start_table("images","IDS-GalleryTable")
        cells = 3 # the GalleryTable has 3 cells
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", cells)
        self.write_paragraph(self._('Images'), style='IDS-TableTitle')
        self.doc.end_cell()
        self.doc.end_row()
        media_count = 0
        image_count = 0
        while ( media_count < len(media_list) ):
            media_ref = media_list[media_count]
            media_handle = media_ref.get_reference_handle()
            media = self._db.get_media_from_handle(media_handle)
            if media is None:
                from gramps.gui.dialog import RunDatabaseRepair
                RunDatabaseRepair(_('Non existing media found in the Gallery'))
                return
            mime_type = media.get_mime_type()
            if not mime_type or not mime_type.startswith("image"):
                media_count += 1
                continue
            description = media.get_description()
            if image_count % cells == 0:
                self.doc.start_row()
            self.doc.start_cell('IDS-NormalCell')
            self.write_paragraph(description, style='IDS-ImageCaptionCenter')
            ReportUtils.insert_image(self._db, self.doc, media_ref, self._user,
                                     align='center', w_cm=5.0, h_cm=5.0)
            self.do_attributes(media.get_attribute_list() +
                               media_ref.get_attribute_list() )
            self.doc.end_cell()
            if image_count % cells == cells - 1:
                self.doc.end_row()
            media_count += 1
            image_count += 1
        if image_count % cells != 0:
            self.doc.end_row()
        self.doc.end_table()
        self.doc.start_paragraph('IDS-Normal')
        self.doc.end_paragraph()
    def write_person_info(self, person):
        name = self._name_display.display(person)
        if not name:
            name = self._("Unknown")
        self.__narrator.set_subject(person)

        plist = person.get_media_list()
        if self.addimages and len(plist) > 0:
            photo = plist[0]
            ReportUtils.insert_image(self.db, self.doc, photo, self._user)

        self.doc.start_paragraph("DDR-Entry")

        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)
        self.write_marriage(person)
        self.doc.end_paragraph()

        notelist = person.get_note_list()
        if len(notelist) > 0 and self.inc_notes:
            self.doc.start_paragraph("DDR-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(),
                    "DDR-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('DDR-MoreHeader')
                    self.doc.write_text(
                        self._('More about %(person_name)s:') %
                        {'person_name': name})
                    self.doc.end_paragraph()
                    first = False
                self.doc.start_paragraph('DDR-MoreDetails')
                atype = self._get_type(alt_name.get_type())
                aname = alt_name.get_regular_name()
                self.doc.write_text_citation(
                    self._('%(name_kind)s: %(name)s%(endnotes)s') % {
                        'name_kind': self._(atype),
                        'name': aname,
                        'endnotes': self.endnotes(alt_name),
                    })
                self.doc.end_paragraph()

        if self.inc_events:
            for event_ref in person.get_primary_event_ref_list():
                if first:
                    self.doc.start_paragraph('DDR-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('DDR-MoreHeader')
                    self.doc.write_text(
                        self._('More about %(person_name)s:') %
                        {'person_name': name})
                    self.doc.end_paragraph()
                    first = False
                self.doc.start_paragraph('DDR-MoreDetails')

                text = ReportUtils.get_address_str(addr)

                if self.fulldate:
                    date = self._get_date(addr.get_date_object())
                else:
                    date = addr.get_date_object().get_year()

                self.doc.write_text(self._('Address: '))
                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('DDR-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('DDR-MoreDetails')
                attrName = attr.get_type().type2base()
                # translators: needed for French, ignore otherwise
                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()
Beispiel #12
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:
                        fam = self._db.get_family_from_handle(family_handle)
                        if fam.get_mother_handle() or fam.get_father_handle():
                            has_info = True
                            break

            if has_info:
                self.doc.start_paragraph("DAR-MoreHeader")

                plist = ind.get_media_list()

                if self.addimages and len(plist) > 0:
                    photo = plist[0]
                    utils.insert_image(self._db, self.doc,
                                       photo, self._user)

                name = self._nd.display(ind)
                if not name:
                    name = self._("Unknown")
                mark = utils.get_person_mark(self._db, ind)

                if family.get_relationship() == FamilyRelType.MARRIED:
                    self.doc.write_text(self._("Spouse: %s"
                                              ) % name,
                                        mark)
                else:
                    self.doc.write_text(self._("Relationship with: %s"
                                              ) % name,
                                        mark)
                if name[-1:] != '.':
                    self.doc.write_text(".")
                if self.want_ids:
                    self.doc.write_text(' (%s)' % ind.get_gramps_id())
                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()
Beispiel #13
0
    def write_person(self, key):
        """ Output birth, death, parentage, marriage and notes information """

        def write_more_header(first, name):
            """ convenience function """
            if first:
                self.doc.start_paragraph('DAR-MoreHeader')
                self.doc.write_text(self._('More about %(person_name)s:'
                                          ) % {'person_name' : name})
                self.doc.end_paragraph()
            return False

        person_handle = self.map[key]
        person = self._db.get_person_from_handle(person_handle)
        plist = person.get_media_list()
        self.__narrator.set_subject(person)

        if self.addimages and len(plist) > 0:
            photo = plist[0]
            utils.insert_image(self._db, self.doc, photo, self._user)

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

        name = self._nd.display(person)
        if not name:
            name = self._("Unknown")
        mark = utils.get_person_mark(self._db, person)

        self.doc.start_bold()
        self.doc.write_text(name, mark)
        if name[-1:] == '.':
            self.doc.write_text_citation("%s " % self.endnotes(person))
        elif name:
            self.doc.write_text_citation("%s. " % self.endnotes(person))
        self.doc.end_bold()
        if self.want_ids:
            self.doc.write_text('(%s) ' % person.get_gramps_id())

        if self.dupperson:
            # Check for duplicate record (result of distant cousins marrying)
            for dkey in sorted(self.map):
                if dkey >= key:
                    break
                if self.map[key] == self.map[dkey]:
                    self.doc.write_text(
                        self._("%(name)s is the same person as [%(id_str)s]."
                              ) % {'name' : '', 'id_str' : str(dkey)})
                    self.doc.end_paragraph()
                    return 1    # Duplicate person

        if not self.verbose:
            self.write_parents(person)

        text = self.__narrator.get_born_string()
        if text:
            self.doc.write_text_citation(text)

        text = self.__narrator.get_baptised_string()
        if text:
            self.doc.write_text_citation(text)

        text = self.__narrator.get_christened_string()
        if text:
            self.doc.write_text_citation(text)

        text = self.__narrator.get_died_string(self.calcageflag)
        if text:
            self.doc.write_text_citation(text)

        text = self.__narrator.get_buried_string()
        if text:
            self.doc.write_text_citation(text)

        if self.verbose:
            self.write_parents(person)

        if not key % 2 or key == 1:
            self.write_marriage(person)
        self.doc.end_paragraph()

        if key == 1:
            self.write_mate(person)

        notelist = person.get_note_list()
        if len(notelist) > 0 and self.includenotes:
            self.doc.start_paragraph("DAR-NoteHeader")
            # feature request 2356: avoid genitive form
            self.doc.write_text(self._("Notes for %s") % name)
            self.doc.end_paragraph()
            for notehandle in notelist:
                note = self._db.get_note_from_handle(notehandle)
                self.doc.write_styled_note(
                    note.get_styledtext(),
                    note.get_format(),
                    "DAR-Entry",
                    contains_html=(note.get_type() == NoteType.HTML_CODE)
                    )

        first = True
        if self.inc_names:
            for alt_name in person.get_alternate_names():
                first = write_more_header(first, name)
                self.doc.start_paragraph('DAR-MoreDetails')
                atype = self._get_type(alt_name.get_type())
                self.doc.write_text_citation(
                    self._('%(type)s: %(value)s%(endnotes)s'
                          ) % {'type' : self._(atype),
                               'value' : alt_name.get_regular_name(),
                               'endnotes' : self.endnotes(alt_name)})
                self.doc.end_paragraph()

        if self.inc_events:
            birth_ref = person.get_birth_ref()
            death_ref = person.get_death_ref()
            for event_ref in person.get_primary_event_ref_list():
                if event_ref == birth_ref or event_ref == death_ref:
                    continue
                first = write_more_header(first, name)
                self.write_event(event_ref)

        if self.other_events:
            for event_ref in person.get_event_ref_list():
                role = event_ref.get_role()
                if role in (EventRoleType.PRIMARY, EventRoleType.FAMILY):
                    continue
                first = write_more_header(first, name)
                self.write_event(event_ref)

        if self.inc_addr:
            for addr in person.get_address_list():
                first = write_more_header(first, name)
                self.doc.start_paragraph('DAR-MoreDetails')

                text = utils.get_address_str(addr)
                self.doc.write_text(self._('Address: '))

                if self.fulldate:
                    date = self._get_date(addr.get_date_object())
                else:
                    date = addr.get_date_object().get_year()

                if date:
                    # translators: needed for Arabic, ignore otherwise
                    self.doc.write_text(self._('%s, ') % date)
                self.doc.write_text(text)
                self.doc.write_text_citation(self.endnotes(addr))
                self.doc.end_paragraph()

        if self.inc_attrs:
            attrs = person.get_attribute_list()
            if attrs:
                first = write_more_header(first, name)
            for attr in attrs:
                self.doc.start_paragraph('DAR-MoreDetails')
                attr_name = attr.get_type().type2base()
                # translators: needed for French, ignore otherwise
                text = self._("%(type)s: %(value)s%(endnotes)s"
                             ) % {'type'     : self._(attr_name),
                                  'value'    : attr.get_value(),
                                  'endnotes' : self.endnotes(attr)}
                self.doc.write_text_citation(text)
                self.doc.end_paragraph()

        return 0        # Not duplicate person