From a3cdadd56a6341cf0f2376d3bb08bd70937799bf Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 20 Dec 2001 18:50:09 +0000 Subject: [PATCH] Make merge and check handle empty families correctly svn: r646 --- src/Date.py | 2 +- src/MergeData.py | 32 ++++++++++----------- src/RelLib.py | 2 +- src/gramps_main.py | 4 ++- src/plugins/Check.py | 24 ++++++++-------- src/plugins/WriteGedcom.py | 57 ++++++++++++++++++++++++-------------- 6 files changed, 68 insertions(+), 53 deletions(-) diff --git a/src/Date.py b/src/Date.py index c57ec007e..930b4e32e 100644 --- a/src/Date.py +++ b/src/Date.py @@ -394,7 +394,7 @@ class SingleDate: raise Date.Error,val def setMonth(self,val): - if val > 12 or val < 0: + if val > 14 or val < 0: self.month = UNDEF else: self.month = val - 1 diff --git a/src/MergeData.py b/src/MergeData.py index 38dd0bf4f..b28fc7d8e 100644 --- a/src/MergeData.py +++ b/src/MergeData.py @@ -428,8 +428,8 @@ class MergePeople: else: index = 0 for fam in child.getAltFamilies(): - if fam == src_family: - child.getAltFamilies()[index] = tgt_family + if fam[0] == src_family: + child.getAltFamilies()[index] = (tgt_family,fam[1],fam[2]) index = index + 1 # add family events from the old to the new @@ -449,13 +449,13 @@ class MergePeople: del self.db.getFamilyMap()[src_family.getId()] else: - self.remove_marriage(src_family,self.p2) if src_family not in self.p1.getFamilyList(): self.p1.addFamily(src_family) if self.p1.getGender() == RelLib.Person.male: src_family.setFather(self.p1) else: src_family.setMother(self.p1) + self.remove_marriage(src_family,self.p2) # a little debugging here @@ -467,22 +467,22 @@ class MergePeople: fam.setFather(self.p1) if self.p2 == fam.getMother(): fam.setMother(self.p1) + if fam.getFather() == None and fam.getMother() == None: + self.delete_empty_family(self) - #--------------------------------------------------------------------- - # - # - # - #--------------------------------------------------------------------- def remove_marriage(self,family,person): - if not person: - return - index = 0 - for fam in person.getFamilyList(): - if fam == family: - del person.getFamilyList()[index] - return - index = index + 1 + if person: + person.removeFamily(family) + if family.getFather() == None and family.getMother() == None: + self.delete_empty_family(family) + def delete_empty_family(self,family): + for child in family.getChildList(): + if child.getMainFamily() == family: + child.setMainFamily(None) + else: + child.removeAltFamily(family) + self.db.deleteFamily(family) def compare_people(p1,p2): diff --git a/src/RelLib.py b/src/RelLib.py index 38c90aa5b..6893c94eb 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -1385,7 +1385,7 @@ class Family: def removeChild(self,person): """removes the specified Person from the child list""" if person in self.Children: - self.Children.remove(person) + self.Children.remove(person) if person.ancestor: if self.Father: self.Father.setAncestor(0) diff --git a/src/gramps_main.py b/src/gramps_main.py index b8f30dd89..55d7caafe 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -699,8 +699,10 @@ def remove_from_person_list(person): person_list.thaw() def merge_update(p1,p2): + remove_from_person_list(p1) remove_from_person_list(p2) - + redisplay_person_list(p1) + #------------------------------------------------------------------------- # # diff --git a/src/plugins/Check.py b/src/plugins/Check.py index 6093cf8ed..d97249598 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -103,20 +103,18 @@ class CheckIntegrity: family_list = self.db.getFamilyMap().values()[:] for family in family_list: - child_list = family.getChildList()[:] - num_kids = len(child_list) - father = family.getFather() - mother = family.getMother() + if family.getFather() == None and family.getMother() == None: + utils.modified() + self.empty_family.append(family) + self.delete_empty_family(family) - if num_kids == 0: - if father or mother: - continue - elif not father and not mother: - self.db.deleteFamily(family) - elif automatic: - self.db.deleteFamily(family) - else: - self.empty_family.append(family) + def delete_empty_family(self,family): + for child in self.db.getPersonMap().values(): + if child.getMainFamily() == family: + child.setMainFamily(None) + else: + child.removeAltFamily(family) + self.db.deleteFamily(family) #------------------------------------------------------------------------- # diff --git a/src/plugins/WriteGedcom.py b/src/plugins/WriteGedcom.py index eb9974efa..2a8b6f137 100644 --- a/src/plugins/WriteGedcom.py +++ b/src/plugins/WriteGedcom.py @@ -272,21 +272,28 @@ def make_date(subdate,mmap): year_valid = subdate.getYearValid() if not day_valid: - if not mon_valid: + try: + if not mon_valid: + retval = str(year) + elif not year_valid: + retval = mmap[mon] + else: + retval = "%s %d" % (mmap[mon],year) + except IndexError: + print "Month index error - %d" % mon retval = str(year) - elif not year_valid: - retval = mmap[mon] - else: - retval = "%s %d" % (mmap[mon],year) elif not mon_valid: retval = str(year) else: - month = mmap[mon] - if not year_valid: - retval = "%d %s ????" % (day,month) - else: - retval = "%d %s %d" % (day,month,year) - + try: + month = mmap[mon] + if not year_valid: + retval = "%d %s ????" % (day,month) + else: + retval = "%d %s %d" % (day,month,year) + except IndexError: + print "Month index error - %d" % mon + retval = str(year) if mode == Date.SingleDate.about: retval = "ABT %s" % retval elif mode == Date.SingleDate.before: @@ -330,20 +337,28 @@ def ged_subdate(date): if not date.getValid(): return "" elif not date.getDayValid(): - if not date.getMonthValid(): + try: + if not date.getMonthValid(): + retval = str(date.year) + elif not date.getYearValid(): + retval = "(%s)" % Date.SingleDate.emname[date.month] + else: + retval = "%s %d" % (Date.SingleDate.emname[date.month],date.year) + except IndexError: + print "Month index error - %d" % date.month retval = str(date.year) - elif not date.getYearValid(): - retval = "(%s)" % Date.SingleDate.emname[date.month] - else: - retval = "%s %d" % (Date.SingleDate.emname[date.month],date.year) elif not date.getMonthValid(): retval = str(date.year) else: - month = Date.SingleDate.emname[date.month] - if not date.getYearValid(): - retval = "(%d %s)" % (date.day,month) - else: - retval = "%d %s %d" % (date.day,month,date.year) + try: + month = Date.SingleDate.emname[date.month] + if not date.getYearValid(): + retval = "(%d %s)" % (date.day,month) + else: + retval = "%d %s %d" % (date.day,month,date.year) + except IndexError: + print "Month index error - %d" % date.month + retval = str(date.year) if date.mode == Date.SingleDate.about: retval = "ABT %s" % retval