2006-11-07 Don Allingham <don@gramps-project.org>
* src/plugins/RemoveUnused.py: general cleanup svn: r7580
This commit is contained in:
parent
8b3c4359ef
commit
a1d3c6b68f
@ -1,3 +1,6 @@
|
|||||||
|
2006-11-07 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/plugins/RemoveUnused.py: general cleanup
|
||||||
|
|
||||||
2006-11-07 Alex Roitman <shura@gramps-project.org>
|
2006-11-07 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/DataViews/_RelationView.py (info_string): Add missing clause.
|
* src/DataViews/_RelationView.py (info_string): Add missing clause.
|
||||||
|
|
||||||
|
@ -75,11 +75,7 @@ class RemoveUnused:
|
|||||||
|
|
||||||
if self.db.readonly:
|
if self.db.readonly:
|
||||||
return
|
return
|
||||||
|
self.init_gui()
|
||||||
if uistate:
|
|
||||||
self.init_gui()
|
|
||||||
else:
|
|
||||||
self.run_tool(cli=True)
|
|
||||||
|
|
||||||
def init_gui(self):
|
def init_gui(self):
|
||||||
a = gtk.Dialog("%s - GRAMPS" % _('Remove unused objects'),
|
a = gtk.Dialog("%s - GRAMPS" % _('Remove unused objects'),
|
||||||
@ -150,70 +146,64 @@ class CheckIntegrity:
|
|||||||
self.event_cnt = 0
|
self.event_cnt = 0
|
||||||
self.progress = Utils.ProgressMeter(_('Checking database'),'')
|
self.progress = Utils.ProgressMeter(_('Checking database'),'')
|
||||||
|
|
||||||
def cleanup_events(self):
|
def _cleanup_map(self, title, no_events, db_map, remove_func):
|
||||||
self.progress.set_pass(_('Removing unused events'),
|
self.progress.set_pass(title, no_events)
|
||||||
self.db.get_number_of_events())
|
|
||||||
|
|
||||||
self.event_cnt = 0
|
cnt = 0
|
||||||
for handle in self.db.event_map.keys():
|
for handle in db_map.keys():
|
||||||
hlist = [ x for x in self.db.find_backlink_handles(handle)]
|
hlist = [ x for x in self.db.find_backlink_handles(handle)]
|
||||||
if len(hlist) == 0:
|
if len(hlist) == 0:
|
||||||
self.db.remove_event(handle, self.trans)
|
remove_func(handle, self.trans)
|
||||||
self.event_cnt += 1
|
cnt += 1
|
||||||
|
return cnt
|
||||||
|
|
||||||
|
def cleanup_events(self):
|
||||||
|
self.event_cnt = self._cleanup_map(
|
||||||
|
_('Removing unused events'),
|
||||||
|
self.db.get_number_of_events(),
|
||||||
|
self.db.event_map,
|
||||||
|
self.db.remove_event)
|
||||||
|
|
||||||
def cleanup_sources(self):
|
def cleanup_sources(self):
|
||||||
self.progress.set_pass(_('Removing unused sources'),
|
self.source_cnt = self._cleanup_map(
|
||||||
self.db.get_number_of_events())
|
_('Removing unused sources'),
|
||||||
|
self.db.get_number_of_sources(),
|
||||||
self.source_cnt = 0
|
self.db.source_map,
|
||||||
for handle in self.db.event_map.keys():
|
self.db.remove_source)
|
||||||
hlist = [ x for x in self.db.find_backlink_handles(handle)]
|
|
||||||
if len(hlist) == 0:
|
|
||||||
self.db.remove_source(handle, self.trans)
|
|
||||||
self.source_cnt += 1
|
|
||||||
|
|
||||||
def cleanup_places(self):
|
def cleanup_places(self):
|
||||||
self.progress.set_pass(_('Removing unused places'),
|
self.place_cnt = self._cleanup_map(
|
||||||
self.db.get_number_of_places())
|
_('Removing unused places'),
|
||||||
|
self.db.get_number_of_places(),
|
||||||
|
self.db.place_map,
|
||||||
|
self.db.remove_place)
|
||||||
|
|
||||||
self.place_cnt = 0
|
def build_report(self):
|
||||||
for handle in self.db.place_map.keys():
|
|
||||||
hlist = [ x for x in self.db.find_backlink_handles(handle)]
|
|
||||||
if len(hlist) == 0:
|
|
||||||
self.db.remove_place(handle, self.trans)
|
|
||||||
self.place_cnt += 1
|
|
||||||
|
|
||||||
def build_report(self,cl=0):
|
|
||||||
self.progress.close()
|
self.progress.close()
|
||||||
|
|
||||||
errors = self.event_cnt + self.source_cnt + self.place_cnt
|
errors = self.event_cnt + self.source_cnt + self.place_cnt
|
||||||
|
|
||||||
if errors == 0:
|
if errors == 0:
|
||||||
if cl:
|
OkDialog(_("No unreferenced objects were found."),
|
||||||
print "No unreferenced objects were found."
|
_('The database has passed internal checks'))
|
||||||
else:
|
|
||||||
OkDialog(_("No unreferenced objects were found."),
|
|
||||||
_('The database has passed internal checks'))
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
self.text = cStringIO.StringIO()
|
self.text = cStringIO.StringIO()
|
||||||
if self.event_cnt > 0:
|
|
||||||
if self.event_cnt == 1:
|
|
||||||
self.text.write(_("1 non-referenced event removed\n"))
|
|
||||||
else:
|
|
||||||
self.text.write(_("%d non-referenced event removed\n") % self.event_cnt)
|
|
||||||
|
|
||||||
if self.source_cnt > 0:
|
if self.event_cnt == 1:
|
||||||
if self.source_cnt == 1:
|
self.text.write(_("1 non-referenced event removed\n"))
|
||||||
self.text.write(_("1 non-referenced source removed\n"))
|
elif self.event_cnt > 1:
|
||||||
else:
|
self.text.write(_("%d non-referenced events removed\n") % self.event_cnt)
|
||||||
self.text.write(_("%d non-referenced source removed\n") % self.source_cnt)
|
|
||||||
|
|
||||||
if self.place_cnt > 0:
|
if self.source_cnt == 1:
|
||||||
if self.place_cnt == 1:
|
self.text.write(_("1 non-referenced source removed\n"))
|
||||||
self.text.write(_("1 non-referenced place removed\n"))
|
elif self.source_cnt > 1:
|
||||||
else:
|
self.text.write(_("%d non-referenced sources removed\n") % self.source_cnt)
|
||||||
self.text.write(_("%d non-referenced place removed\n") % self.place_cnt)
|
|
||||||
|
if self.place_cnt == 1:
|
||||||
|
self.text.write(_("1 non-referenced place removed\n"))
|
||||||
|
elif self.place_cnt > 1:
|
||||||
|
self.text.write(_("%d non-referenced places removed\n") % self.place_cnt)
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user