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
|
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):
|
||||||
|
|
||||||
|
@ -1385,7 +1385,7 @@ class Family:
|
|||||||
def removeChild(self,person):
|
def removeChild(self,person):
|
||||||
"""removes the specified Person from the child list"""
|
"""removes the specified Person from the child list"""
|
||||||
if person in self.Children:
|
if person in self.Children:
|
||||||
self.Children.remove(person)
|
self.Children.remove(person)
|
||||||
if person.ancestor:
|
if person.ancestor:
|
||||||
if self.Father:
|
if self.Father:
|
||||||
self.Father.setAncestor(0)
|
self.Father.setAncestor(0)
|
||||||
|
@ -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()
|
self.empty_family.append(family)
|
||||||
mother = family.getMother()
|
self.delete_empty_family(family)
|
||||||
|
|
||||||
if num_kids == 0:
|
def delete_empty_family(self,family):
|
||||||
if father or mother:
|
for child in self.db.getPersonMap().values():
|
||||||
continue
|
if child.getMainFamily() == family:
|
||||||
elif not father and not mother:
|
child.setMainFamily(None)
|
||||||
self.db.deleteFamily(family)
|
else:
|
||||||
elif automatic:
|
child.removeAltFamily(family)
|
||||||
self.db.deleteFamily(family)
|
self.db.deleteFamily(family)
|
||||||
else:
|
|
||||||
self.empty_family.append(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:
|
||||||
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)
|
retval = str(year)
|
||||||
elif not year_valid:
|
|
||||||
retval = mmap[mon]
|
|
||||||
else:
|
|
||||||
retval = "%s %d" % (mmap[mon],year)
|
|
||||||
elif not mon_valid:
|
elif not mon_valid:
|
||||||
retval = str(year)
|
retval = str(year)
|
||||||
else:
|
else:
|
||||||
month = mmap[mon]
|
try:
|
||||||
if not year_valid:
|
month = mmap[mon]
|
||||||
retval = "%d %s ????" % (day,month)
|
if not year_valid:
|
||||||
else:
|
retval = "%d %s ????" % (day,month)
|
||||||
retval = "%d %s %d" % (day,month,year)
|
else:
|
||||||
|
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():
|
||||||
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)
|
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():
|
elif not date.getMonthValid():
|
||||||
retval = str(date.year)
|
retval = str(date.year)
|
||||||
else:
|
else:
|
||||||
month = Date.SingleDate.emname[date.month]
|
try:
|
||||||
if not date.getYearValid():
|
month = Date.SingleDate.emname[date.month]
|
||||||
retval = "(%d %s)" % (date.day,month)
|
if not date.getYearValid():
|
||||||
else:
|
retval = "(%d %s)" % (date.day,month)
|
||||||
retval = "%d %s %d" % (date.day,month,date.year)
|
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:
|
if date.mode == Date.SingleDate.about:
|
||||||
retval = "ABT %s" % retval
|
retval = "ABT %s" % retval
|
||||||
|
Loading…
Reference in New Issue
Block a user