Example #1
0
    def _setup_fields(self):

        self.parents_label = self.top.get_object('parents_label')
        self.parents = self.top.get_object('parents')
        self.parents_select = self.top.get_object('parents_select')

        self.priv = PrivacyButton(
            self.top.get_object("private"),
            self.obj, self.db.readonly)

        self.date_field = MonitoredDate(
            self.top.get_object("date_entry"),
            self.top.get_object("date_stat"),
            self.obj.get_date_object(),
            self.uistate,
            self.track,
            self.db.readonly)

        self.place_field = PlaceEntry(
            self.dbstate,
            self.uistate,
            self.track,
            self.top.get_object("place"),
            self.top.get_object("place_event_box"),
            self.obj.set_place_handle,
            self.obj.get_place_handle,
            self.add_del_btn,
            self.share_btn)

        self.type_menu = MonitoredMenu(
            self.top.get_object('type'),
            self.obj.set_type,
            self.obj.get_type,
            [(item[1],item[0]) for item in LdsOrd._TYPE_MAP
             if item[0] in self._get_types()],
            self.db.readonly,
            changed=self.ord_type_changed)
        self.track_ref_for_deletion('type_menu')

        self.temple_menu = MonitoredStrMenu(
            self.top.get_object('temple'),
            self.obj.set_temple,
            self.obj.get_temple,
            TEMPLES.name_code_data(),
            self.db.readonly)
        self.track_ref_for_deletion('temple_menu')

        self.status_menu = MonitoredMenu(
            self.top.get_object('status'),
            self.obj.set_status,
            self.obj.get_status,
            [(item[1],item[0]) for item in LdsOrd._STATUS_MAP
             if item[0] in _DATA_MAP[self.obj.get_type()] ],
            self.db.readonly)
        self.track_ref_for_deletion('status_menu')

        self.ord_type_changed()
        self.update_parent_label()
Example #2
0
    def _setup_fields(self):

        self.parents_label = self.top.get_object('parents_label')
        self.parents = self.top.get_object('parents')
        self.parents_select = self.top.get_object('parents_select')

        self.priv = PrivacyButton(
            self.top.get_object("private"),
            self.obj, self.db.readonly)

        self.date_field = MonitoredDate(
            self.top.get_object("date_entry"),
            self.top.get_object("date_stat"),
            self.obj.get_date_object(),
            self.uistate,
            self.track,
            self.db.readonly)

        self.place_field = PlaceEntry(
            self.dbstate,
            self.uistate,
            self.track,
            self.top.get_object("place"),
            self.top.get_object("place_event_box"),
            self.obj.set_place_handle,
            self.obj.get_place_handle,
            self.add_del_btn,
            self.share_btn)

        self.type_menu = MonitoredMenu(
            self.top.get_object('type'),
            self.obj.set_type,
            self.obj.get_type,
            [(item[1],item[0]) for item in LdsOrd._TYPE_MAP
             if item[0] in self._get_types()],
            self.db.readonly,
            changed=self.ord_type_changed)
        self.track_ref_for_deletion('type_menu')

        self.temple_menu = MonitoredStrMenu(
            self.top.get_object('temple'),
            self.obj.set_temple,
            self.obj.get_temple,
            TEMPLES.name_code_data(),
            self.db.readonly)
        self.track_ref_for_deletion('temple_menu')

        self.status_menu = MonitoredMenu(
            self.top.get_object('status'),
            self.obj.set_status,
            self.obj.get_status,
            [(item[1],item[0]) for item in LdsOrd._STATUS_MAP
             if item[0] in _DATA_MAP[self.obj.get_type()] ],
            self.db.readonly)
        self.track_ref_for_deletion('status_menu')

        self.ord_type_changed()
        self.update_parent_label()
Example #3
0
    def __init__(self, lds_list, db):
        Gtk.ListStore.__init__(self, str, str, str, str, str, bool, object)

        for lds_ord in lds_list:
            self.append(row=[
                lds_ord.type2str(),
                get_date(lds_ord),
                lds_ord.status2str(),
                TEMPLES.name(lds_ord.get_temple()),
                place_displayer.display_event(db, lds_ord),
                lds_ord.get_privacy(),
                lds_ord,
                ])
Example #4
0
    def __init__(self, lds_list, db):
        Gtk.ListStore.__init__(self, str, str, str, str, str, bool, object)

        for lds_ord in lds_list:
            self.append(row=[
                lds_ord.type2str(),
                get_date(lds_ord),
                lds_ord.status2str(),
                TEMPLES.name(lds_ord.get_temple()),
                place_displayer.display_event(db, lds_ord),
                lds_ord.get_privacy(),
                lds_ord,
            ])
Example #5
0
    def __init__(self, lds_list, db):
        Gtk.ListStore.__init__(self, str, str, str, str, str, bool, object)

        self.db = db
        for lds_ord in lds_list:
            self.append(row=[
                lds_ord.type2str(),
                get_date(lds_ord),
                lds_ord.status2str(),
                TEMPLES.name(lds_ord.get_temple()),
                self.column_place(lds_ord),
                lds_ord.get_privacy(),
                lds_ord,
            ])
Example #6
0
    def write_LDS_ordinances(self):
        """ write any LDS ordinances of the person """

        ord_list = self.person.get_lds_ord_list()

        if len(ord_list) == 0:
            return

        self.doc.start_table("ordinances", "IDS-IndTable")
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", 2)
        self.write_paragraph(self._('LDS Ordinance'), style='IDS-TableTitle')
        self.doc.end_cell()
        self.doc.end_row()
        self.doc.end_table()

        self.doc.start_table("ordinances3", "IDS-OrdinanceTable")
        self.doc.start_row()
        self.write_cell(self._('Type'), style='IDS-Section')
        self.write_cell(self._('Date'), style='IDS-Section')
        self.write_cell(self._('Status'), style='IDS-Section')
        self.write_cell(self._('Temple'), style='IDS-Section')
        self.write_cell(self._('Place'), style='IDS-Section')
        self.doc.end_row()

        for lds_ord in ord_list:
            otype = self._(lds_ord.type2str())
            date = self._get_date(lds_ord.get_date_object())
            status = self._(lds_ord.status2str())
            temple = TEMPLES.name(lds_ord.get_temple())
            place_name = ''
            place_endnote = ''
            place_handle = lds_ord.get_place_handle()
            if place_handle:
                place = self._db.get_place_from_handle(place_handle)
                place_name = _pd.display_event(self._db, lds_ord)
                place_endnote = self._cite_endnote(place)
            endnotes = self._cite_endnote(lds_ord, prior=place_endnote)
            self.doc.start_row()
            self.write_cell(otype, endnotes)
            self.write_cell(date)
            self.write_cell(status)
            self.write_cell(temple)
            self.write_cell(place_name)
            self.doc.end_row()
        self.doc.end_table()
        self.doc.start_paragraph('IDS-Normal')
        self.doc.end_paragraph()
Example #7
0
    def write_LDS_ordinances(self):

        ord_list = self.person.get_lds_ord_list()

        if len(ord_list) == 0:
            return

        self.doc.start_table("ordinances","IDS-IndTable")
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", 2)
        self.write_paragraph(self._('LDS Ordinance'), style='IDS-TableTitle')
        self.doc.end_cell()
        self.doc.end_row()
        self.doc.end_table()

        self.doc.start_table("ordinances3","IDS-OrdinanceTable")
        self.doc.start_row()
        self.write_cell(self._('Type'), style='IDS-Section')
        self.write_cell(self._('Date'), style='IDS-Section')
        self.write_cell(self._('Status'), style='IDS-Section')
        self.write_cell(self._('Temple'), style='IDS-Section')
        self.write_cell(self._('Place'), style='IDS-Section')
        self.doc.end_row()

        for lds_ord in ord_list:
            type = self._(lds_ord.type2str())
            date = self._get_date(lds_ord.get_date_object())
            status = self._(lds_ord.status2str())
            temple = TEMPLES.name(lds_ord.get_temple())
            place_name = ''
            place_endnote = ''
            place_handle = lds_ord.get_place_handle()
            if place_handle:
                place = self._db.get_place_from_handle(place_handle)
                place_name = place_displayer.display_event(self._db, lds_ord)
                place_endnote = self._cite_endnote(place)
            endnotes = self._cite_endnote(lds_ord, prior=place_endnote)
            self.doc.start_row()
            self.write_cell(type, endnotes)
            self.write_cell(date)
            self.write_cell(status)
            self.write_cell(temple)
            self.write_cell(place_name)
            self.doc.end_row()
        self.doc.end_table()
        self.doc.start_paragraph('IDS-Normal')
        self.doc.end_paragraph()
Example #8
0
    def write_families(self):

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

        self.doc.start_table("three","IDS-IndTable")
        self.doc.start_row()
        self.doc.start_cell("IDS-TableHead", 2)
        self.write_paragraph(self._('Marriages/Children'),
                             style='IDS-TableTitle')
        self.doc.end_cell()
        self.doc.end_row()
        self.doc.end_table()

        for family_handle in family_handle_list:
            self.doc.start_table("three","IDS-IndTable")
            family = self._db.get_family_from_handle(family_handle)
            self.family_notes_list += family.get_note_list()
            if self.person.get_handle() == family.get_father_handle():
                spouse_id = family.get_mother_handle()
            else:
                spouse_id = family.get_father_handle()
            self.doc.start_row()
            self.doc.start_cell("IDS-NormalCell", 2)
            if spouse_id:
                spouse = self._db.get_person_from_handle(spouse_id)
                text = self.get_name(spouse)
                mark = ReportUtils.get_person_mark(self._db, spouse)
            else:
                spouse = None
                text = self._("unknown")
                mark = None
            endnotes = self._cite_endnote(family)
            self.write_paragraph(text, endnotes=endnotes, mark=mark,
                                 style='IDS-Spouse')
            self.doc.end_cell()
            self.doc.end_row()

            event_ref_list = family.get_event_ref_list()
            for event_ref, event in self.get_event_list(event_ref_list):
                self.write_fact(event_ref, event)

            child_ref_list = family.get_child_ref_list()
            if len(child_ref_list):
                self.doc.start_row()
                self.write_cell(self._("Children"))
                self.doc.start_cell("IDS-ListCell")
                for child_ref in child_ref_list:
                    child = self._db.get_person_from_handle(child_ref.ref)
                    name = self.get_name(child)
                    mark = ReportUtils.get_person_mark(self._db, child)
                    endnotes = self._cite_endnote(child_ref)
                    self.write_paragraph(name, endnotes=endnotes, mark=mark)
                self.doc.end_cell()
                self.doc.end_row()

            attr_list = family.get_attribute_list()
            if len(attr_list):
                self.doc.start_row()
                self.write_cell(self._("Attributes"))
                self.doc.start_cell("IDS-ListCell")
                self.do_attributes(attr_list)
                self.doc.end_cell()
                self.doc.end_row()

            self.doc.end_table()

            ord_list = family.get_lds_ord_list()
            if len(ord_list):
                self.doc.start_table("ordinances2","IDS-OrdinanceTable2")
                self.doc.start_row()
                self.write_cell(self._('LDS Ordinance'))
                self.write_cell(self._('Type'), style='IDS-Section')
                self.write_cell(self._('Date'), style='IDS-Section')
                self.write_cell(self._('Status'), style='IDS-Section')
                self.write_cell(self._('Temple'), style='IDS-Section')
                self.write_cell(self._('Place'), style='IDS-Section')
                self.doc.end_row()

                for lds_ord in ord_list:
                    type = self._(lds_ord.type2str())
                    date = self._get_date(lds_ord.get_date_object())
                    status = self._(lds_ord.status2str())
                    temple = TEMPLES.name(lds_ord.get_temple())
                    place_name = ''
                    place_endnote = ''
                    place_handle = lds_ord.get_place_handle()
                    if place_handle:
                        place = self._db.get_place_from_handle(place_handle)
                        place_name = place_displayer.display_event(self._db, lds_ord)
                        place_endnote = self._cite_endnote(place)
                    endnotes = self._cite_endnote(lds_ord, prior=place_endnote)
                    self.doc.start_row()
                    self.write_cell('')
                    self.write_cell(type, endnotes)
                    self.write_cell(date)
                    self.write_cell(status)
                    self.write_cell(temple)
                    self.write_cell(place_name)
                    self.doc.end_row()
                self.doc.end_table()

        self.doc.start_paragraph('IDS-Normal')
        self.doc.end_paragraph()
Example #9
0
    def print_object(self, level, o):

        if issubclass(o.__class__, gramps.gen.lib.address.Address):
            # Details of address are printed by the subclass conditions,
            # primarily by LocationBase, because address is a subclass of
            # LocationBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.addressbase.AddressBase):
            for address in o.get_address_list():
                self.print_header(level, _("Address"), ref=address)
                self.print_object(level + 1, address)

        if isinstance(o, gramps.gen.lib.Attribute):
            # The unique information about attributes (the type) is printed by
            # AttributeBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.attrbase.AttributeBase):
            for attribute in o.get_attribute_list():
                self.print_header(level,
                                  _("Attribute") + ". ",
                                  type_desc=str(attribute.get_type()),
                                  obj_type=attribute.get_value(),
                                  privacy=attribute.get_privacy(),
                                  ref=attribute)
                self.print_object(level + 1, attribute)

        if isinstance(o, gramps.gen.lib.ChildRef):
            # The unique information about ChildRef (the father relation and
            # mother relation) is printed by the main write_report function
            pass

        if issubclass(o.__class__, gramps.gen.lib.citationbase.CitationBase):
            if self.print_citations:
                self.print_header(level, "CitationBase tbd")

                for citation_handle in o.get_citation_list():
                    citation = self.database.get_citation_from_handle(
                        citation_handle)
                    self.print_object(level + 1, citation)

        if isinstance(o, gramps.gen.lib.Citation):
            # the unique information about Citation (the page) is printed by the
            # bibliography code. The other unique information, the confidence is
            # printed here
            if o.get_confidence_level() != gramps.gen.lib.Citation.CONF_NORMAL:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Confidence") + " : ")
                self.doc.end_bold()
                self.doc.write_text(
                    conf_strings.get(o.get_confidence_level(), _('Unknown')))
                self.doc.end_paragraph()

            if self.print_citations:
                source_handle = o.get_reference_handle()
                source = self.database.get_source_from_handle(source_handle)
                self.print_object(level + 1, source)

        if issubclass(o.__class__, gramps.gen.lib.datebase.DateBase):
            if o.get_date_object() and not o.get_date_object().is_empty():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Date") + " : ")
                self.doc.end_bold()
                self.doc.write_text(displayer.display(o.get_date_object()))
                self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Event):
            # The event type is printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description") + " : ")
            self.doc.end_bold()
            self.doc.write_text(str(o.get_description()))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.eventref.EventRef):
            # The unique information about EventRef (the EventRoleType) is
            # printed by the main write_report function
            event = self.database.get_event_from_handle(
                o.get_reference_handle())
            self.print_header(level,
                              _("Event"),
                              event.get_gramps_id(),
                              _("Event type"),
                              str(event.get_type()),
                              event.get_privacy(),
                              ref=event)
            self.print_object(level + 1, event)

        if isinstance(o, gramps.gen.lib.Family):
            # The unique information about Family (father, mother and children,
            # FamilyRelType and event references) are printed by the main
            # write_report function
            pass

        if isinstance(o, gramps.gen.lib.LdsOrd):
            # The Ordinance type is printed by LdsOrdBase
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Temple and status") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (TEMPLES.name(o.get_temple()), o.status2str())))
            self.doc.end_paragraph()

            f_h = o.get_family_handle()
            if f_h:
                family = self.database.get_family_from_handle(f_h)
                self.print_family_summary(level + 1, family,
                                          _("LDS Ordinance family"))

        if issubclass(o.__class__, gramps.gen.lib.ldsordbase.LdsOrdBase):
            for ldsord in o.get_lds_ord_list():
                self.print_header(level,
                                  _("LDS "),
                                  type_desc=_("Ordinance"),
                                  obj_type=ldsord.type2str(),
                                  privacy=ldsord.get_privacy(),
                                  ref=ldsord)
                self.print_object(level + 1, ldsord)

        if isinstance(o, gramps.gen.lib.Location):
            # The unique information about location (Parish) is printed by
            # Place. Location otherwise serves as a pointer to a LocationBase
            # object
            pass

        if issubclass(o.__class__, gramps.gen.lib.locationbase.LocationBase):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(
                _("Street, City, County, State, Postal Code, "
                  "Country, Phone number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (o.get_street(), o.get_city(), o.get_county(), o.get_state(),
                 o.get_postal_code(), o.get_country(), o.get_phone())))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.mediabase.MediaBase):
            for mediaref in o.get_media_list():
                self.print_header(level, _("Media Reference"), ref=mediaref)
                self.print_object(level + 1, mediaref)

        if isinstance(o, gramps.gen.lib.Media):
            # thumb is not printed. The mime type is printed by MediaRef
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark(
                    "file://:" + media_path_full(self.database, path),
                    LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

            mime_type = o.get_mime_type()
            if mime_type and mime_type.startswith("image"):
                filename = media_path_full(self.database, o.get_path())
                if os.path.exists(filename):
                    self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                    self.doc.add_media(filename, "single", 4.0, 4.0)
                    self.doc.end_paragraph()
                else:
                    self._user.warn(
                        _("Could not add photo to page"),
                        "%s: %s" % (filename, _('File does not exist')))

        if isinstance(o, gramps.gen.lib.MediaRef):
            media_handle = o.get_reference_handle()
            media = self.database.get_media_from_handle(media_handle)

            if o.get_rectangle():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Referenced Region") + " : ")
                self.doc.end_bold()
                self.doc.write_text(", ".join(
                    (("%d" % i) for i in o.get_rectangle())))
                self.doc.end_paragraph()

                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.start_paragraph("PE-Level%d" % min(level, 32))
                        self.doc.add_media(filename,
                                           "single",
                                           4.0,
                                           4.0,
                                           crop=o.get_rectangle())
                        self.doc.end_paragraph()

            desc = get_description(media.get_mime_type())
            if not desc:
                desc = _("unknown")
            self.print_header(level,
                              _("Media Object"),
                              media.get_gramps_id(),
                              _("Mime type"),
                              desc,
                              media.get_privacy(),
                              ref=media)
            self.print_object(level + 1, media)

        if isinstance(o, gramps.gen.lib.Name):
            # group_as, sort_as and display_as are not printed. NameType is
            # printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(
                _("Given name(s): Title, Given, Suffix, "
                  "Call Name, Nick Name, Family Nick Name") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (o.get_title(), o.get_first_name(), o.get_suffix(),
                 o.get_call_name(), o.get_nick_name(),
                 o.get_family_nick_name())))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Note):
            # The NoteType is printed by NoteBase. Whether the note is flowed or
            # not is not printed, but affects the way the note appears
            self.doc.write_styled_note(
                o.get_styledtext(),
                o.get_format(),
                "PE-Level%d" % min(level, 32),
                contains_html=o.get_type() ==
                gramps.gen.lib.notetype.NoteType.HTML_CODE)

        if issubclass(o.__class__, gramps.gen.lib.notebase.NoteBase):
            for n_h in o.get_note_list():
                note = self.database.get_note_from_handle(n_h)
                self.print_header(level, _("Note"), note.get_gramps_id(),
                                  _("Note type"), str(note.get_type()),
                                  note.get_privacy())
                self.print_object(level + 1, note)

        if issubclass(o.__class__, gramps.gen.lib.Person):
            # This is printed by the main write-report function
            pass

        if isinstance(o, gramps.gen.lib.Place):
            # The title, name, type, code and lat/long are printed by PlaceBase
            for placeref in o.get_placeref_list():
                self.print_header(level, _("Parent Place"))
                self.print_object(level + 1, placeref)


#            location = o.get_main_location()
#            if location.get_parish():
#                self.print_header(level, _("Main Location"),
#                                  type_desc=_("Parish"),
#                                  obj_type=location.get_parish())
#            else:
#                self.print_header(level, _("Main Location"))
#
#            self.print_object(level+1, location)
#
            for location in o.get_alternate_locations():
                if location.get_parish():
                    self.print_header(level,
                                      _("Alternate Location"),
                                      type_desc=_("Parish"),
                                      obj_type=location.get_parish())
                else:
                    self.print_header(level, _("Alternate Location"))
                self.print_object(level + 1, location)

        if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase) or \
            issubclass(o.__class__, gramps.gen.lib.placeref.PlaceRef):
            if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase):
                place_handle = o.get_place_handle()
            else:
                place_handle = o.get_reference_handle()
            if place_handle:
                place = self.database.get_place_from_handle(place_handle)
                if place:
                    place_title = place_displayer.display(self.database, place)
                    self.print_header(level,
                                      _("Place"),
                                      place.get_gramps_id(),
                                      _("Place Title"),
                                      place_title,
                                      privacy=place.get_privacy(),
                                      ref=place)
                    self.doc.start_paragraph("PE-Level%d" % min(level + 1, 32))
                    self.doc.start_bold()
                    self.doc.write_text(_("Name") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(place.get_name().value)
                    self.doc.start_bold()
                    self.doc.write_text(" " + _("Type") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(str(place.get_type()))
                    self.doc.start_bold()
                    self.doc.write_text(" " + _("Code") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(place.get_code())
                    self.doc.end_paragraph()

                    for name in place.get_alternative_names():
                        self.doc.start_paragraph("PE-Level%d" %
                                                 min(level + 1, 32))
                        self.doc.start_bold()
                        self.doc.write_text(_("Alternative Name") + " : ")
                        self.doc.end_bold()
                        self.doc.write_text(name.value)
                        self.doc.end_paragraph()

                    if place.get_longitude() or place.get_latitude():
                        self.doc.start_paragraph("PE-Level%d" %
                                                 min(level + 1, 32))
                        self.doc.start_bold()
                        self.doc.write_text(_("Latitude, Longitude") + " : ")
                        self.doc.end_bold()
                        self.doc.write_text(", ".join(
                            (place.get_longitude(), place.get_latitude())))
                        self.doc.end_paragraph()

                    self.print_object(level + 1, place)

        if issubclass(o.__class__,
                      gramps.gen.lib.primaryobj.BasicPrimaryObject):
            # The Gramps ID is printed by the enclosing object
            pass

        if issubclass(o.__class__, gramps.gen.lib.privacybase.PrivacyBase):
            # The privacy is printed by the enclosing object
            pass

        if isinstance(o, gramps.gen.lib.RepoRef):
            # The media type is printed by source
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Call number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_call_number())
            self.doc.end_paragraph()

            repository_handle = o.get_reference_handle()
            repository = self.database.get_repository_from_handle(
                repository_handle)
            self.print_header(level,
                              _("Repository"),
                              repository.get_gramps_id(),
                              _("Repository type"),
                              str(repository.get_type()),
                              privacy=repository.get_privacy())
            self.print_object(level + 1, repository)

        if isinstance(o, gramps.gen.lib.Repository):
            # the repository type is printed by RepoRef
            pass

        if isinstance(o, gramps.gen.lib.Source):
            # The title, author, abbreviation and publication information are
            # printed by the bibliography code
            #            data_map = o.get_data_map()
            #            for key in data_map.keys():
            #                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            #                self.doc.start_bold()
            #                self.doc.write_text(_("Data") + ". " + key + " : ")
            #                self.doc.end_bold()
            #                self.doc.write_text(data_map[key])
            #                self.doc.end_paragraph()

            reporef_list = o.get_reporef_list()
            for reporef in reporef_list:
                self.print_header(level,
                                  _("Repository reference"),
                                  type_desc=_("Media type"),
                                  obj_type=str(reporef.get_media_type()),
                                  privacy=reporef.get_privacy())
                self.print_object(level + 1, reporef)

        if isinstance(o, gramps.gen.lib.Surname):
            if o.get_origintype():
                self.print_header(level,
                                  _("Surname"),
                                  type_desc=_("Origin type"),
                                  obj_type=str(o.get_origintype()))
            else:
                self.print_header(level, _("Surname"), privacy=o.get_privacy())
            self.doc.start_paragraph("PE-Level%d" % min(level + 1, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Prefix, surname, connector") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (o.get_prefix(), o.get_surname(), o.get_connector())))
            if o.get_primary():
                self.doc.write_text(" " + _("{This is the primary surname}"))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.surnamebase.SurnameBase):
            surname_list = o.get_surname_list()
            for surname in surname_list:
                self.print_object(level, surname)

        if issubclass(o.__class__, gramps.gen.lib.tagbase.TagBase):
            for tag_handle in o.get_tag_list():
                tag = self.database.get_tag_from_handle(tag_handle)
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag name") + " : ")
                self.doc.end_bold()
                self.doc.write_text(tag.get_name())
                self.doc.end_paragraph()
                self.print_object(level + 1, tag)

        if issubclass(o.__class__, gramps.gen.lib.Tag):
            # The tag name is printed by TagBase
            if o.get_color() != "#000000000000" or o.get_priority() != 0:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag colour and priority") + " : ")
                self.doc.end_bold()
                self.doc.write_text(o.get_color() + ", " +
                                    "%d" % o.get_priority())
                self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.urlbase.UrlBase):
            for url in o.get_url_list():
                self.print_header(level,
                                  _("URL"),
                                  type_desc=_("Type"),
                                  obj_type=str(url.get_type()),
                                  privacy=url.get_privacy())
                self.print_object(level + 1, url)

        if isinstance(o, gramps.gen.lib.Url):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark(path, LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

        return o
Example #10
0
    def print_object(self, level, o):

        if issubclass(o.__class__, gramps.gen.lib.address.Address):
            # Details of address are printed by the subclass conditions,
            # primarily by LocationBase, because address is a subclass of
            # LocationBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.addressbase.AddressBase):
            for address in o.get_address_list():
                self.print_header(level, _("Address"), ref=address)
                self.print_object(level+1, address)

        if isinstance(o, gramps.gen.lib.Attribute):
            # The unique information about attributes (the type) is printed by
            # AttributeBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.attrbase.AttributeBase):
            for attribute in o.get_attribute_list():
                self.print_header(level, _("Attribute")+". ",
                                  type_desc=str(attribute.get_type()),
                                  obj_type=attribute.get_value(),
                                  privacy=attribute.get_privacy(),
                                  ref=attribute)
                self.print_object(level+1, attribute)

        if isinstance(o, gramps.gen.lib.ChildRef):
            # The unique information about ChildRef (the father relation and
            # mother relation) is printed by the main write_report function
            pass

        if issubclass(o.__class__, gramps.gen.lib.citationbase.CitationBase):
            if self.print_citations:
                self.print_header(level, "CitationBase tbd")

                for citation_handle in o.get_citation_list():
                    citation = self.database.get_citation_from_handle(
                                                            citation_handle)
                    self.print_object(level+1, citation)

        if isinstance(o, gramps.gen.lib.Citation):
            # the unique information about Citation (the page) is printed by the
            # bibliography code. The other unique information, the confidence is
            # printed here
            if o.get_confidence_level() != gramps.gen.lib.Citation.CONF_NORMAL:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Confidence") + " : ")
                self.doc.end_bold()
                self.doc.write_text(conf_strings.get(o.get_confidence_level(),
                                                     _('Unknown')))
                self.doc.end_paragraph()

            if self.print_citations:
                source_handle = o.get_reference_handle()
                source = self.database.get_source_from_handle(source_handle)
                self.print_object(level+1, source)

        if issubclass(o.__class__, gramps.gen.lib.datebase.DateBase):
            if o.get_date_object() and not o.get_date_object().is_empty():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Date") + " : ")
                self.doc.end_bold()
                self.doc.write_text(displayer.display(o.get_date_object()))
                self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Event):
            # The event type is printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description") + " : ")
            self.doc.end_bold()
            self.doc.write_text(str(o.get_description()))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.eventref.EventRef):
            # The unique information about EventRef (the EventRoleType) is
            # printed by the main write_report function
            event = self.database.get_event_from_handle(o.get_reference_handle())
            self.print_header(level, _("Event"), event.get_gramps_id(),
                              _("Event type"), str(event.get_type()),
                              event.get_privacy(),
                              ref=event)
            self.print_object(level+1, event)

        if isinstance(o, gramps.gen.lib.Family):
            # The unique information about Family (father, mother and children,
            # FamilyRelType and event references) are printed by the main
            # write_report function
            pass

        if isinstance(o, gramps.gen.lib.LdsOrd):
            # The Ordinance type is printed by LdsOrdBase
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Temple and status") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((TEMPLES.name(o.get_temple()),
                                           o.status2str()
                                   )))
            self.doc.end_paragraph()

            f_h = o.get_family_handle()
            if f_h:
                family = self.database.get_family_from_handle(f_h)
                self.print_family_summary(level+1, family,
                                          _("LDS Ordinance family"))

        if issubclass(o.__class__, gramps.gen.lib.ldsordbase.LdsOrdBase):
            for ldsord in o.get_lds_ord_list():
                self.print_header(level, _("LDS "),
                                  type_desc=_("Ordinance"),
                                  obj_type=ldsord.type2str(),
                                  privacy=ldsord.get_privacy(),
                                  ref=ldsord)
                self.print_object(level+1, ldsord)

        if isinstance(o, gramps.gen.lib.Location):
            # The unique information about location (Parish) is printed by
            # Place. Location otherwise serves as a pointer to a LocationBase
            # object
            pass

        if issubclass(o.__class__, gramps.gen.lib.locationbase.LocationBase):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Street, City, County, State, Postal Code, "
                                  "Country, Phone number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((o.get_street(),
                                            o.get_city(),
                                            o.get_county(),
                                            o.get_state(),
                                            o.get_postal_code(),
                                            o.get_country(),
                                            o.get_phone())))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.mediabase.MediaBase):
            for mediaref in o.get_media_list():
                self.print_header(level, _("Media Reference"), ref=mediaref)
                self.print_object(level+1, mediaref)

        if isinstance(o, gramps.gen.lib.MediaObject):
            # thumb is not printed. The mime type is printed by MediaRef
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark("file://:" +
                                 media_path_full(self.database, path),
                                 LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

            mime_type = o.get_mime_type()
            if mime_type and mime_type.startswith("image"):
                filename = media_path_full(self.database, o.get_path())
                if os.path.exists(filename):
                    self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                    self.doc.add_media_object(filename, "single", 4.0, 4.0)
                    self.doc.end_paragraph()
                else:
                    self._user.warn(_("Could not add photo to page"),
                          "%s: %s" % (filename, _('File does not exist')))

        if isinstance(o, gramps.gen.lib.MediaRef):
            mediaobject_handle = o.get_reference_handle()
            mediaobject = self.database.get_object_from_handle(mediaobject_handle)

            if o.get_rectangle():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Referenced Region") + " : ")
                self.doc.end_bold()
                self.doc.write_text(", ".join((("%d" % i) for i in o.get_rectangle())))
                self.doc.end_paragraph()

                mime_type = mediaobject.get_mime_type()
                if mime_type and mime_type.startswith("image"):
                    filename = media_path_full(self.database,
                                               mediaobject.get_path())
                    if os.path.exists(filename):
                        self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                        self.doc.add_media_object(filename, "single", 4.0, 4.0,
                                                  crop=o.get_rectangle()
                                                  )
                        self.doc.end_paragraph()

            desc = get_description(mediaobject.get_mime_type())
            if not desc:
                desc = _("unknown")
            self.print_header(level, _("Media Object"),
                              mediaobject.get_gramps_id(),
                              _("Mime type"),
                              desc,
                              mediaobject.get_privacy(),
                              ref=mediaobject)
            self.print_object(level+1, mediaobject)

        if isinstance(o, gramps.gen.lib.Name):
            # group_as, sort_as and display_as are not printed. NameType is
            # printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Given name(s): Title, Given, Suffix, "
                                  "Call Name, Nick Name, Family Nick Name") +
                                  " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((o.get_title(),
                                           o.get_first_name(),
                                           o.get_suffix(),
                                           o.get_call_name(),
                                           o.get_nick_name(),
                                           o.get_family_nick_name())))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Note):
            # The NoteType is printed by NoteBase. Whether the note is flowed or
            # not is not printed, but affects the way the note appears
            self.doc.write_styled_note(o.get_styledtext(),
                                       o.get_format(),
                                       "PE-Level%d" % min(level, 32),
                                       contains_html = o.get_type()
                                        == gramps.gen.lib.notetype.NoteType.HTML_CODE
                                      )

        if issubclass(o.__class__, gramps.gen.lib.notebase.NoteBase):
            for n_h in o.get_note_list():
                note = self.database.get_note_from_handle(n_h)
                self.print_header(level, _("Note"), note.get_gramps_id(),
                                  _("Note type"), str(note.get_type()),
                                  note.get_privacy())
                self.print_object(level+1, note)

        if issubclass(o.__class__, gramps.gen.lib.Person):
            # This is printed by the main write-report function
            pass

        if isinstance(o, gramps.gen.lib.Place):
            # The title, name, type, code and lat/long are printed by PlaceBase
            for placeref in o.get_placeref_list():
                self.print_header(level, _("Parent Place"))
                self.print_object(level+1, placeref)

#            location = o.get_main_location()
#            if location.get_parish():
#                self.print_header(level, _("Main Location"),
#                                  type_desc=_("Parish"),
#                                  obj_type=location.get_parish())
#            else:
#                self.print_header(level, _("Main Location"))
#
#            self.print_object(level+1, location)
#
            for location in o.get_alternate_locations():
                if location.get_parish():
                    self.print_header(level, _("Alternate Location"),
                                      type_desc=_("Parish"),
                                      obj_type=location.get_parish())
                else:
                    self.print_header(level, _("Alternate Location"))
                self.print_object(level+1, location)

        if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase) or \
            issubclass(o.__class__, gramps.gen.lib.placeref.PlaceRef):
            if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase):
                place_handle = o.get_place_handle()
            else:
                place_handle = o.get_reference_handle()
            place = self.database.get_place_from_handle(place_handle)
            if place:
                place_title = place_displayer.display(self.database, place)
                self.print_header(level, _("Place"), place.get_gramps_id(),
                                  _("Place Title"), place_title,
                                  privacy=place.get_privacy(),
                                  ref=place)
                self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Name") + " : ")
                self.doc.end_bold()
                self.doc.write_text(place.get_name().value)
                self.doc.start_bold()
                self.doc.write_text(" " + _("Type") + " : ")
                self.doc.end_bold()
                self.doc.write_text(str(place.get_type()))
                self.doc.start_bold()
                self.doc.write_text(" " + _("Code") + " : ")
                self.doc.end_bold()
                self.doc.write_text(place.get_code())
                self.doc.end_paragraph()

                for name in place.get_alternative_names():
                    self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
                    self.doc.start_bold()
                    self.doc.write_text(_("Alternative Name") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(name)
                    self.doc.end_paragraph()

                if place.get_longitude() or place.get_latitude():
                    self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
                    self.doc.start_bold()
                    self.doc.write_text(_("Latitude, Longitude") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(", ".join((place.get_longitude(),
                                                   place.get_latitude())))
                    self.doc.end_paragraph()

                self.print_object(level+1, place)

        if issubclass(o.__class__, gramps.gen.lib.primaryobj.BasicPrimaryObject):
            # The Gramps ID is printed by the enclosing object
            pass


        if issubclass(o.__class__, gramps.gen.lib.privacybase.PrivacyBase):
            # The privacy is printed by the enclosing object
            pass

        if isinstance(o, gramps.gen.lib.RepoRef):
            # The media type is printed by source
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Call number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_call_number())
            self.doc.end_paragraph()

            repository_handle = o.get_reference_handle()
            repository = self.database.get_repository_from_handle(repository_handle)
            self.print_header(level, _("Repository"), repository.get_gramps_id(),
                              _("Repository type"), str(repository.get_type()),
                              privacy=repository.get_privacy())
            self.print_object(level+1, repository)

        if isinstance(o, gramps.gen.lib.Repository):
            # the repository type is printed by RepoRef
            pass

        if isinstance(o, gramps.gen.lib.Source):
            # The title, author, abbreviation and publication information are
            # printed by the bibliography code
#            data_map = o.get_data_map()
#            for key in data_map.keys():
#                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
#                self.doc.start_bold()
#                self.doc.write_text(_("Data") + ". " + key + " : ")
#                self.doc.end_bold()
#                self.doc.write_text(data_map[key])
#                self.doc.end_paragraph()

            reporef_list = o.get_reporef_list()
            for reporef in reporef_list:
                self.print_header(level, _("Repository reference"),
                                  type_desc=_("Media type"),
                                  obj_type=str(reporef.get_media_type()),
                                  privacy=reporef.get_privacy())
                self.print_object(level+1, reporef)

        if isinstance(o, gramps.gen.lib.Surname):
            if o.get_origintype():
                self.print_header(level, _("Surname"),
                                  type_desc=_("Origin type"),
                                  obj_type=str(o.get_origintype()))
            else:
                self.print_header(level, _("Surname"),
                                  privacy=o.get_privacy())
            self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Prefix, surname, connector") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((o.get_prefix(), o.get_surname(),
                                           o.get_connector())))
            if o.get_primary():
                self.doc.write_text(" " + _("{This is the primary surname}"))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.surnamebase.SurnameBase):
            surname_list = o.get_surname_list()
            for surname in surname_list:
                self.print_object(level, surname)

        if issubclass(o.__class__, gramps.gen.lib.tagbase.TagBase):
            for tag_handle in o.get_tag_list():
                tag = self.database.get_tag_from_handle(tag_handle)
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag name") + " : ")
                self.doc.end_bold()
                self.doc.write_text(tag.get_name())
                self.doc.end_paragraph()
                self.print_object(level+1, tag)

        if issubclass(o.__class__, gramps.gen.lib.Tag):
            # The tag name is printed by TagBase
            if o.get_color() != "#000000000000" or o.get_priority() != 0:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag colour and priority") + " : ")
                self.doc.end_bold()
                self.doc.write_text(o.get_color() + ", " +
                                    "%d" % o.get_priority())
                self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.urlbase.UrlBase):
            for url in o.get_url_list():
                self.print_header(level, _("URL"),
                                  type_desc=_("Type"),
                                  obj_type=str(url.get_type()),
                                  privacy=url.get_privacy())
                self.print_object(level+1, url)

        if isinstance(o, gramps.gen.lib.Url):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark(path, LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

        return o