Make merge and check handle empty families correctly
svn: r646
This commit is contained in:
parent
016804ff53
commit
8fa4475a6b
@ -394,7 +394,7 @@ class SingleDate:
|
|||||||
raise Date.Error,val
|
raise Date.Error,val
|
||||||
|
|
||||||
def setMonth(self,val):
|
def setMonth(self,val):
|
||||||
if val > 12 or val < 0:
|
if val > 14 or val < 0:
|
||||||
self.month = UNDEF
|
self.month = UNDEF
|
||||||
else:
|
else:
|
||||||
self.month = val - 1
|
self.month = val - 1
|
||||||
|
@ -428,8 +428,8 @@ class MergePeople:
|
|||||||
else:
|
else:
|
||||||
index = 0
|
index = 0
|
||||||
for fam in child.getAltFamilies():
|
for fam in child.getAltFamilies():
|
||||||
if fam == src_family:
|
if fam[0] == src_family:
|
||||||
child.getAltFamilies()[index] = tgt_family
|
child.getAltFamilies()[index] = (tgt_family,fam[1],fam[2])
|
||||||
index = index + 1
|
index = index + 1
|
||||||
|
|
||||||
# add family events from the old to the new
|
# add family events from the old to the new
|
||||||
@ -449,13 +449,13 @@ class MergePeople:
|
|||||||
|
|
||||||
del self.db.getFamilyMap()[src_family.getId()]
|
del self.db.getFamilyMap()[src_family.getId()]
|
||||||
else:
|
else:
|
||||||
self.remove_marriage(src_family,self.p2)
|
|
||||||
if src_family not in self.p1.getFamilyList():
|
if src_family not in self.p1.getFamilyList():
|
||||||
self.p1.addFamily(src_family)
|
self.p1.addFamily(src_family)
|
||||||
if self.p1.getGender() == RelLib.Person.male:
|
if self.p1.getGender() == RelLib.Person.male:
|
||||||
src_family.setFather(self.p1)
|
src_family.setFather(self.p1)
|
||||||
else:
|
else:
|
||||||
src_family.setMother(self.p1)
|
src_family.setMother(self.p1)
|
||||||
|
self.remove_marriage(src_family,self.p2)
|
||||||
|
|
||||||
# a little debugging here
|
# a little debugging here
|
||||||
|
|
||||||
@ -467,22 +467,22 @@ class MergePeople:
|
|||||||
fam.setFather(self.p1)
|
fam.setFather(self.p1)
|
||||||
if self.p2 == fam.getMother():
|
if self.p2 == fam.getMother():
|
||||||
fam.setMother(self.p1)
|
fam.setMother(self.p1)
|
||||||
|
if fam.getFather() == None and fam.getMother() == None:
|
||||||
|
self.delete_empty_family(self)
|
||||||
|
|
||||||
#---------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#---------------------------------------------------------------------
|
|
||||||
def remove_marriage(self,family,person):
|
def remove_marriage(self,family,person):
|
||||||
if not person:
|
if person:
|
||||||
return
|
person.removeFamily(family)
|
||||||
index = 0
|
if family.getFather() == None and family.getMother() == None:
|
||||||
for fam in person.getFamilyList():
|
self.delete_empty_family(family)
|
||||||
if fam == family:
|
|
||||||
del person.getFamilyList()[index]
|
|
||||||
return
|
|
||||||
index = index + 1
|
|
||||||
|
|
||||||
|
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):
|
def compare_people(p1,p2):
|
||||||
|
|
||||||
|
@ -699,7 +699,9 @@ def remove_from_person_list(person):
|
|||||||
person_list.thaw()
|
person_list.thaw()
|
||||||
|
|
||||||
def merge_update(p1,p2):
|
def merge_update(p1,p2):
|
||||||
|
remove_from_person_list(p1)
|
||||||
remove_from_person_list(p2)
|
remove_from_person_list(p2)
|
||||||
|
redisplay_person_list(p1)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -103,20 +103,18 @@ class CheckIntegrity:
|
|||||||
|
|
||||||
family_list = self.db.getFamilyMap().values()[:]
|
family_list = self.db.getFamilyMap().values()[:]
|
||||||
for family in family_list:
|
for family in family_list:
|
||||||
child_list = family.getChildList()[:]
|
if family.getFather() == None and family.getMother() == None:
|
||||||
num_kids = len(child_list)
|
utils.modified()
|
||||||
father = family.getFather()
|
|
||||||
mother = family.getMother()
|
|
||||||
|
|
||||||
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)
|
self.empty_family.append(family)
|
||||||
|
self.delete_empty_family(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()
|
year_valid = subdate.getYearValid()
|
||||||
|
|
||||||
if not day_valid:
|
if not day_valid:
|
||||||
|
try:
|
||||||
if not mon_valid:
|
if not mon_valid:
|
||||||
retval = str(year)
|
retval = str(year)
|
||||||
elif not year_valid:
|
elif not year_valid:
|
||||||
retval = mmap[mon]
|
retval = mmap[mon]
|
||||||
else:
|
else:
|
||||||
retval = "%s %d" % (mmap[mon],year)
|
retval = "%s %d" % (mmap[mon],year)
|
||||||
|
except IndexError:
|
||||||
|
print "Month index error - %d" % mon
|
||||||
|
retval = str(year)
|
||||||
elif not mon_valid:
|
elif not mon_valid:
|
||||||
retval = str(year)
|
retval = str(year)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
month = mmap[mon]
|
month = mmap[mon]
|
||||||
if not year_valid:
|
if not year_valid:
|
||||||
retval = "%d %s ????" % (day,month)
|
retval = "%d %s ????" % (day,month)
|
||||||
else:
|
else:
|
||||||
retval = "%d %s %d" % (day,month,year)
|
retval = "%d %s %d" % (day,month,year)
|
||||||
|
except IndexError:
|
||||||
|
print "Month index error - %d" % mon
|
||||||
|
retval = str(year)
|
||||||
if mode == Date.SingleDate.about:
|
if mode == Date.SingleDate.about:
|
||||||
retval = "ABT %s" % retval
|
retval = "ABT %s" % retval
|
||||||
elif mode == Date.SingleDate.before:
|
elif mode == Date.SingleDate.before:
|
||||||
@ -330,20 +337,28 @@ def ged_subdate(date):
|
|||||||
if not date.getValid():
|
if not date.getValid():
|
||||||
return ""
|
return ""
|
||||||
elif not date.getDayValid():
|
elif not date.getDayValid():
|
||||||
|
try:
|
||||||
if not date.getMonthValid():
|
if not date.getMonthValid():
|
||||||
retval = str(date.year)
|
retval = str(date.year)
|
||||||
elif not date.getYearValid():
|
elif not date.getYearValid():
|
||||||
retval = "(%s)" % Date.SingleDate.emname[date.month]
|
retval = "(%s)" % Date.SingleDate.emname[date.month]
|
||||||
else:
|
else:
|
||||||
retval = "%s %d" % (Date.SingleDate.emname[date.month],date.year)
|
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.getMonthValid():
|
elif not date.getMonthValid():
|
||||||
retval = str(date.year)
|
retval = str(date.year)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
month = Date.SingleDate.emname[date.month]
|
month = Date.SingleDate.emname[date.month]
|
||||||
if not date.getYearValid():
|
if not date.getYearValid():
|
||||||
retval = "(%d %s)" % (date.day,month)
|
retval = "(%d %s)" % (date.day,month)
|
||||||
else:
|
else:
|
||||||
retval = "%d %s %d" % (date.day,month,date.year)
|
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:
|
if date.mode == Date.SingleDate.about:
|
||||||
retval = "ABT %s" % retval
|
retval = "ABT %s" % retval
|
||||||
|
Loading…
Reference in New Issue
Block a user