Make merge and check handle empty families correctly
svn: r646
This commit is contained in:
parent
498c37b810
commit
a3cdadd56a
@ -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
|
||||
|
@ -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):
|
||||
|
||||
|
@ -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)
|
||||
|
@ -699,7 +699,9 @@ 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)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -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)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user