Beispiel #1
0
def run(database, document, object, item, trans):
    """
    Display back-references for this object.
    """

    # setup the simple access functions
    sdb = SimpleAccess(database)
    sdoc = SimpleDoc(document)
    stab = SimpleTable(sdb)

    # display the title
    sdoc.title(_("References for this %s") % trans)
    sdoc.paragraph("\n")
    stab.columns(_("Type"), _("Reference"))
    for (objclass, handle) in database.find_backlink_handles(object.handle):
        ref = get_ref(database, objclass, handle)
        stab.row(_(objclass), ref)  # translation are explicit (above)

    if stab.get_row_count() > 0:
        document.has_data = True
        stab.write(sdoc)
    else:
        document.has_data = False
        sdoc.paragraph(_("No references for this %s") % trans)
        sdoc.paragraph("")
    sdoc.paragraph("")
Beispiel #2
0
def run(database, document, obj):
    """
    Display link references for this note.
    """

    # setup the simple access functions
    sdb = SimpleAccess(database)
    sdoc = SimpleDoc(document)
    stab = SimpleTable(sdb)

    # display the title
    sdoc.title(_("Link References for this note"))
    sdoc.paragraph("\n")
    stab.columns(_("Type"), _("Reference"), _("Link check"))

    tags = obj.text.get_tags()

    for styledtext_tag in tags:
        if int(styledtext_tag.name) == StyledTextTagType.LINK:
            if styledtext_tag.value.startswith("gramps://"):
                object_class, prop, value = styledtext_tag.value[9:].split(
                    "/", 2)
                tagtype = _(object_class)
                ref_obj = sdb.get_link(object_class, prop, value)
                if ref_obj:
                    tagvalue = ref_obj
                    tagcheck = _("Ok")
                else:
                    tagvalue = styledtext_tag.value
                    tagcheck = _("Failed: missing object")
            else:
                tagtype = _("Internet")
                tagvalue = styledtext_tag.value
                tagcheck = ""
            stab.row(tagtype, tagvalue, tagcheck)

    if stab.get_row_count() > 0:
        stab.write(sdoc)
        document.has_data = True
    else:
        sdoc.paragraph(_("No link references for this note"))
        sdoc.paragraph("")
        document.has_data = False
    sdoc.paragraph("")
Beispiel #3
0
def run(database, document, main_event):
    """
    Displays events on a specific date of an event (or date)
    
    Takes an Event or Date object
    """
    if isinstance(main_event, gen.lib.Date):
        main_date = main_event
    else:
        main_date = main_event.get_date_object()

    cal = main_date.get_calendar()

    # setup the simple access functions
    sdb = SimpleAccess(database)
    sdoc = SimpleDoc(document)
    stab = SimpleTable(sdb)
    stab.set_link_col(3)
    yeartab = SimpleTable(sdb)
    yeartab.set_link_col(3)
    histab = SimpleTable(sdb)
    histab.set_link_col(3)

    # display the title
    sdoc.title(_("Events of %(date)s") % {"date": sdb.date_string(main_date)})
    sdoc.paragraph("")
    stab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
    yeartab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
    histab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))

    for event in database.iter_events():
        date = event.get_date_object()
        date.convert_calendar(cal)
        if date.get_year() == 0:
            continue
        if (date.get_year() == main_date.get_year()
                and date.get_month() == main_date.get_month()
                and date.get_day() == main_date.get_day()):
            for (objclass,
                 handle) in database.find_backlink_handles(event.handle):
                ref = get_ref(database, objclass, handle)
                stab.row(date, sdb.event_type(event), sdb.event_place(event),
                         ref)
        elif (date.get_month() == main_date.get_month()
              and date.get_day() == main_date.get_day()
              and date.get_month() != 0):
            for (objclass,
                 handle) in database.find_backlink_handles(event.handle):
                ref = get_ref(database, objclass, handle)
                histab.row(date, sdb.event_type(event), sdb.event_place(event),
                           ref)
        elif (date.get_year() == main_date.get_year()):
            for (objclass,
                 handle) in database.find_backlink_handles(event.handle):
                ref = get_ref(database, objclass, handle)
                yeartab.row(date, sdb.event_type(event),
                            sdb.event_place(event), ref)

    document.has_data = False
    if stab.get_row_count() > 0:
        document.has_data = True
        sdoc.paragraph(_("Events on this exact date"))
        stab.write(sdoc)
    else:
        sdoc.paragraph(_("No events on this exact date"))
        sdoc.paragraph("")
    sdoc.paragraph("")

    if histab.get_row_count() > 0:
        document.has_data = True
        sdoc.paragraph(_("Other events on this month/day in history"))
        histab.write(sdoc)
    else:
        sdoc.paragraph(_("No other events on this month/day in history"))
        sdoc.paragraph("")
    sdoc.paragraph("")

    if yeartab.get_row_count() > 0:
        document.has_data = True
        sdoc.paragraph(
            _("Other events in %(year)d") % {"year": main_date.get_year()})
        yeartab.write(sdoc)
    else:
        sdoc.paragraph(
            _("No other events in %(year)d") % {"year": main_date.get_year()})
        sdoc.paragraph("")
    sdoc.paragraph("")