def run(database, document, person):
    """
    Display a person's timeline.
    """
    sa = SimpleAccess(database)
    sd = SimpleDoc(document)
    sd.title(_("Timeline for %s") % sa.name(person))
    sd.paragraph("")
    stab = QuickTable(sa)
    stab.columns(_("Date"), _("Event"), _("Age"), _("Place"),
                 _("People involved"))
    stab.set_link_col(4)

    handled = {}
    birth_ref = gramps.gen.lib.Person.get_birth_ref(person)
    birth_date = get_event_date_from_ref(database, birth_ref)
    event_list = []

    process(database, sa, event_list, handled, person, False, person)

    for (event, obj, desc) in sorted(event_list, key=by_date):
        edate = sa.event_date_obj(event)
        span_str, span_int = format_date(birth_date, edate, obj == person)
        if desc == None:
            desc = event
        stab.row(edate, desc, span_str, sa.event_place(event), obj)
        stab.row_sort_val(2, span_int)
    today = Today()
    span_str, span_int = format_date(birth_date, today, False)
    stab.row(today, _("Today"), span_str, "", person)
    stab.row_sort_val(2, span_int)
    stab.write(sd)
    sd.paragraph("")
Пример #2
0
def run(database, document, person):
    """
    Display a person's timeline.
    """
    sa = SimpleAccess(database)
    sd = SimpleDoc(document)
    sd.title(_("Timeline for %s") % sa.name(person))
    sd.paragraph("")
    stab = QuickTable(sa)
    stab.columns(_("Date"), 
                 _("Event"), 
                 _("Age"), 
                 _("Place"), 
                 _("People involved"))
    stab.set_link_col(4)

    handled = {}
    birth_ref = gramps.gen.lib.Person.get_birth_ref(person)
    birth_date = get_event_date_from_ref(database, birth_ref)
    event_list = []

    process(database, sa, event_list, handled, person, False, person)

    for (event, obj, desc) in sorted(event_list, key=by_date):
        edate = sa.event_date_obj(event)
        span_str, span_int = format_date(birth_date, edate, obj == person)
        if desc == None:
            desc = event
        stab.row(edate,
                 desc,
                 span_str,
                 sa.event_place(event),
                 obj)
        stab.row_sort_val(2, span_int)
    today = Today()
    span_str, span_int = format_date(birth_date, today, False)
    stab.row(today, _("Today"), span_str, "", person)
    stab.row_sort_val(2, span_int)
    stab.write(sd)
    sd.paragraph("")
Пример #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, 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("")
Пример #4
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("")