* 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,356 +56,379 @@ 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())
oldmom = int(verifySettings.get_widget("oldmom").get_text())
yngmom = int(verifySettings.get_widget("yngmom").get_text())
olddad = int(verifySettings.get_widget("olddad").get_text())
yngdad = int(verifySettings.get_widget("yngdad").get_text())
wedder = int(verifySettings.get_widget("wedder").get_text())
lngwdw = int(verifySettings.get_widget("lngwdw").get_text())
estimate_age = verifySettings.get_widget("estimate").get_active()
oldunm = 99 # maximum age at death for unmarried person oldage = int(self.top.get_widget("oldage").get_text())
yngmar = int(self.top.get_widget("yngmar").get_text())
oldmar = int(self.top.get_widget("oldmar").get_text())
oldmom = int(self.top.get_widget("oldmom").get_text())
yngmom = int(self.top.get_widget("yngmom").get_text())
olddad = int(self.top.get_widget("olddad").get_text())
yngdad = int(self.top.get_widget("yngdad").get_text())
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()
error = cStringIO.StringIO() oldunm = 99 # maximum age at death for unmarried person
warn = cStringIO.StringIO()
for person in personList: error = cStringIO.StringIO()
idstr = person.get_primary_name().get_name() + " (" + person.get_id() + ")" warn = cStringIO.StringIO()
# individual checks for person_id in personList:
ageatdeath = 0 person = self.db.find_person_from_id(person_id)
byear = get_year( person.get_birth() ) idstr = "%s (%s)" % (person.get_primary_name().get_name(),person_id)
bapyear = 0
dyear = get_year( person.get_death() ) # individual checks
buryear = 0
if byear>0 and bapyear>0:
if byear > bapyear:
if person.get_gender() == RelLib.Person.male:
error.write( _("Baptized before birth: %(male_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Baptized before birth: %(female_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if byear < bapyear:
if person.get_gender() == RelLib.Person.male:
warn.write( _("Baptized late: %(male_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Baptized late: %(female_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if dyear>0 and buryear>0:
if dyear > buryear:
if person.get_gender() == RelLib.Person.male:
error.write( _("Buried before death: %(male_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Buried before death: %(female_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if dyear < buryear:
if person.get_gender() == RelLib.Person.male:
warn.write( _("Buried late: %(male_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Buried late: %(female_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if dyear>0 and (byear>dyear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Died before birth: %(male_name)s born %(byear)d, died %(dyear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'dyear' : dyear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Died before birth: %(female_name)s born %(byear)d, died %(dyear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'dyear' : dyear } )
if dyear>0 and (bapyear>dyear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Died before baptism: %(male_name)s baptized %(bapyear)d, died %(dyear)d.\n") % {
'male_name' : idstr, 'bapyear' : bapyear, 'dyear' : dyear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Died before baptism: %(female_name)s baptized %(bapyear)d, died %(dyear)d.\n") % {
'female_name' : idstr, 'bapyear' : bapyear, 'dyear' : dyear } )
if buryear>0 and (byear>buryear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Buried before birth: %(male_name)s born %(byear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Buried before birth: %(female_name)s born %(byear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'buryear' : buryear } )
if buryear>0 and (bapyear>buryear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Buried before baptism: %(male_name)s baptized %(bapyear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'bapyear' : bapyear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Buried before baptism: %(female_name)s baptized %(bapyear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'bapyear' : bapyear, 'buryear' : buryear } )
if byear == 0 and estimate_age:
byear = bapyear # guess baptism = birth
if dyear == 0 and estimate_age:
dyear = buryear # guess burial = death
if byear>0 and dyear>0:
ageatdeath = dyear - byear
else:
ageatdeath = 0 ageatdeath = 0
if ageatdeath > oldage: byear = self.get_year( person.get_birth_id() )
if person.get_gender() == RelLib.Person.male: bapyear = 0
warn.write( _("Old age: %(male_name)s born %(byear)d, died %(dyear)d, at the age of %(ageatdeath)d.\n") % { dyear = self.get_year( person.get_death_id() )
'male_name' : idstr, 'byear' : byear, 'dyear' : dyear, 'ageatdeath' : ageatdeath } ) buryear = 0
if byear>0 and bapyear>0:
if byear > bapyear:
if person.get_gender() == RelLib.Person.male:
error.write( _("Baptized before birth: %(male_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Baptized before birth: %(female_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if byear < bapyear:
if person.get_gender() == RelLib.Person.male:
warn.write( _("Baptized late: %(male_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Baptized late: %(female_name)s born %(byear)d, baptized %(bapyear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'bapyear' : bapyear } )
if dyear>0 and buryear>0:
if dyear > buryear:
if person.get_gender() == RelLib.Person.male:
error.write( _("Buried before death: %(male_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Buried before death: %(female_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if dyear < buryear:
if person.get_gender() == RelLib.Person.male:
warn.write( _("Buried late: %(male_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Buried late: %(female_name)s died %(dyear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'dyear' : dyear, 'buryear' : buryear } )
if dyear>0 and (byear>dyear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Died before birth: %(male_name)s born %(byear)d, died %(dyear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'dyear' : dyear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Died before birth: %(female_name)s born %(byear)d, died %(dyear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'dyear' : dyear } )
if dyear>0 and (bapyear>dyear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Died before baptism: %(male_name)s baptized %(bapyear)d, died %(dyear)d.\n") % {
'male_name' : idstr, 'bapyear' : bapyear, 'dyear' : dyear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Died before baptism: %(female_name)s baptized %(bapyear)d, died %(dyear)d.\n") % {
'female_name' : idstr, 'bapyear' : bapyear, 'dyear' : dyear } )
if buryear>0 and (byear>buryear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Buried before birth: %(male_name)s born %(byear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Buried before birth: %(female_name)s born %(byear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'buryear' : buryear } )
if buryear>0 and (bapyear>buryear):
if person.get_gender() == RelLib.Person.male:
error.write( _("Buried before baptism: %(male_name)s baptized %(bapyear)d, buried %(buryear)d.\n") % {
'male_name' : idstr, 'bapyear' : bapyear, 'buryear' : buryear } )
if person.get_gender() == RelLib.Person.female:
error.write( _("Buried before baptism: %(female_name)s baptized %(bapyear)d, buried %(buryear)d.\n") % {
'female_name' : idstr, 'bapyear' : bapyear, 'buryear' : buryear } )
if byear == 0 and estimate_age:
byear = bapyear # guess baptism = birth
if dyear == 0 and estimate_age:
dyear = buryear # guess burial = death
if byear>0 and dyear>0:
ageatdeath = dyear - byear
else:
ageatdeath = 0
if ageatdeath > oldage:
if person.get_gender() == RelLib.Person.male:
warn.write( _("Old age: %(male_name)s born %(byear)d, died %(dyear)d, at the age of %(ageatdeath)d.\n") % {
'male_name' : idstr, 'byear' : byear, 'dyear' : dyear, 'ageatdeath' : ageatdeath } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Old age: %(female_name)s born %(byear)d, died %(dyear)d, at the age of %(ageatdeath)d.\n") % {
'female_name' : idstr, 'byear' : byear, 'dyear' : dyear, 'ageatdeath' : ageatdeath } )
# gender checks
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
warn.write( _("Old age: %(female_name)s born %(byear)d, died %(dyear)d, at the age of %(ageatdeath)d.\n") % { oldpar = oldmom
'female_name' : idstr, 'byear' : byear, 'dyear' : dyear, 'ageatdeath' : ageatdeath } ) yngpar = yngmom
if person.get_gender() == RelLib.Person.male:
oldpar = olddad
yngpar = yngdad
if (person.get_gender() != RelLib.Person.female) and (person.get_gender() != RelLib.Person.male):
warn.write( _("Unknown gender for %s.\n") % idstr )
oldpar = olddad
yngpar = yngdad
if (person.get_gender() == RelLib.Person.female) and (person.get_gender() == RelLib.Person.male):
error.write( _("Ambiguous gender for %s.\n") % idstr )
oldpar = olddad
yngpar = yngdad
# gender checks # multiple parentage check
if( len( person.get_parent_family_id_list() ) > 1 ):
warn.write( _("Multiple parentage for %s.\n") % idstr )
if person.get_gender() == RelLib.Person.female: # marriage checks
oldpar = oldmom nkids = 0
yngpar = yngmom nfam = len( person.get_family_id_list() )
if person.get_gender() == RelLib.Person.male: if nfam > wedder:
oldpar = olddad if person.get_gender() == RelLib.Person.male:
yngpar = yngdad warn.write( _("Married often: %(male_name)s married %(nfam)d times.\n") % {
if (person.get_gender() != RelLib.Person.female) and (person.get_gender() != RelLib.Person.male): 'male_name' : idstr, 'nfam' : nfam } )
warn.write( _("Unknown gender for %s.\n") % idstr ) if person.get_gender() == RelLib.Person.female:
oldpar = olddad warn.write( _("Married often: %(female_name)s married %(nfam)d times.\n") % {
yngpar = yngdad 'female_name' : idstr, 'nfam' : nfam } )
if (person.get_gender() == RelLib.Person.female) and (person.get_gender() == RelLib.Person.male): if ageatdeath>oldunm and nfam == 0:
error.write( _("Ambiguous gender for %s.\n") % idstr ) if person.get_gender() == RelLib.Person.male:
oldpar = olddad warn.write( _("Old and unmarried: %(male_name)s died unmarried, at the age of %(ageatdeath)d years.\n") % {
yngpar = yngdad 'male_name' : idstr, 'ageatdeath' : ageatdeath } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Old and unmarried: %(female_name)s died unmarried, at the age of %(ageatdeath)d years.\n") % {
'female_name' : idstr, 'ageatdeath' : ageatdeath } )
first_cbyear = 99999
last_cbyear=0
prev_cbyear=0
prev_maryear=0
prev_sdyear=0
fnum = 0
for family_id in person.get_family_id_list():
family = self.db.find_family_from_id(family_id)
fnum = fnum + 1
mother_id = family.get_mother_id()
father_id = family.get_father_id()
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:
warn.write( _("Homosexual marriage: %s in family %s.\n") % ( idstr, family.get_id() ) )
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() ) )
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() ) )
if father_id == person.get_id():
spouse_id = mother_id
else:
spouse_id = father_id
if spouse_id:
spouse = self.db.find_person_from_id(spouse_id)
if person.get_gender() == RelLib.Person.male and \
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") % (
idstr,family.get_id(), spouse.get_primary_name().get_name() ) )
sdyear = self.get_year( spouse.get_death_id() )
if sdyear == 0:
sdyear = 0 # burial year
# multiple parentage check for event_id in family.get_event_list():
if( len( person.get_parent_family_id_list() ) > 1 ): if event_id:
warn.write( _("Multiple parentage for %s.\n") % idstr ) event = self.db.find_event_from_id(event_id)
if event.get_name() == "Marriage":
marriage_id = event_id
break
else:
marriage_id = None
# marriage checks maryear = self.get_year( marriage_id )
nkids = 0
nfam = len( person.get_family_id_list() )
if nfam > wedder:
if person.get_gender() == RelLib.Person.male:
warn.write( _("Married often: %(male_name)s married %(nfam)d times.\n") % {
'male_name' : idstr, 'nfam' : nfam } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Married often: %(female_name)s married %(nfam)d times.\n") % {
'female_name' : idstr, 'nfam' : nfam } )
if ageatdeath>oldunm and nfam == 0:
if person.get_gender() == RelLib.Person.male:
warn.write( _("Old and unmarried: %(male_name)s died unmarried, at the age of %(ageatdeath)d years.\n") % {
'male_name' : idstr, 'ageatdeath' : ageatdeath } )
if person.get_gender() == RelLib.Person.female:
warn.write( _("Old and unmarried: %(female_name)s died unmarried, at the age of %(ageatdeath)d years.\n") % {
'female_name' : idstr, 'ageatdeath' : ageatdeath } )
first_cbyear = 99999
last_cbyear=0
prev_cbyear=0
prev_maryear=0
prev_sdyear=0
fnum = 0
for family in person.get_family_id_list():
fnum = fnum + 1
mother = family.get_mother_id()
father = family.get_father_id()
if mother!=None and father!=None:
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() ) )
if family.get_father_id() == person and person.get_gender() == RelLib.Person.female:
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:
error.write( _("Male wife: %s in family %s.\n") % ( idstr, family.get_id() ) )
if family.get_father_id() == person:
spouse = family.get_mother_id()
else:
spouse = family.get_father_id()
if spouse != None:
if person.get_gender() == RelLib.Person.male and \
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") % (
idstr,family.get_id(), spouse.get_primary_name().get_name() ) )
sdyear = get_year( spouse.get_death() )
if sdyear == 0:
sdyear = 0 # burial year
maryear = get_year( family.get_marriage() )
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)
if birthyear > 0: birthyear = self.get_year( child.get_birth_id() )
maryear = birthyear-cnum if birthyear > 0:
maryear = birthyear-cnum
if maryear > 0: if maryear > 0:
if byear > 0: if byear > 0:
marage = maryear - byear marage = maryear - byear
if marage < 0: if marage < 0:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
error.write( _("Married before birth: %(male_name)s born %(byear)d, married %(maryear)d to %(spouse)s.\n") % { error.write( _("Married before birth: %(male_name)s born %(byear)d, married %(maryear)d to %(spouse)s.\n") % {
'male_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) 'male_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } )
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
error.write( _("Married before birth: %(female_name)s born %(byear)d, married %(maryear)d to %(spouse)s.\n") % { error.write( _("Married before birth: %(female_name)s born %(byear)d, married %(maryear)d to %(spouse)s.\n") % {
'female_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) 'female_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } )
else: else:
if marage < yngmar: if marage < yngmar:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
warn.write( _("Young marriage: %(male_name)s married at age %(marage)d to %(spouse)s.\n") % { warn.write( _("Young marriage: %(male_name)s married at age %(marage)d to %(spouse)s.\n") % {
'male_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } ) 'male_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } )
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
warn.write( _("Young marriage: %(female_name)s married at age %(marage)d to %(spouse)s.\n") % { warn.write( _("Young marriage: %(female_name)s married at age %(marage)d to %(spouse)s.\n") % {
'female_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } ) 'female_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } )
if marage > oldmar: if marage > oldmar:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
warn.write( _("Old marriage: %(male_name)s married at age %(marage)d to %(spouse)s.\n") % { warn.write( _("Old marriage: %(male_name)s married at age %(marage)d to %(spouse)s.\n") % {
'male_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } ) 'male_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } )
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
warn.write( _("Old marriage: %(female_name)s married at age %(marage)d to %(spouse)s.\n") % { warn.write( _("Old marriage: %(female_name)s married at age %(marage)d to %(spouse)s.\n") % {
'female_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } ) 'female_name' : idstr, 'marage' : marage, 'spouse' : spouse.get_primary_name().get_name() } )
if dyear>0 and maryear > dyear: if dyear>0 and maryear > dyear:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
error.write( _("Married after death: %(male_name)s died %(dyear)d, married %(maryear)d to %(spouse)s.\n") % { error.write( _("Married after death: %(male_name)s died %(dyear)d, married %(maryear)d to %(spouse)s.\n") % {
'male_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) 'male_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } )
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
error.write( _("Married after death: %(female_name)s died %(dyear)d, married %(maryear)d to %(spouse)s.\n") % { error.write( _("Married after death: %(female_name)s died %(dyear)d, married %(maryear)d to %(spouse)s.\n") % {
'female_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) 'female_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } )
if prev_cbyear > maryear: if prev_cbyear > maryear:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
warn.write( _("Marriage before birth from previous family: %(male_name)s married %(maryear)d to %(spouse)s, previous birth %(prev_cbyear)d.\n") % { warn.write( _("Marriage before birth from previous family: %(male_name)s married %(maryear)d to %(spouse)s, previous birth %(prev_cbyear)d.\n") % {
'male_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } ) 'male_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } )
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
warn.write( _("Marriage before birth from previous family: %(female_name)s married %(maryear)d to %(spouse)s, previous birth %(prev_cbyear)d.\n") % { warn.write( _("Marriage before birth from previous family: %(female_name)s married %(maryear)d to %(spouse)s, previous birth %(prev_cbyear)d.\n") % {
'female_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } ) 'female_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } )
prev_maryear = maryear prev_maryear = maryear
else: else:
maryear = prev_maryear maryear = prev_maryear
if maryear>0 and prev_sdyear > 0: if maryear>0 and prev_sdyear > 0:
wdwyear = maryear-prev_sdyear wdwyear = maryear-prev_sdyear
if wdwyear > lngwdw: if wdwyear > lngwdw:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
warn.write( _("Long widowhood: %s was a widower %d years before, family %s.\n") % (idstr, wdwyear, family.get_id() ) ) warn.write( _("Long widowhood: %s was a widower %d years before, family %s.\n") % (idstr, wdwyear, family.get_id() ) )
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
warn.write( _("Long widowhood: %s was a widow %d years before, family %s.\n") % (idstr, wdwyear, family.get_id() ) ) warn.write( _("Long widowhood: %s was a widow %d years before, family %s.\n") % (idstr, wdwyear, family.get_id() ) )
if fnum==nfam and dyear>0 and sdyear>0: if fnum==nfam and dyear>0 and sdyear>0:
wdwyear = dyear - sdyear wdwyear = dyear - sdyear
if wdwyear > lngwdw: if wdwyear > lngwdw:
if person.get_gender() == RelLib.Person.male: if person.get_gender() == RelLib.Person.male:
warn.write( _("Long widowhood: %s was a widower %d years.\n") % (idstr, wdwyear) ) warn.write( _("Long widowhood: %s was a widower %d years.\n") % (idstr, wdwyear) )
if person.get_gender() == RelLib.Person.female: if person.get_gender() == RelLib.Person.female:
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)
if cbyear>0 and cbyear < first_cbyear: cbyear = self.get_year( child.get_birth_id() )
first_cbyear = cbyear if cbyear>0 and cbyear < first_cbyear:
if cbyear>last_cbyear: first_cbyear = cbyear
last_cbyear = cbyear if cbyear>last_cbyear:
# parentage checks last_cbyear = cbyear
if byear>0 and cbyear>0:
bage = cbyear - byear # parentage checks
if bage > oldpar: if byear>0 and cbyear>0:
if person.get_gender() == RelLib.Person.male: bage = cbyear - byear
warn.write( _("Old father: %(male_name)s at age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { if bage > oldpar:
'male_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) if person.get_gender() == RelLib.Person.male:
if person.get_gender() == RelLib.Person.female: warn.write( _("Old father: %(male_name)s at age of %(bage)d in family %(fam)s had a child %(child)s.\n") % {
warn.write( _("Old mother: %(female_name)s at age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { 'male_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } )
'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) if person.get_gender() == RelLib.Person.female:
if bage < 0: warn.write( _("Old mother: %(female_name)s at age of %(bage)d in family %(fam)s had a child %(child)s.\n") % {
if person.get_gender() == RelLib.Person.male: 'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } )
error.write( _("Unborn father: %(male_name)s born %(byear)d, in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { if bage < 0:
'male_name' : idstr, 'byear' : byear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear } ) if person.get_gender() == RelLib.Person.male:
if person.get_gender() == RelLib.Person.female: error.write( _("Unborn father: %(male_name)s born %(byear)d, in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % {
error.write( _("Unborn mother: %(female_name)s born %(byear)d, in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { 'male_name' : idstr, 'byear' : byear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear } )
'female_name' : idstr, 'byear' : byear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear } ) if person.get_gender() == RelLib.Person.female:
else: error.write( _("Unborn mother: %(female_name)s born %(byear)d, in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % {
if bage < yngpar: 'female_name' : idstr, 'byear' : byear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear } )
if person.get_gender() == RelLib.Person.male: else:
warn.write( _("Young father: %(male_name)s at the age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { if bage < yngpar:
'male_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) if person.get_gender() == RelLib.Person.male:
if person.get_gender() == RelLib.Person.female: warn.write( _("Young father: %(male_name)s at the age of %(bage)d in family %(fam)s had a child %(child)s.\n") % {
warn.write( _("Young mother: %(female_name)s at the age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { 'male_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } )
'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) if person.get_gender() == RelLib.Person.female:
if dyear>0 and cbyear>dyear: warn.write( _("Young mother: %(female_name)s at the age of %(bage)d in family %(fam)s had a child %(child)s.\n") % {
if cbyear-1>dyear: 'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } )
if person.get_gender() == RelLib.Person.male: if dyear>0 and cbyear>dyear:
error.write( _("Dead father: %(male_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { if cbyear-1>dyear:
'male_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} ) if person.get_gender() == RelLib.Person.male:
if person.get_gender() == RelLib.Person.female: error.write( _("Dead father: %(male_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % {
error.write( _("Dead mother: %(female_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { 'male_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} )
'female_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} ) if person.get_gender() == RelLib.Person.female:
else: error.write( _("Dead mother: %(female_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % {
if person.get_gender() == RelLib.Person.male: 'female_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} )
warn.write( _("Dead father: %(male_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { else:
'male_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} ) if person.get_gender() == RelLib.Person.male:
if person.get_gender() == RelLib.Person.female: warn.write( _("Dead father: %(male_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % {
warn.write( _("Dead mother: %(female_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { 'male_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} )
'female_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} ) if person.get_gender() == RelLib.Person.female:
warn.write( _("Dead mother: %(female_name)s died %(dyear)d, but in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % {
'female_name' : idstr, 'dyear' : dyear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear} )
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.get_buffer().set_text(text) textwindow = top.get_widget("textwindow")
top.show() textwindow.get_buffer().set_text(text)
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)