2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-05-07 07:50:39 +05:30
|
|
|
# Copyright (C) 2000-2004 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$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"View/Summary of the database"
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import os
|
|
|
|
import posixpath
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import Utils
|
2003-01-10 19:22:32 +05:30
|
|
|
import RelLib
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
from gnome.ui import *
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-05-21 23:36:41 +05:30
|
|
|
# Build the text of the report
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-05-21 23:36:41 +05:30
|
|
|
def build_report(database,person):
|
2003-03-19 09:57:34 +05:30
|
|
|
|
2004-05-07 07:50:39 +05:30
|
|
|
personList = database.get_person_keys()
|
|
|
|
familyList = database.get_family_keys()
|
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
|
|
|
|
bytes = 0
|
|
|
|
namelist = []
|
|
|
|
notfound = []
|
|
|
|
|
2004-05-07 07:50:39 +05:30
|
|
|
pobjects = len(database.get_object_keys())
|
|
|
|
for photo_id in database.get_object_keys():
|
* src/RelLib.py (try_to_find_person_from_id): Remove transaction;
(try_to_find_source_from_id, try_to_find_object_from_id,
try_to_find_place_from_id): Add functions.
* src/plugins/WriteCD.py, src/plugins/WritePkg.py,
src/plugins/WebPage.py, src/plugins/Verify.py,
src/plugins/TimeLine.py, src/plugins/Summary.py,
src/plugins/SoundGen.py, src/plugins/RelGraph.py,
src/plugins/RelCalc.py, src/plugins/PatchNames.py,
src/plugins/Merge.py, src/plugins/IndivSummary.py,
src/plugins/IndivComplete.py, src/plugins/GraphViz.py,
src/plugins/FtmStyleDescendants.py,
src/plugins/FtmStyleAncestors.py, src/plugins/FilterEditor.py,
src/plugins/FanChart.py, src/plugins/FamilyGroup.py,
src/plugins/EventCmp.py, src/plugins/DetDescendantReport.py,
src/plugins/DetAncestralReport.py, src/plugins/DescendReport.py,
src/plugins/Desbrowser.py, src/plugins/CountAncestors.py,
src/plugins/Check.py, src/plugins/ChangeTypes.py,
src/plugins/BookReport.py, src/plugins/Ancestors.py,
src/plugins/AncestorReport.py, src/plugins/AncestorChart.py,
src/plugins/AncestorChart2.py, src/Relationship.py,
src/Sort.py, src/GenericFilter.py, src/SubstKeywords.py,
src/GraphLayout.py: Switch from find_* to try_to_find_* methods.
svn: r3191
2004-05-26 07:35:02 +05:30
|
|
|
photo = database.try_to_find_object_from_id(photo_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
try:
|
2004-02-14 11:10:30 +05:30
|
|
|
bytes = bytes + posixpath.getsize(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-05-07 07:50:39 +05:30
|
|
|
for person_id in personList:
|
2004-06-22 04:52:55 +05:30
|
|
|
person = database.try_to_find_person_from_id(person_id)
|
|
|
|
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
|
|
|
|
|
* src/RelLib.py (try_to_find_person_from_id): Remove transaction;
(try_to_find_source_from_id, try_to_find_object_from_id,
try_to_find_place_from_id): Add functions.
* src/plugins/WriteCD.py, src/plugins/WritePkg.py,
src/plugins/WebPage.py, src/plugins/Verify.py,
src/plugins/TimeLine.py, src/plugins/Summary.py,
src/plugins/SoundGen.py, src/plugins/RelGraph.py,
src/plugins/RelCalc.py, src/plugins/PatchNames.py,
src/plugins/Merge.py, src/plugins/IndivSummary.py,
src/plugins/IndivComplete.py, src/plugins/GraphViz.py,
src/plugins/FtmStyleDescendants.py,
src/plugins/FtmStyleAncestors.py, src/plugins/FilterEditor.py,
src/plugins/FanChart.py, src/plugins/FamilyGroup.py,
src/plugins/EventCmp.py, src/plugins/DetDescendantReport.py,
src/plugins/DetAncestralReport.py, src/plugins/DescendReport.py,
src/plugins/Desbrowser.py, src/plugins/CountAncestors.py,
src/plugins/Check.py, src/plugins/ChangeTypes.py,
src/plugins/BookReport.py, src/plugins/Ancestors.py,
src/plugins/AncestorReport.py, src/plugins/AncestorChart.py,
src/plugins/AncestorChart2.py, src/Relationship.py,
src/Sort.py, src/GenericFilter.py, src/SubstKeywords.py,
src/GraphLayout.py: Switch from find_* to try_to_find_* methods.
svn: r3191
2004-05-26 07:35:02 +05:30
|
|
|
person = database.try_to_find_person_from_id(person_id)
|
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-05-07 07:50:39 +05:30
|
|
|
if (not person.get_main_parents_family_id()) and (not len(person.get_family_id_list())):
|
2002-10-20 19:55:16 +05:30
|
|
|
disconnected = disconnected + 1
|
2004-05-07 07:50:39 +05:30
|
|
|
birth_id = person.get_birth_id()
|
|
|
|
if birth_id:
|
|
|
|
birth = database.find_event_from_id(birth_id)
|
|
|
|
if not birth.get_date():
|
|
|
|
missing_bday = missing_bday + 1
|
|
|
|
else:
|
2002-10-20 19:55:16 +05:30
|
|
|
missing_bday = missing_bday + 1
|
2004-02-14 11:10:30 +05:30
|
|
|
if person.get_gender() == RelLib.Person.female:
|
2002-10-20 19:55:16 +05:30
|
|
|
females = females + 1
|
|
|
|
else:
|
|
|
|
males = males + 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)
|
|
|
|
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
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def report(database,person):
|
|
|
|
|
|
|
|
text = build_report(database,person)
|
|
|
|
|
|
|
|
base = os.path.dirname(__file__)
|
|
|
|
glade_file = "%s/summary.glade" % base
|
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
topDialog = gtk.glade.XML(glade_file,"summary","gramps")
|
2003-05-21 23:36:41 +05:30
|
|
|
topDialog.signal_autoconnect({
|
|
|
|
"destroy_passed_object" : Utils.destroy_passed_object,
|
|
|
|
})
|
|
|
|
|
|
|
|
Utils.set_titles(topDialog.get_widget('summary'),
|
|
|
|
topDialog.get_widget('title'),
|
|
|
|
_('Database summary'))
|
|
|
|
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
top = topDialog.get_widget("summary")
|
|
|
|
textwindow = topDialog.get_widget("textwindow")
|
2002-12-14 10:37:09 +05:30
|
|
|
textwindow.get_buffer().set_text(text)
|
2002-10-20 19:55:16 +05:30
|
|
|
top.show()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from Plugins import register_report
|
|
|
|
|
|
|
|
register_report(
|
|
|
|
report,
|
|
|
|
_("Summary of the database"),
|
|
|
|
status=(_("Beta")),
|
|
|
|
category=_("View"),
|
|
|
|
description=_("Provides a summary of the current database")
|
|
|
|
)
|
|
|
|
|