Пример #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 = QuickTable(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("")
Пример #2
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 = QuickTable(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("")
Пример #3
0
def run(database, document, obj):
    """
    Display link references for this note.
    """

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

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

    for (ldomain, ltype, lprop, lvalue) in obj.get_links():
        if ldomain == "gramps":
            tagtype = _(ltype)
            ref_obj = sdb.get_link(ltype, lprop, lvalue)
            if ref_obj:
                tagvalue = ref_obj
                tagcheck = _("Ok")
            else:
                tagvalue = styledtext_tag.value
                tagcheck = _("Failed: missing object")
        else:
            tagtype = _("Internet")
            tagvalue = lvalue
            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("")
Пример #4
0
def run(database, document, obj):
    """
    Display link references for this note.
    """

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

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

    for (ldomain, ltype, lprop, lvalue) in obj.get_links():
            if ldomain == "gramps":
                tagtype = _(ltype)
                ref_obj = sdb.get_link(ltype, lprop, lvalue)
                if ref_obj:
                    tagvalue = ref_obj
                    tagcheck = _("Ok")
                else:
                    tagvalue = lvalue
                    tagcheck = _("Failed: missing object")
            else:
                tagtype = _("Internet")
                tagvalue = lvalue
                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("")
Пример #5
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, 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 = QuickTable(sdb)
    stab.set_link_col(3)
    yeartab = QuickTable(sdb)
    yeartab.set_link_col(3)
    histab = QuickTable(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("")
Пример #6
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, 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 = QuickTable(sdb)
    stab.set_link_col(3)
    yeartab = QuickTable(sdb)
    yeartab.set_link_col(3)
    histab = QuickTable(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("")
Пример #7
0
def run(database, document, object, item='place', trans=_("Place")):
    """
    Display back-references for this object.
    """

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

    # hold a person-event dictionary
    pedic = defaultdict(list)
    for pe in database.get_person_handles():
        for eventref in database.get_person_from_handle(pe).event_ref_list:
            pedic[eventref.ref].append((eventref.get_role(), pe))
    #for ev in pedic.keys():
    #    print(ev,pedic[ev])

    # display the title
    sdoc.title(_("References for this %s") % trans)
    sdoc.paragraph("\n")
    stab.columns(_("Type"), _("Reference"), _("Date"), _("Persons"))
    


    # get the events
    event_handle_list = [handle for (objclass, handle) in database.find_backlink_handles(object.handle)]
    
    #    ref = get_ref(database, objclass, handle)
    #    #print(ref,pedic[handle])
    #    line=''
    #    for i, (role, personhandle) in enumerate(pedic[handle]):
    #        line = line + ' ' + (
    #                f'{i} {role} {_nd.display(database.get_person_from_handle(personhandle))} '
    #                f'[{database.get_person_from_handle(personhandle).get_gramps_id()}]'
    #                )
    #    e_date = ref.get_date_object()
    #    s_date = ref.get_date_object().get_sort_value()
    #    event_list += [s_date, _(objclass), ref, e_date, line]


    # Sort the events by their date
    event_handle_list.sort(key=lambda x: database.get_event_from_handle(x).get_date_object().get_sort_value())
    print(len(event_handle_list))
    for handle in event_handle_list:
        print(database.get_event_from_handle(handle), pedic[handle], database.get_event_from_handle(handle).get_date_object())

        line=''
        for i, (role, personhandle) in enumerate(pedic[handle]):
            line = line + ' ' + (
                    f'{i} {role} {_nd.display(database.get_person_from_handle(personhandle))} '
                    f'[{database.get_person_from_handle(personhandle).get_gramps_id()}]'
                    )
        stab.row(database.get_event_from_handle(handle).get_description(), database.get_event_from_handle(handle), database.get_event_from_handle(handle).get_date_object(), line)  # translation are explicit (above)

    if stab.get_row_count() > 0:
        document.has_data = True
#        stab.sort(_("Date"))
        stab.write(sdoc)
    else:
        document.has_data = False
        sdoc.paragraph(_("No references for this %s") % trans)
        sdoc.paragraph("")
    sdoc.paragraph("")