* src/plugins/Check.py: Use transaction for commits.
* src/plugins/PatchNames.py: Use transaction for commits. svn: r3160
This commit is contained in:
parent
df99dc444d
commit
653d5499ee
@ -8,6 +8,9 @@
|
|||||||
* src/plugins/WritePkg.py: Remove Utils.modified() call.
|
* src/plugins/WritePkg.py: Remove Utils.modified() call.
|
||||||
* src/plugins/Merge.py: Typo.
|
* src/plugins/Merge.py: Typo.
|
||||||
|
|
||||||
|
* src/plugins/Check.py: Use transaction for commits.
|
||||||
|
* src/plugins/PatchNames.py: Use transaction for commits.
|
||||||
|
|
||||||
2004-05-11 Don Allingham <donaldallingham@users.sourceforge.net>
|
2004-05-11 Don Allingham <donaldallingham@users.sourceforge.net>
|
||||||
* src/GrampsCfg.py: remove unused options
|
* src/GrampsCfg.py: remove unused options
|
||||||
* src/gramps.glade: remove unused panels in preferences
|
* src/gramps.glade: remove unused panels in preferences
|
||||||
|
@ -58,15 +58,21 @@ from QuestionDialog import OkDialog, MissingMediaDialog
|
|||||||
def runTool(database,active_person,callback,parent=None):
|
def runTool(database,active_person,callback,parent=None):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
checker = CheckIntegrity(database,parent)
|
trans = database.start_transaction()
|
||||||
|
checker = CheckIntegrity(database,parent,trans)
|
||||||
checker.check_for_broken_family_links()
|
checker.check_for_broken_family_links()
|
||||||
checker.cleanup_missing_photos(0)
|
checker.cleanup_missing_photos(0)
|
||||||
checker.check_parent_relationships()
|
checker.check_parent_relationships()
|
||||||
checker.cleanup_empty_families(0)
|
checker.cleanup_empty_families(0)
|
||||||
|
database.add_transaction(trans)
|
||||||
|
|
||||||
errs = checker.build_report(0)
|
errs = checker.build_report(0)
|
||||||
if errs:
|
if errs:
|
||||||
checker.report(0)
|
checker.report(0)
|
||||||
except:
|
except:
|
||||||
|
database.add_transaction(trans)
|
||||||
|
database.undo()
|
||||||
|
|
||||||
import DisplayTrace
|
import DisplayTrace
|
||||||
DisplayTrace.DisplayTrace()
|
DisplayTrace.DisplayTrace()
|
||||||
|
|
||||||
@ -77,8 +83,9 @@ def runTool(database,active_person,callback,parent=None):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class CheckIntegrity:
|
class CheckIntegrity:
|
||||||
|
|
||||||
def __init__(self,db,parent):
|
def __init__(self,db,parent,trans):
|
||||||
self.db = db
|
self.db = db
|
||||||
|
self.trans = trans
|
||||||
self.bad_photo = []
|
self.bad_photo = []
|
||||||
self.replaced_photo = []
|
self.replaced_photo = []
|
||||||
self.removed_photo = []
|
self.removed_photo = []
|
||||||
@ -101,11 +108,11 @@ class CheckIntegrity:
|
|||||||
if father_id and family_id not in father.get_family_id_list():
|
if father_id and family_id not in father.get_family_id_list():
|
||||||
self.broken_parent_links.append((father_id,family_id))
|
self.broken_parent_links.append((father_id,family_id))
|
||||||
father.add_family_id(family_id)
|
father.add_family_id(family_id)
|
||||||
self.db.commit_person(father)
|
self.db.commit_person(father,self.trans)
|
||||||
if mother_id and family_id not in mother.get_family_id_list():
|
if mother_id and family_id not in mother.get_family_id_list():
|
||||||
self.broken_parent_links.append((mother_id,family_id))
|
self.broken_parent_links.append((mother_id,family_id))
|
||||||
mother.add_family_id(family_id)
|
mother.add_family_id(family_id)
|
||||||
self.db.commit_person(mother)
|
self.db.commit_person(mother,self.trans)
|
||||||
for child_id in family.get_child_id_list():
|
for child_id in family.get_child_id_list():
|
||||||
child = self.db.find_person_from_id(child_id)
|
child = self.db.find_person_from_id(child_id)
|
||||||
if family_id == child.get_main_parents_family_id():
|
if family_id == child.get_main_parents_family_id():
|
||||||
@ -115,7 +122,7 @@ class CheckIntegrity:
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
family.remove_child_id(child_id)
|
family.remove_child_id(child_id)
|
||||||
self.db.commit_family(family)
|
self.db.commit_family(family,self.trans)
|
||||||
self.broken_links.append((child_id,family_id))
|
self.broken_links.append((child_id,family_id))
|
||||||
|
|
||||||
def cleanup_missing_photos(self,cl=0):
|
def cleanup_missing_photos(self,cl=0):
|
||||||
@ -133,7 +140,7 @@ class CheckIntegrity:
|
|||||||
nl.remove(o)
|
nl.remove(o)
|
||||||
if changed:
|
if changed:
|
||||||
p.set_media_list(nl)
|
p.set_media_list(nl)
|
||||||
self.db.commit_person(p)
|
self.db.commit_person(p,self.trans)
|
||||||
|
|
||||||
for key in self.db.get_person_keys():
|
for key in self.db.get_person_keys():
|
||||||
p = self.db.find_person_from_id(key)
|
p = self.db.find_person_from_id(key)
|
||||||
@ -145,7 +152,7 @@ class CheckIntegrity:
|
|||||||
nl.remove(o)
|
nl.remove(o)
|
||||||
if changed:
|
if changed:
|
||||||
p.set_media_list(nl)
|
p.set_media_list(nl)
|
||||||
self.db.commit_person(p)
|
self.db.commit_person(p,self.trans)
|
||||||
|
|
||||||
for key in self.db.get_source_keys():
|
for key in self.db.get_source_keys():
|
||||||
p = self.db.find_source_from_id(key)
|
p = self.db.find_source_from_id(key)
|
||||||
@ -157,7 +164,7 @@ class CheckIntegrity:
|
|||||||
nl.remove(o)
|
nl.remove(o)
|
||||||
if changed:
|
if changed:
|
||||||
p.set_media_list(nl)
|
p.set_media_list(nl)
|
||||||
self.db.commit_source(p)
|
self.db.commit_source(p,self.trans)
|
||||||
|
|
||||||
for key in self.db.get_place_id_keys():
|
for key in self.db.get_place_id_keys():
|
||||||
p = self.db.get_place_id(key)
|
p = self.db.get_place_id(key)
|
||||||
@ -169,9 +176,9 @@ class CheckIntegrity:
|
|||||||
nl.remove(o)
|
nl.remove(o)
|
||||||
if changed:
|
if changed:
|
||||||
p.set_media_list(nl)
|
p.set_media_list(nl)
|
||||||
self.db.commit_place(p)
|
self.db.commit_place(p,self.trans)
|
||||||
self.removed_photo.append(ObjectId)
|
self.removed_photo.append(ObjectId)
|
||||||
self.db.remove_object(ObjectId)
|
self.db.remove_object(ObjectId,self.trans)
|
||||||
|
|
||||||
def leave_clicked():
|
def leave_clicked():
|
||||||
self.bad_photo.append(ObjectId)
|
self.bad_photo.append(ObjectId)
|
||||||
@ -239,7 +246,7 @@ class CheckIntegrity:
|
|||||||
child = self.db.find_person_from_id(key)
|
child = self.db.find_person_from_id(key)
|
||||||
child.remove_parent_family_id(family_id)
|
child.remove_parent_family_id(family_id)
|
||||||
child.remove_family_id(family_id)
|
child.remove_family_id(family_id)
|
||||||
self.db.delete_family(family_id)
|
self.db.delete_family(family_id,self.trans)
|
||||||
|
|
||||||
def check_parent_relationships(self):
|
def check_parent_relationships(self):
|
||||||
for key in self.db.get_family_keys():
|
for key in self.db.get_family_keys():
|
||||||
@ -258,12 +265,12 @@ class CheckIntegrity:
|
|||||||
if mother.get_gender() == RelLib.Person.male:
|
if mother.get_gender() == RelLib.Person.male:
|
||||||
family.set_father_id(mother_id)
|
family.set_father_id(mother_id)
|
||||||
family.set_mother_id(None)
|
family.set_mother_id(None)
|
||||||
self.db.commit_family(family)
|
self.db.commit_family(family,self.trans)
|
||||||
elif not mother_id:
|
elif not mother_id:
|
||||||
if father.get_gender() == RelLib.Person.female:
|
if father.get_gender() == RelLib.Person.female:
|
||||||
family.set_mother_id(father_id)
|
family.set_mother_id(father_id)
|
||||||
family.set_father_id(None)
|
family.set_father_id(None)
|
||||||
self.db.commit_family(family)
|
self.db.commit_family(family,self.trans)
|
||||||
else:
|
else:
|
||||||
fgender = father.get_gender()
|
fgender = father.get_gender()
|
||||||
mgender = mother.get_gender()
|
mgender = mother.get_gender()
|
||||||
@ -271,19 +278,19 @@ class CheckIntegrity:
|
|||||||
if fgender == mgender and fgender != RelLib.Person.unknown:
|
if fgender == mgender and fgender != RelLib.Person.unknown:
|
||||||
family.set_relationship("Partners")
|
family.set_relationship("Partners")
|
||||||
self.fam_rel.append(family_id)
|
self.fam_rel.append(family_id)
|
||||||
self.db.commit_family(family)
|
self.db.commit_family(family,self.trans)
|
||||||
elif fgender == RelLib.Person.female or mgender == RelLib.Person.male:
|
elif fgender == RelLib.Person.female or mgender == RelLib.Person.male:
|
||||||
family.set_father_id(mother_id)
|
family.set_father_id(mother_id)
|
||||||
family.set_mother_id(father_id)
|
family.set_mother_id(father_id)
|
||||||
self.fam_rel.append(family_id)
|
self.fam_rel.append(family_id)
|
||||||
self.db.commit_family(family)
|
self.db.commit_family(family,self.trans)
|
||||||
elif fgender != mgender:
|
elif fgender != mgender:
|
||||||
family.set_relationship("Unknown")
|
family.set_relationship("Unknown")
|
||||||
self.fam_rel.append(family_id)
|
self.fam_rel.append(family_id)
|
||||||
if fgender == RelLib.Person.female or mgender == RelLib.Person.male:
|
if fgender == RelLib.Person.female or mgender == RelLib.Person.male:
|
||||||
family.set_father_id(mother_id)
|
family.set_father_id(mother_id)
|
||||||
family.set_mother_id(father_id)
|
family.set_mother_id(father_id)
|
||||||
self.db.commit_family(family)
|
self.db.commit_family(family,self.trans)
|
||||||
|
|
||||||
def build_report(self,cl=0):
|
def build_report(self,cl=0):
|
||||||
bad_photos = len(self.bad_photo)
|
bad_photos = len(self.bad_photo)
|
||||||
|
@ -65,8 +65,12 @@ _nick_re = re.compile(r"(.+)[(\"](.*)[)\"]")
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def runTool(database,active_person,callback,parent=None):
|
def runTool(database,active_person,callback,parent=None):
|
||||||
try:
|
try:
|
||||||
PatchNames(database,callback,parent)
|
trans = database.start_transaction()
|
||||||
|
PatchNames(database,callback,parent,trans)
|
||||||
|
database.add_transaction(trans)
|
||||||
except:
|
except:
|
||||||
|
database.add_transaction(trans)
|
||||||
|
database.undo()
|
||||||
import DisplayTrace
|
import DisplayTrace
|
||||||
DisplayTrace.DisplayTrace()
|
DisplayTrace.DisplayTrace()
|
||||||
|
|
||||||
@ -77,10 +81,11 @@ def runTool(database,active_person,callback,parent=None):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class PatchNames:
|
class PatchNames:
|
||||||
|
|
||||||
def __init__(self,db,callback,parent):
|
def __init__(self,db,callback,parent,trans):
|
||||||
self.cb = callback
|
self.cb = callback
|
||||||
self.db = db
|
self.db = db
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
self.trans = trans
|
||||||
self.win_key = self
|
self.win_key = self
|
||||||
self.child_windows = {}
|
self.child_windows = {}
|
||||||
self.title_list = []
|
self.title_list = []
|
||||||
@ -209,7 +214,7 @@ class PatchNames:
|
|||||||
name = p.get_primary_name()
|
name = p.get_primary_name()
|
||||||
name.set_first_name(grp[1])
|
name.set_first_name(grp[1])
|
||||||
p.set_nick_name(grp[2])
|
p.set_nick_name(grp[2])
|
||||||
self.db.commit_person(p)
|
self.db.commit_person(p,self.trans)
|
||||||
|
|
||||||
for grp in self.title_list:
|
for grp in self.title_list:
|
||||||
iter = self.title_hash[grp[0]]
|
iter = self.title_hash[grp[0]]
|
||||||
@ -219,7 +224,7 @@ class PatchNames:
|
|||||||
name = p.get_primary_name()
|
name = p.get_primary_name()
|
||||||
name.set_first_name(grp[2])
|
name.set_first_name(grp[2])
|
||||||
name.set_title(grp[1])
|
name.set_title(grp[1])
|
||||||
self.db.commit_person(p)
|
self.db.commit_person(p,self.trans)
|
||||||
|
|
||||||
self.close(obj)
|
self.close(obj)
|
||||||
self.cb(1)
|
self.cb(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user