* src/plugins/ReorderIds.py: Adapt to new API; rebuild for Events

and Repositories.


svn: r6459
This commit is contained in:
Alex Roitman 2006-04-27 01:56:42 +00:00
parent 7b3030a87f
commit f8f0ac3e30
2 changed files with 38 additions and 15 deletions

View File

@ -1,5 +1,6 @@
2006-04-26 Alex Roitman <shura@gramps-project.org> 2006-04-26 Alex Roitman <shura@gramps-project.org>
* src/plugins/ReorderIds.py: Adapt to new API; rebuild for Events
and Repositories.
* src/GrampsLogger/_ErrorReportAssistant.py * src/GrampsLogger/_ErrorReportAssistant.py
(ErrorReportAssistant._get_sys_information): Add LANG to report. (ErrorReportAssistant._get_sys_information): Add LANG to report.

View File

@ -51,18 +51,19 @@ _findint = re.compile('^[^\d]*(\d+)[^\d]*')
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ReorderIds(Tool.Tool): class ReorderIds(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None): def __init__(self,dbstate,uistate,options_class,name,callback=None):
Tool.Tool.__init__(self,db,person,options_class,name) Tool.Tool.__init__(self,dbstate,options_class,name)
self.parent = parent db = dbstate.db
if parent: self.uistate = uistate
if uistate:
self.progress = Utils.ProgressMeter(_('Reordering GRAMPS IDs'),'') self.progress = Utils.ProgressMeter(_('Reordering GRAMPS IDs'),'')
else: else:
print "Reordering GRAMPS IDs..." print "Reordering GRAMPS IDs..."
self.trans = db.transaction_begin() self.trans = db.transaction_begin()
if parent: if uistate:
self.progress.set_pass(_('Reordering People IDs'), self.progress.set_pass(_('Reordering People IDs'),
db.get_number_of_people()) db.get_number_of_people())
self.reorder(RelLib.Person, self.reorder(RelLib.Person,
@ -73,7 +74,7 @@ class ReorderIds(Tool.Tool):
db.commit_person, db.commit_person,
db.iprefix) db.iprefix)
if parent: if uistate:
self.progress.set_pass(_('Reordering Family IDs'), self.progress.set_pass(_('Reordering Family IDs'),
db.get_number_of_families()) db.get_number_of_families())
self.reorder(RelLib.Family, self.reorder(RelLib.Family,
@ -83,7 +84,17 @@ class ReorderIds(Tool.Tool):
db.get_family_cursor, db.get_family_cursor,
db.commit_family, db.commit_family,
db.fprefix) db.fprefix)
if parent: if uistate:
self.progress.set_pass(_('Reordering Event IDs'),
db.get_number_of_events())
self.reorder(RelLib.Event,
db.get_event_from_gramps_id,
db.get_event_from_handle,
db.find_next_event_gramps_id,
db.get_event_cursor,
db.commit_event,
db.eprefix)
if uistate:
self.progress.set_pass(_('Reordering Media Object IDs'), self.progress.set_pass(_('Reordering Media Object IDs'),
db.get_number_of_media_objects()) db.get_number_of_media_objects())
self.reorder(RelLib.MediaObject, self.reorder(RelLib.MediaObject,
@ -93,7 +104,7 @@ class ReorderIds(Tool.Tool):
db.get_media_cursor, db.get_media_cursor,
db.commit_media_object, db.commit_media_object,
db.oprefix) db.oprefix)
if parent: if uistate:
self.progress.set_pass(_('Reordering Source IDs'), self.progress.set_pass(_('Reordering Source IDs'),
db.get_number_of_sources()) db.get_number_of_sources())
self.reorder(RelLib.Source, self.reorder(RelLib.Source,
@ -103,7 +114,7 @@ class ReorderIds(Tool.Tool):
db.get_source_cursor, db.get_source_cursor,
db.commit_source, db.commit_source,
db.sprefix) db.sprefix)
if parent: if uistate:
self.progress.set_pass(_('Reordering Place IDs'), self.progress.set_pass(_('Reordering Place IDs'),
db.get_number_of_places()) db.get_number_of_places())
self.reorder(RelLib.Place, self.reorder(RelLib.Place,
@ -113,7 +124,18 @@ class ReorderIds(Tool.Tool):
db.get_place_cursor, db.get_place_cursor,
db.commit_place, db.commit_place,
db.pprefix) db.pprefix)
if parent: if uistate:
self.progress.set_pass(_('Reordering Repository IDs'),
db.get_number_of_repositories())
self.reorder(RelLib.Place,
db.get_repository_from_gramps_id,
db.get_repository_from_handle,
db.find_next_repository_gramps_id,
db.get_repository_cursor,
db.commit_repository,
db.rprefix)
if uistate:
self.progress.close() self.progress.close()
else: else:
print "Done." print "Done."
@ -131,7 +153,7 @@ class ReorderIds(Tool.Tool):
cursor = get_cursor() cursor = get_cursor()
data = cursor.first() data = cursor.first()
while data: while data:
if self.parent: if self.uistate:
self.progress.step() self.progress.step()
(handle,sdata) = data (handle,sdata) = data
@ -169,11 +191,11 @@ class ReorderIds(Tool.Tool):
# go through the duplicates, looking for the first availble # go through the duplicates, looking for the first availble
# handle that matches the new scheme. # handle that matches the new scheme.
if self.parent: if self.uistate:
self.progress.set_pass(_('Finding and assigning unused IDs'), self.progress.set_pass(_('Finding and assigning unused IDs'),
len(dups)) len(dups))
for handle in dups: for handle in dups:
if self.parent: if self.uistate:
self.progress.step() self.progress.step()
obj = find_from_handle(handle) obj = find_from_handle(handle)
obj.set_gramps_id(find_next_id()) obj.set_gramps_id(find_next_id())