* src/plugins/soundgen.py: Convert to db.

* src/plugins/GraphViz.py: Typo.
* src/plugins/Verify.py: Convert to db.


svn: r3141
This commit is contained in:
Alex Roitman 2004-05-08 03:29:21 +00:00
parent d5f0618ac1
commit 963ea4c80a
4 changed files with 366 additions and 336 deletions

View File

@ -1,3 +1,8 @@
2004-05-07 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/soundgen.py: Convert to db.
* src/plugins/GraphViz.py: Typo.
* src/plugins/Verify.py: Convert to db.
2004-05-06 Alex Roitman <shura@alex.neuro.umn.edu> 2004-05-06 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/WebPage.py: Clean up conversion to db. * src/plugins/WebPage.py: Clean up conversion to db.
Switch to using Sort function. Switch to using Sort function.

View File

@ -496,7 +496,7 @@ def dump_index(database,person_list,file,includedates,includeurl,colorize,
family_list = person.get_family_id_list() family_list = person.get_family_id_list()
for fam_id in family_list: for fam_id in family_list:
fid = string.replace(fam_id,'-','_') fid = string.replace(fam_id,'-','_')
if fam not_id in families_done: if fam_id not in families_done:
families_done.append(fam_id) families_done.append(fam_id)
file.write('f%s [shape=ellipse, ' % fid) file.write('f%s [shape=ellipse, ' % fid)
marriage = "" marriage = ""

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2003 Donald N. Allingham # Copyright (C) 2000-2004 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -23,6 +23,8 @@
# Modified further to use cStringIO object. # Modified further to use cStringIO object.
# #
# $Id$
"View/Verify" "View/Verify"
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -54,73 +56,76 @@ import Gregorian
from gettext import gettext as _ from gettext import gettext as _
db = None
glade_file = None
verifySettings = None
# returns the year of an event or 0 if no event==None or no year specified in the event
def get_year( event ):
year = 0
if event != None:
dateObj = event.get_date_object()
if dateObj != None:
dateObj = Date.Date(dateObj)
if dateObj.__class__ != Gregorian.Gregorian:
dateObj.set_calendar(Gregorian.Gregorian)
year = dateObj.getYear()
return year
def runTool(database,active_person,callback): def runTool(database,active_person,callback):
global glade_file Verify(database,active_person)
global db
global verifySettings
db = database #-------------------------------------------------------------------------
#
#
#-------------------------------------------------------------------------
class Verify:
def __init__(self,database,active_person):
self.db = database
base = os.path.dirname(__file__) base = os.path.dirname(__file__)
glade_file = base + os.sep + "verify.glade" self.glade_file = base + os.sep + "verify.glade"
verifySettings = gtk.glade.XML(glade_file,"verify_settings","gramps") self.top = gtk.glade.XML(self.glade_file,"verify_settings","gramps")
verifySettings.signal_autoconnect({ self.top.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object, "destroy_passed_object" : Utils.destroy_passed_object,
"on_verify_ok_clicked" : on_apply_clicked "on_verify_ok_clicked" : self.on_apply_clicked
}) })
Utils.set_titles(verifySettings.get_widget('verify_settings'), Utils.set_titles(self.top.get_widget('verify_settings'),
verifySettings.get_widget('title'), self.top.get_widget('title'),
_('Database Verify')) _('Database Verify'))
def on_apply_clicked(obj): def get_year(self,event_id):
global db """
global verifySettings Returns the year of an event (by its id) or 0 if no event_id
or no year specified in the event
"""
year = 0
if event_id:
event = self.db.find_event_from_id(event_id)
dateObj = event.get_date_object()
if dateObj:
if dateObj.get_calendar().NAME != Gregorian.Gregorian:
dateObj.set_calendar(Gregorian.Gregorian)
year = dateObj.get_year()
return year
personList = db.get_person_id_map().values() def on_apply_clicked(self,obj):
oldage = int(verifySettings.get_widget("oldage").get_text()) personList = self.db.get_person_keys()
yngmar = int(verifySettings.get_widget("yngmar").get_text())
oldmar = int(verifySettings.get_widget("oldmar").get_text()) oldage = int(self.top.get_widget("oldage").get_text())
oldmom = int(verifySettings.get_widget("oldmom").get_text()) yngmar = int(self.top.get_widget("yngmar").get_text())
yngmom = int(verifySettings.get_widget("yngmom").get_text()) oldmar = int(self.top.get_widget("oldmar").get_text())
olddad = int(verifySettings.get_widget("olddad").get_text()) oldmom = int(self.top.get_widget("oldmom").get_text())
yngdad = int(verifySettings.get_widget("yngdad").get_text()) yngmom = int(self.top.get_widget("yngmom").get_text())
wedder = int(verifySettings.get_widget("wedder").get_text()) olddad = int(self.top.get_widget("olddad").get_text())
lngwdw = int(verifySettings.get_widget("lngwdw").get_text()) yngdad = int(self.top.get_widget("yngdad").get_text())
estimate_age = verifySettings.get_widget("estimate").get_active() wedder = int(self.top.get_widget("wedder").get_text())
lngwdw = int(self.top.get_widget("lngwdw").get_text())
estimate_age = self.top.get_widget("estimate").get_active()
oldunm = 99 # maximum age at death for unmarried person oldunm = 99 # maximum age at death for unmarried person
error = cStringIO.StringIO() error = cStringIO.StringIO()
warn = cStringIO.StringIO() warn = cStringIO.StringIO()
for person in personList: for person_id in personList:
idstr = person.get_primary_name().get_name() + " (" + person.get_id() + ")" person = self.db.find_person_from_id(person_id)
idstr = "%s (%s)" % (person.get_primary_name().get_name(),person_id)
# individual checks # individual checks
ageatdeath = 0 ageatdeath = 0
byear = get_year( person.get_birth() ) byear = self.get_year( person.get_birth_id() )
bapyear = 0 bapyear = 0
dyear = get_year( person.get_death() ) dyear = self.get_year( person.get_death_id() )
buryear = 0 buryear = 0
if byear>0 and bapyear>0: if byear>0 and bapyear>0:
if byear > bapyear: if byear > bapyear:
@ -240,37 +245,54 @@ def on_apply_clicked(obj):
prev_maryear=0 prev_maryear=0
prev_sdyear=0 prev_sdyear=0
fnum = 0 fnum = 0
for family in person.get_family_id_list(): for family_id in person.get_family_id_list():
family = self.db.find_family_from_id(family_id)
fnum = fnum + 1 fnum = fnum + 1
mother = family.get_mother_id() mother_id = family.get_mother_id()
father = family.get_father_id() father_id = family.get_father_id()
if mother!=None and father!=None: if mother_id:
mother = self.db.find_person_from_id(mother_id)
if father_id:
father = self.db.find_person_from_id(father_id)
if mother_id and father_id:
if ( mother.get_gender() == father.get_gender() ) and mother.get_gender() != RelLib.Person.unknown: if ( mother.get_gender() == father.get_gender() ) and mother.get_gender() != RelLib.Person.unknown:
warn.write( _("Homosexual marriage: %s in family %s.\n") % ( idstr, family.get_id() ) ) warn.write( _("Homosexual marriage: %s in family %s.\n") % ( idstr, family.get_id() ) )
if family.get_father_id() == person and person.get_gender() == RelLib.Person.female: if father_id == person.get_id() and person.get_gender() == RelLib.Person.female:
error.write( _("Female husband: %s in family %s.\n") % ( idstr, family.get_id() ) ) error.write( _("Female husband: %s in family %s.\n") % ( idstr, family.get_id() ) )
if family.get_mother_id() == person and person.get_gender() == RelLib.Person.male: if mother_id == person.get_id() and person.get_gender() == RelLib.Person.male:
error.write( _("Male wife: %s in family %s.\n") % ( idstr, family.get_id() ) ) error.write( _("Male wife: %s in family %s.\n") % ( idstr, family.get_id() ) )
if family.get_father_id() == person: if father_id == person.get_id():
spouse = family.get_mother_id() spouse_id = mother_id
else: else:
spouse = family.get_father_id() spouse_id = father_id
if spouse != None: if spouse_id:
spouse = self.db.find_person_from_id(spouse_id)
if person.get_gender() == RelLib.Person.male and \ if person.get_gender() == RelLib.Person.male and \
person.get_primary_name().get_surname() == spouse.get_primary_name().get_surname(): person.get_primary_name().get_surname() == spouse.get_primary_name().get_surname():
warn.write( _("Husband and wife with the same surname: %s in family %s, and %s.\n") % ( warn.write( _("Husband and wife with the same surname: %s in family %s, and %s.\n") % (
idstr,family.get_id(), spouse.get_primary_name().get_name() ) ) idstr,family.get_id(), spouse.get_primary_name().get_name() ) )
sdyear = get_year( spouse.get_death() ) sdyear = self.get_year( spouse.get_death_id() )
if sdyear == 0: if sdyear == 0:
sdyear = 0 # burial year sdyear = 0 # burial year
maryear = get_year( family.get_marriage() )
for event_id in family.get_event_list():
if event_id:
event = self.db.find_event_from_id(event_id)
if event.get_name() == "Marriage":
marriage_id = event_id
break
else:
marriage_id = None
maryear = self.get_year( marriage_id )
if maryear == 0 and estimate_age: # estimate marriage year if maryear == 0 and estimate_age: # estimate marriage year
cnum=0 cnum=0
for child in family.get_child_id_list(): for child_id in family.get_child_id_list():
cnum = cnum + 1 cnum = cnum + 1
if maryear == 0: if maryear == 0:
birthyear = get_year( child.get_birth() ) child = self.db.find_person_from_id(child_id)
birthyear = self.get_year( child.get_birth_id() )
if birthyear > 0: if birthyear > 0:
maryear = birthyear-cnum maryear = birthyear-cnum
@ -334,13 +356,15 @@ def on_apply_clicked(obj):
warn.write( _("Long widowhood: %s was a widow %d years.\n") % (idstr, wdwyear) ) warn.write( _("Long widowhood: %s was a widow %d years.\n") % (idstr, wdwyear) )
nkids = 0 nkids = 0
for child in family.get_child_id_list(): for child_id in family.get_child_id_list():
nkids = nkids+1 nkids = nkids+1
cbyear = get_year( child.get_birth() ) child = self.db.find_person_from_id(child_id)
cbyear = self.get_year( child.get_birth_id() )
if cbyear>0 and cbyear < first_cbyear: if cbyear>0 and cbyear < first_cbyear:
first_cbyear = cbyear first_cbyear = cbyear
if cbyear>last_cbyear: if cbyear>last_cbyear:
last_cbyear = cbyear last_cbyear = cbyear
# parentage checks # parentage checks
if byear>0 and cbyear>0: if byear>0 and cbyear>0:
bage = cbyear - byear bage = cbyear - byear
@ -384,26 +408,27 @@ def on_apply_clicked(obj):
text = "" text = ""
if error != "": if error:
text = _("ERRORS:\n") + error.getvalue() + "\n" text = _("ERRORS:\n") + error.getvalue() + "\n"
if warn != "": if warn:
text = _("WARNINGS:\n") + warn.getvalue() text = _("WARNINGS:\n") + warn.getvalue()
error.close() error.close()
warn.close() warn.close()
verifyResult = gtk.glade.XML(glade_file,"verify_result","gramps") top = gtk.glade.XML(self.glade_file,"verify_result","gramps")
Utils.set_titles(verifyResult.get_widget('verify_result'), Utils.set_titles(top.get_widget('verify_result'),
verifyResult.get_widget('title'), top.get_widget('title'),
_('Database Verify')) _('Database Verify'))
verifyResult.signal_autoconnect({ top.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object, "destroy_passed_object" : Utils.destroy_passed_object,
}) })
top = verifyResult.get_widget("verify_result")
textwindow = verifyResult.get_widget("textwindow") topwin = top.get_widget("verify_result")
textwindow = top.get_widget("textwindow")
textwindow.get_buffer().set_text(text) textwindow.get_buffer().set_text(text)
top.show() topwin.show()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -418,4 +443,3 @@ register_tool(
category=_("Utilities"), category=_("Utilities"),
description=_("Lists exceptions to assertions or checks about the database") description=_("Lists exceptions to assertions or checks about the database")
) )

View File

@ -63,7 +63,8 @@ class SoundGen:
self.name.connect('changed',self.on_apply_clicked) self.name.connect('changed',self.on_apply_clicked)
names = [] names = []
for person in self.db.get_person_id_map().values(): for person_id in self.db.get_person_keys():
person = self.db.find_person_from_id(person_id)
lastname = person.get_primary_name().get_surname() lastname = person.get_primary_name().get_surname()
if lastname not in names: if lastname not in names:
names.append(lastname) names.append(lastname)