From 963ea4c80ac73737daa53a4d3088132a5c8e8f1e Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sat, 8 May 2004 03:29:21 +0000 Subject: [PATCH] * src/plugins/soundgen.py: Convert to db. * src/plugins/GraphViz.py: Typo. * src/plugins/Verify.py: Convert to db. svn: r3141 --- gramps2/ChangeLog | 5 + gramps2/src/plugins/GraphViz.py | 2 +- gramps2/src/plugins/Verify.py | 692 +++++++++++++++++--------------- gramps2/src/plugins/soundgen.py | 3 +- 4 files changed, 366 insertions(+), 336 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 275481c56..44cbb2c76 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2004-05-07 Alex Roitman + * src/plugins/soundgen.py: Convert to db. + * src/plugins/GraphViz.py: Typo. + * src/plugins/Verify.py: Convert to db. + 2004-05-06 Alex Roitman * src/plugins/WebPage.py: Clean up conversion to db. Switch to using Sort function. diff --git a/gramps2/src/plugins/GraphViz.py b/gramps2/src/plugins/GraphViz.py index 5104b7d7a..9fcfd65a2 100644 --- a/gramps2/src/plugins/GraphViz.py +++ b/gramps2/src/plugins/GraphViz.py @@ -496,7 +496,7 @@ def dump_index(database,person_list,file,includedates,includeurl,colorize, family_list = person.get_family_id_list() for fam_id in family_list: fid = string.replace(fam_id,'-','_') - if fam not_id in families_done: + if fam_id not in families_done: families_done.append(fam_id) file.write('f%s [shape=ellipse, ' % fid) marriage = "" diff --git a/gramps2/src/plugins/Verify.py b/gramps2/src/plugins/Verify.py index f6cf8aab1..8f9d0a6d6 100644 --- a/gramps2/src/plugins/Verify.py +++ b/gramps2/src/plugins/Verify.py @@ -1,7 +1,7 @@ # # 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 # it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ # Modified further to use cStringIO object. # +# $Id$ + "View/Verify" #------------------------------------------------------------------------ @@ -54,356 +56,379 @@ import Gregorian 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): - global glade_file - global db - global verifySettings - - db = database - - base = os.path.dirname(__file__) - glade_file = base + os.sep + "verify.glade" + Verify(database,active_person) - verifySettings = gtk.glade.XML(glade_file,"verify_settings","gramps") - verifySettings.signal_autoconnect({ - "destroy_passed_object" : Utils.destroy_passed_object, - "on_verify_ok_clicked" : on_apply_clicked +#------------------------------------------------------------------------- +# +# +#------------------------------------------------------------------------- +class Verify: + def __init__(self,database,active_person): + self.db = database + + base = os.path.dirname(__file__) + self.glade_file = base + os.sep + "verify.glade" + + self.top = gtk.glade.XML(self.glade_file,"verify_settings","gramps") + self.top.signal_autoconnect({ + "destroy_passed_object" : Utils.destroy_passed_object, + "on_verify_ok_clicked" : self.on_apply_clicked }) - Utils.set_titles(verifySettings.get_widget('verify_settings'), - verifySettings.get_widget('title'), + Utils.set_titles(self.top.get_widget('verify_settings'), + self.top.get_widget('title'), _('Database Verify')) -def on_apply_clicked(obj): - global db - global verifySettings + def get_year(self,event_id): + """ + 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()) - 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() + personList = self.db.get_person_keys() - 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() - warn = cStringIO.StringIO() + oldunm = 99 # maximum age at death for unmarried person - for person in personList: - idstr = person.get_primary_name().get_name() + " (" + person.get_id() + ")" - - # individual checks - ageatdeath = 0 - byear = get_year( person.get_birth() ) - bapyear = 0 - dyear = get_year( person.get_death() ) - 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: + error = cStringIO.StringIO() + warn = cStringIO.StringIO() + + for person_id in personList: + person = self.db.find_person_from_id(person_id) + idstr = "%s (%s)" % (person.get_primary_name().get_name(),person_id) + + # individual checks 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: - oldpar = oldmom - 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 - - # multiple parentage check - if( len( person.get_parent_family_id_list() ) > 1 ): - warn.write( _("Multiple parentage for %s.\n") % idstr ) - - # marriage checks - 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 - cnum=0 - for child in family.get_child_id_list(): - cnum = cnum + 1 - if maryear == 0: - birthyear = get_year( child.get_birth() ) - if birthyear > 0: - maryear = birthyear-cnum - - if maryear > 0: - if byear > 0: - marage = maryear - byear - if marage < 0: - 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") % { - 'male_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) - 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") % { - 'female_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) - else: - if marage < yngmar: - if person.get_gender() == RelLib.Person.male: - 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() } ) - if person.get_gender() == RelLib.Person.female: - 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() } ) - if marage > oldmar: - if person.get_gender() == RelLib.Person.male: - 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() } ) - if person.get_gender() == RelLib.Person.female: - 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() } ) - if dyear>0 and maryear > dyear: - 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") % { - 'male_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) - 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") % { - 'female_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) - if prev_cbyear > maryear: - 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") % { - 'male_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } ) - 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") % { - 'female_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } ) - prev_maryear = maryear - else: - maryear = prev_maryear - - if maryear>0 and prev_sdyear > 0: - wdwyear = maryear-prev_sdyear - if wdwyear > lngwdw: - 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() ) ) - 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() ) ) - - if fnum==nfam and dyear>0 and sdyear>0: - wdwyear = dyear - sdyear - if wdwyear > lngwdw: - if person.get_gender() == RelLib.Person.male: - warn.write( _("Long widowhood: %s was a widower %d years.\n") % (idstr, wdwyear) ) - if person.get_gender() == RelLib.Person.female: - warn.write( _("Long widowhood: %s was a widow %d years.\n") % (idstr, wdwyear) ) - - nkids = 0 - for child in family.get_child_id_list(): - nkids = nkids+1 - cbyear = get_year( child.get_birth() ) - if cbyear>0 and cbyear < first_cbyear: - first_cbyear = cbyear - if cbyear>last_cbyear: - last_cbyear = cbyear - # parentage checks - if byear>0 and cbyear>0: - bage = cbyear - byear - if bage > oldpar: - if person.get_gender() == RelLib.Person.male: - warn.write( _("Old father: %(male_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() } ) - if person.get_gender() == RelLib.Person.female: - warn.write( _("Old mother: %(female_name)s at age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { - 'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) - if bage < 0: - if person.get_gender() == RelLib.Person.male: - error.write( _("Unborn father: %(male_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 } ) - if person.get_gender() == RelLib.Person.female: - error.write( _("Unborn mother: %(female_name)s born %(byear)d, in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { - 'female_name' : idstr, 'byear' : byear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear } ) - else: - if bage < yngpar: - if person.get_gender() == RelLib.Person.male: - warn.write( _("Young father: %(male_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() } ) - if person.get_gender() == RelLib.Person.female: - warn.write( _("Young mother: %(female_name)s at the age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { - 'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) - if dyear>0 and cbyear>dyear: - if cbyear-1>dyear: - if person.get_gender() == RelLib.Person.male: - error.write( _("Dead father: %(male_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} ) - if person.get_gender() == RelLib.Person.female: - error.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} ) - else: - if person.get_gender() == RelLib.Person.male: - warn.write( _("Dead father: %(male_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} ) - 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 = "" - if error != "": - text = _("ERRORS:\n") + error.getvalue() + "\n" - if warn != "": - text = _("WARNINGS:\n") + warn.getvalue() - - error.close() - warn.close() + byear = self.get_year( person.get_birth_id() ) + bapyear = 0 + dyear = self.get_year( person.get_death_id() ) + 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 } ) - verifyResult = gtk.glade.XML(glade_file,"verify_result","gramps") - Utils.set_titles(verifyResult.get_widget('verify_result'), - verifyResult.get_widget('title'), + # gender checks + + if person.get_gender() == RelLib.Person.female: + oldpar = oldmom + 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 + + # multiple parentage check + if( len( person.get_parent_family_id_list() ) > 1 ): + warn.write( _("Multiple parentage for %s.\n") % idstr ) + + # marriage checks + 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_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 + + 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 + cnum=0 + for child_id in family.get_child_id_list(): + cnum = cnum + 1 + if maryear == 0: + child = self.db.find_person_from_id(child_id) + birthyear = self.get_year( child.get_birth_id() ) + if birthyear > 0: + maryear = birthyear-cnum + + if maryear > 0: + if byear > 0: + marage = maryear - byear + if marage < 0: + 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") % { + 'male_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) + 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") % { + 'female_name' : idstr, 'byear' : byear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) + else: + if marage < yngmar: + if person.get_gender() == RelLib.Person.male: + 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() } ) + if person.get_gender() == RelLib.Person.female: + 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() } ) + if marage > oldmar: + if person.get_gender() == RelLib.Person.male: + 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() } ) + if person.get_gender() == RelLib.Person.female: + 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() } ) + if dyear>0 and maryear > dyear: + 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") % { + 'male_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) + 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") % { + 'female_name' : idstr, 'dyear' : dyear, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name() } ) + if prev_cbyear > maryear: + 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") % { + 'male_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } ) + 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") % { + 'female_name' : idstr, 'maryear' : maryear, 'spouse' : spouse.get_primary_name().get_name(), 'prev_cbyear' : prev_cbyear } ) + prev_maryear = maryear + else: + maryear = prev_maryear + + if maryear>0 and prev_sdyear > 0: + wdwyear = maryear-prev_sdyear + if wdwyear > lngwdw: + 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() ) ) + 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() ) ) + + if fnum==nfam and dyear>0 and sdyear>0: + wdwyear = dyear - sdyear + if wdwyear > lngwdw: + if person.get_gender() == RelLib.Person.male: + warn.write( _("Long widowhood: %s was a widower %d years.\n") % (idstr, wdwyear) ) + if person.get_gender() == RelLib.Person.female: + warn.write( _("Long widowhood: %s was a widow %d years.\n") % (idstr, wdwyear) ) + + nkids = 0 + for child_id in family.get_child_id_list(): + nkids = nkids+1 + child = self.db.find_person_from_id(child_id) + cbyear = self.get_year( child.get_birth_id() ) + if cbyear>0 and cbyear < first_cbyear: + first_cbyear = cbyear + if cbyear>last_cbyear: + last_cbyear = cbyear + + # parentage checks + if byear>0 and cbyear>0: + bage = cbyear - byear + if bage > oldpar: + if person.get_gender() == RelLib.Person.male: + warn.write( _("Old father: %(male_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() } ) + if person.get_gender() == RelLib.Person.female: + warn.write( _("Old mother: %(female_name)s at age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { + 'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) + if bage < 0: + if person.get_gender() == RelLib.Person.male: + error.write( _("Unborn father: %(male_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 } ) + if person.get_gender() == RelLib.Person.female: + error.write( _("Unborn mother: %(female_name)s born %(byear)d, in family %(fam)s had a child %(child)s born %(cbyear)d.\n") % { + 'female_name' : idstr, 'byear' : byear, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name(), 'cbyear' : cbyear } ) + else: + if bage < yngpar: + if person.get_gender() == RelLib.Person.male: + warn.write( _("Young father: %(male_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() } ) + if person.get_gender() == RelLib.Person.female: + warn.write( _("Young mother: %(female_name)s at the age of %(bage)d in family %(fam)s had a child %(child)s.\n") % { + 'female_name' : idstr, 'bage' : bage, 'fam' : family.get_id(), 'child' : child.get_primary_name().get_name() } ) + if dyear>0 and cbyear>dyear: + if cbyear-1>dyear: + if person.get_gender() == RelLib.Person.male: + error.write( _("Dead father: %(male_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} ) + if person.get_gender() == RelLib.Person.female: + error.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} ) + else: + if person.get_gender() == RelLib.Person.male: + warn.write( _("Dead father: %(male_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} ) + 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 = "" + if error: + text = _("ERRORS:\n") + error.getvalue() + "\n" + if warn: + text = _("WARNINGS:\n") + warn.getvalue() + + error.close() + warn.close() + + top = gtk.glade.XML(self.glade_file,"verify_result","gramps") + Utils.set_titles(top.get_widget('verify_result'), + top.get_widget('title'), _('Database Verify')) - verifyResult.signal_autoconnect({ - "destroy_passed_object" : Utils.destroy_passed_object, + top.signal_autoconnect({ + "destroy_passed_object" : Utils.destroy_passed_object, }) - top = verifyResult.get_widget("verify_result") - textwindow = verifyResult.get_widget("textwindow") - textwindow.get_buffer().set_text(text) - top.show() + + topwin = top.get_widget("verify_result") + textwindow = top.get_widget("textwindow") + textwindow.get_buffer().set_text(text) + topwin.show() #------------------------------------------------------------------------- # @@ -418,4 +443,3 @@ register_tool( category=_("Utilities"), description=_("Lists exceptions to assertions or checks about the database") ) - diff --git a/gramps2/src/plugins/soundgen.py b/gramps2/src/plugins/soundgen.py index 1f08750fc..484389a12 100644 --- a/gramps2/src/plugins/soundgen.py +++ b/gramps2/src/plugins/soundgen.py @@ -63,7 +63,8 @@ class SoundGen: self.name.connect('changed',self.on_apply_clicked) 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() if lastname not in names: names.append(lastname)