2008-01-03 19:48:18 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
|
|
|
# Copyright (C) 2007-2008 Brian G. Matherly
|
2009-01-04 23:14:33 +05:30
|
|
|
# Copyright (C) 2009 Douglas S. Blank
|
2008-01-03 19:48:18 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
2009-02-16 12:26:49 +05:30
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
#
|
2008-01-03 19:48:18 +05:30
|
|
|
"""
|
|
|
|
Display references for any object
|
|
|
|
"""
|
|
|
|
|
|
|
|
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
2010-01-27 11:36:35 +05:30
|
|
|
from Utils import probably_alive
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2008-01-03 19:48:18 +05:30
|
|
|
import DateHandler
|
|
|
|
import gen.lib
|
2009-10-08 06:42:51 +05:30
|
|
|
import config
|
2008-01-03 19:48:18 +05:30
|
|
|
|
|
|
|
def run(database, document, date):
|
|
|
|
"""
|
|
|
|
Display people probably alive and their ages on a particular date.
|
|
|
|
"""
|
|
|
|
# setup the simple access functions
|
|
|
|
sdb = SimpleAccess(database)
|
|
|
|
sdoc = SimpleDoc(document)
|
2008-04-18 06:39:32 +05:30
|
|
|
stab = SimpleTable(sdb)
|
2008-01-03 19:48:18 +05:30
|
|
|
if not date.get_valid():
|
|
|
|
sdoc.paragraph("Date is not a valid date.")
|
|
|
|
return
|
|
|
|
# display the title
|
2008-03-02 11:42:05 +05:30
|
|
|
if date.get_day_valid():
|
|
|
|
sdoc.title(_("People probably alive and their ages the %s") %
|
|
|
|
DateHandler.displayer.display(date))
|
|
|
|
else:
|
|
|
|
sdoc.title(_("People probably alive and their ages on %s") %
|
2008-01-03 19:48:18 +05:30
|
|
|
DateHandler.displayer.display(date))
|
|
|
|
stab.columns(_("Person"), _("Age")) # Actual Date makes column unicode
|
2008-04-20 09:38:18 +05:30
|
|
|
matches = 0
|
2008-01-03 19:48:18 +05:30
|
|
|
for person in sdb.all_people():
|
2010-01-27 11:36:35 +05:30
|
|
|
alive, birth, death, explain, relative = \
|
|
|
|
probably_alive(person, database, date, return_range=True)
|
|
|
|
# Doesn't show people probably alive but no way of figuring an age:
|
|
|
|
if alive and birth:
|
|
|
|
diff_span = (date - birth)
|
|
|
|
stab.row(person, str(diff_span))
|
|
|
|
stab.row_sort_val(1, int(diff_span))
|
2008-04-20 09:38:18 +05:30
|
|
|
matches += 1
|
2009-10-16 08:50:07 +05:30
|
|
|
|
2009-02-09 21:57:09 +05:30
|
|
|
sdoc.paragraph(_("\n%d matches.\n") % matches)
|
2008-04-18 06:39:32 +05:30
|
|
|
stab.write(sdoc)
|
2008-01-03 19:48:18 +05:30
|
|
|
sdoc.paragraph("")
|
|
|
|
|
|
|
|
def get_event_date_from_ref(database, ref):
|
|
|
|
date = None
|
|
|
|
if ref:
|
|
|
|
handle = ref.get_reference_handle()
|
|
|
|
if handle:
|
|
|
|
event = database.get_event_from_handle(handle)
|
|
|
|
if event:
|
|
|
|
date = event.get_date_object()
|
|
|
|
return date
|