2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-10 02:19:29 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2002-10-20 19:55:16 +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
|
|
|
|
#
|
|
|
|
|
2004-05-07 07:50:39 +05:30
|
|
|
# $Id$
|
|
|
|
|
2008-01-29 13:10:35 +05:30
|
|
|
"""Reports/View/Summary of the Database"""
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import os
|
|
|
|
import posixpath
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2005-01-03 05:18:39 +05:30
|
|
|
# GNOME/GTK modules
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-02-19 01:37:09 +05:30
|
|
|
from gtk import glade
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2005-01-03 05:18:39 +05:30
|
|
|
# GRAMPS modules
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2006-06-01 10:09:40 +05:30
|
|
|
from PluginUtils import register_report
|
2008-02-18 19:36:41 +05:30
|
|
|
from Utils import media_path_full
|
2006-06-02 06:10:54 +05:30
|
|
|
from ReportBase import CATEGORY_VIEW, MODE_GUI
|
2005-08-06 08:27:37 +05:30
|
|
|
import DateHandler
|
2006-06-02 06:10:54 +05:30
|
|
|
import ManagedWindow
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-05-21 23:36:41 +05:30
|
|
|
# Build the text of the report
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-02-20 10:37:43 +05:30
|
|
|
def build_report(database):
|
2003-03-19 09:57:34 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
personList = database.get_person_handles(sort_handles=False)
|
|
|
|
familyList = database.get_family_handles()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
with_photos = 0
|
|
|
|
total_photos = 0
|
|
|
|
incomp_names = 0
|
|
|
|
disconnected = 0
|
|
|
|
missing_bday = 0
|
|
|
|
males = 0
|
|
|
|
females = 0
|
2007-07-24 09:39:35 +05:30
|
|
|
unknowns = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
bytes = 0
|
|
|
|
namelist = []
|
|
|
|
notfound = []
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
pobjects = len(database.get_media_object_handles())
|
|
|
|
for photo_id in database.get_media_object_handles():
|
2004-08-07 10:46:57 +05:30
|
|
|
photo = database.get_object_from_handle(photo_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
try:
|
2008-02-18 19:36:41 +05:30
|
|
|
bytes = bytes + posixpath.getsize(media_path_full(database,
|
|
|
|
photo.get_path()))
|
2002-10-20 19:55:16 +05:30
|
|
|
except:
|
2004-02-14 11:10:30 +05:30
|
|
|
notfound.append(photo.get_path())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in personList:
|
2004-08-07 10:46:57 +05:30
|
|
|
person = database.get_person_from_handle(person_handle)
|
2004-06-22 04:54:51 +05:30
|
|
|
if not person:
|
|
|
|
continue
|
|
|
|
length = len(person.get_media_list())
|
2002-10-20 19:55:16 +05:30
|
|
|
if length > 0:
|
|
|
|
with_photos = with_photos + 1
|
|
|
|
total_photos = total_photos + length
|
|
|
|
|
2004-08-07 10:46:57 +05:30
|
|
|
person = database.get_person_from_handle(person_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
name = person.get_primary_name()
|
|
|
|
if name.get_first_name() == "" or name.get_surname() == "":
|
2002-10-20 19:55:16 +05:30
|
|
|
incomp_names = incomp_names + 1
|
2004-07-28 07:59:07 +05:30
|
|
|
if (not person.get_main_parents_family_handle()) and (not len(person.get_family_handle_list())):
|
2002-10-20 19:55:16 +05:30
|
|
|
disconnected = disconnected + 1
|
2006-03-30 10:45:54 +05:30
|
|
|
birth_ref = person.get_birth_ref()
|
|
|
|
if birth_ref:
|
|
|
|
birth = database.get_event_from_handle(birth_ref.ref)
|
2005-08-06 08:27:37 +05:30
|
|
|
if not DateHandler.get_date(birth):
|
2004-05-07 07:50:39 +05:30
|
|
|
missing_bday = missing_bday + 1
|
|
|
|
else:
|
2002-10-20 19:55:16 +05:30
|
|
|
missing_bday = missing_bday + 1
|
2007-10-08 22:11:39 +05:30
|
|
|
if person.get_gender() == gen.lib.Person.FEMALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
females = females + 1
|
2007-10-08 22:11:39 +05:30
|
|
|
elif person.get_gender() == gen.lib.Person.MALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
males = males + 1
|
2007-07-24 09:39:35 +05:30
|
|
|
else:
|
|
|
|
unknowns += 1
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_surname() not in namelist:
|
|
|
|
namelist.append(name.get_surname())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
text = _("Individuals") + "\n"
|
|
|
|
text = text + "----------------------------\n"
|
2003-03-19 09:57:34 +05:30
|
|
|
text = text + "%s: %d\n" % (_("Number of individuals"),len(personList))
|
|
|
|
text = text + "%s: %d\n" % (_("Males"),males)
|
|
|
|
text = text + "%s: %d\n" % (_("Females"),females)
|
2007-07-24 09:39:35 +05:30
|
|
|
text = text + "%s: %d\n" % (_("Individuals with unknown gender"),unknowns)
|
2003-03-19 09:57:34 +05:30
|
|
|
text = text + "%s: %d\n" % (_("Individuals with incomplete names"),incomp_names)
|
|
|
|
text = text + "%s: %d\n" % (_("Individuals missing birth dates"),missing_bday)
|
|
|
|
text = text + "%s: %d\n" % (_("Disconnected individuals"),disconnected)
|
2002-10-20 19:55:16 +05:30
|
|
|
text = text + "\n%s\n" % _("Family Information")
|
|
|
|
text = text + "----------------------------\n"
|
2003-03-19 09:57:34 +05:30
|
|
|
text = text + "%s: %d\n" % (_("Number of families"),len(familyList))
|
|
|
|
text = text + "%s: %d\n" % (_("Unique surnames"),len(namelist))
|
2002-10-20 19:55:16 +05:30
|
|
|
text = text + "\n%s\n" % _("Media Objects")
|
|
|
|
text = text + "----------------------------\n"
|
2003-03-19 09:57:34 +05:30
|
|
|
text = text + "%s: %d\n" % (_("Individuals with media objects"),with_photos)
|
|
|
|
text = text + "%s: %d\n" % (_("Total number of media object references"),total_photos)
|
|
|
|
text = text + "%s: %d\n" % (_("Number of unique media objects"),pobjects)
|
|
|
|
text = text + "%s: %d %s\n" % (_("Total size of media objects"),bytes,\
|
2002-10-20 19:55:16 +05:30
|
|
|
_("bytes"))
|
|
|
|
|
|
|
|
if len(notfound) > 0:
|
|
|
|
text = text + "\n%s\n" % _("Missing Media Objects")
|
|
|
|
text = text + "----------------------------\n"
|
|
|
|
for p in notfound:
|
|
|
|
text = text + "%s\n" % p
|
|
|
|
|
2003-05-21 23:36:41 +05:30
|
|
|
return text
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Output report in a window
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-06-02 06:10:54 +05:30
|
|
|
class SummaryReport(ManagedWindow.ManagedWindow):
|
2008-02-20 10:37:43 +05:30
|
|
|
def __init__(self, dbstate, uistate):
|
2006-06-02 06:10:54 +05:30
|
|
|
self.title = _('Database summary')
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
|
|
|
|
|
|
|
database = dbstate.db
|
2008-02-20 10:37:43 +05:30
|
|
|
text = build_report(database)
|
2003-05-21 23:36:41 +05:30
|
|
|
|
2005-01-03 05:18:39 +05:30
|
|
|
base = os.path.dirname(__file__)
|
|
|
|
glade_file = "%s/summary.glade" % base
|
2003-05-21 23:36:41 +05:30
|
|
|
|
2008-02-19 01:37:09 +05:30
|
|
|
topDialog = glade.XML(glade_file,"summary","gramps")
|
2005-01-03 05:18:39 +05:30
|
|
|
topDialog.signal_autoconnect({
|
2006-06-02 06:10:54 +05:30
|
|
|
"destroy_passed_object" : self.close,
|
2005-01-03 05:18:39 +05:30
|
|
|
})
|
2003-05-21 23:36:41 +05:30
|
|
|
|
2006-06-02 06:10:54 +05:30
|
|
|
window = topDialog.get_widget("summary")
|
|
|
|
self.set_window(window,topDialog.get_widget('title'),self.title)
|
2005-01-03 05:18:39 +05:30
|
|
|
textwindow = topDialog.get_widget("textwindow")
|
|
|
|
textwindow.get_buffer().set_text(text)
|
2006-06-02 06:10:54 +05:30
|
|
|
self.show()
|
|
|
|
|
|
|
|
def build_menu_names(self,obj):
|
|
|
|
return (self.title,None)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
register_report(
|
2005-01-03 05:18:39 +05:30
|
|
|
name = 'summary',
|
2006-06-01 10:09:40 +05:30
|
|
|
category = CATEGORY_VIEW,
|
2005-01-03 05:18:39 +05:30
|
|
|
report_class = SummaryReport,
|
|
|
|
options_class = None,
|
2006-06-01 10:09:40 +05:30
|
|
|
modes = MODE_GUI,
|
2008-01-29 02:52:06 +05:30
|
|
|
translated_name = _("Summary of the Database"),
|
2005-01-03 05:18:39 +05:30
|
|
|
status = _("Beta"),
|
|
|
|
description= _("Provides a summary of the current database"),
|
2006-06-17 02:56:44 +05:30
|
|
|
require_active=False,
|
2002-10-20 19:55:16 +05:30
|
|
|
)
|