2006-05-03 Alex Roitman <shura@gramps-project.org>
* src/plugins/ReorderIds.py (ReorderIds.reorder): Switch from cursors to keys iteration. svn: r6541
This commit is contained in:
parent
25ada65064
commit
2884c076bf
@ -1,3 +1,7 @@
|
|||||||
|
2006-05-03 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/plugins/ReorderIds.py (ReorderIds.reorder): Switch from
|
||||||
|
cursors to keys iteration.
|
||||||
|
|
||||||
2006-05-03 Don Allingham <don@gramps-project.org>
|
2006-05-03 Don Allingham <don@gramps-project.org>
|
||||||
* src/ViewManager.py: do a better job of building the buttons.
|
* src/ViewManager.py: do a better job of building the buttons.
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ from gettext import gettext as _
|
|||||||
import Utils
|
import Utils
|
||||||
import RelLib
|
import RelLib
|
||||||
from PluginUtils import Tool, register_tool
|
from PluginUtils import Tool, register_tool
|
||||||
from QuestionDialog import WarningDialog
|
|
||||||
|
|
||||||
_findint = re.compile('^[^\d]*(\d+)[^\d]*')
|
_findint = re.compile('^[^\d]*(\d+)[^\d]*')
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
db.get_person_from_gramps_id,
|
db.get_person_from_gramps_id,
|
||||||
db.get_person_from_handle,
|
db.get_person_from_handle,
|
||||||
db.find_next_person_gramps_id,
|
db.find_next_person_gramps_id,
|
||||||
db.get_person_cursor,
|
db.person_map,
|
||||||
db.commit_person,
|
db.commit_person,
|
||||||
db.iprefix)
|
db.iprefix)
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
db.get_family_from_gramps_id,
|
db.get_family_from_gramps_id,
|
||||||
db.get_family_from_handle,
|
db.get_family_from_handle,
|
||||||
db.find_next_family_gramps_id,
|
db.find_next_family_gramps_id,
|
||||||
db.get_family_cursor,
|
db.family_map,
|
||||||
db.commit_family,
|
db.commit_family,
|
||||||
db.fprefix)
|
db.fprefix)
|
||||||
if uistate:
|
if uistate:
|
||||||
@ -93,7 +92,7 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
db.get_event_from_gramps_id,
|
db.get_event_from_gramps_id,
|
||||||
db.get_event_from_handle,
|
db.get_event_from_handle,
|
||||||
db.find_next_event_gramps_id,
|
db.find_next_event_gramps_id,
|
||||||
db.get_event_cursor,
|
db.event_map,
|
||||||
db.commit_event,
|
db.commit_event,
|
||||||
db.eprefix)
|
db.eprefix)
|
||||||
if uistate:
|
if uistate:
|
||||||
@ -103,7 +102,7 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
db.get_object_from_gramps_id,
|
db.get_object_from_gramps_id,
|
||||||
db.get_object_from_handle,
|
db.get_object_from_handle,
|
||||||
db.find_next_object_gramps_id,
|
db.find_next_object_gramps_id,
|
||||||
db.get_media_cursor,
|
db.media_map,
|
||||||
db.commit_media_object,
|
db.commit_media_object,
|
||||||
db.oprefix)
|
db.oprefix)
|
||||||
if uistate:
|
if uistate:
|
||||||
@ -113,7 +112,7 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
db.get_source_from_gramps_id,
|
db.get_source_from_gramps_id,
|
||||||
db.get_source_from_handle,
|
db.get_source_from_handle,
|
||||||
db.find_next_source_gramps_id,
|
db.find_next_source_gramps_id,
|
||||||
db.get_source_cursor,
|
db.source_map,
|
||||||
db.commit_source,
|
db.commit_source,
|
||||||
db.sprefix)
|
db.sprefix)
|
||||||
if uistate:
|
if uistate:
|
||||||
@ -123,17 +122,17 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
db.get_place_from_gramps_id,
|
db.get_place_from_gramps_id,
|
||||||
db.get_place_from_handle,
|
db.get_place_from_handle,
|
||||||
db.find_next_place_gramps_id,
|
db.find_next_place_gramps_id,
|
||||||
db.get_place_cursor,
|
db.place_map,
|
||||||
db.commit_place,
|
db.commit_place,
|
||||||
db.pprefix)
|
db.pprefix)
|
||||||
if uistate:
|
if uistate:
|
||||||
self.progress.set_pass(_('Reordering Repository IDs'),
|
self.progress.set_pass(_('Reordering Repository IDs'),
|
||||||
db.get_number_of_repositories())
|
db.get_number_of_repositories())
|
||||||
self.reorder(RelLib.Place,
|
self.reorder(RelLib.Repository,
|
||||||
db.get_repository_from_gramps_id,
|
db.get_repository_from_gramps_id,
|
||||||
db.get_repository_from_handle,
|
db.get_repository_from_handle,
|
||||||
db.find_next_repository_gramps_id,
|
db.find_next_repository_gramps_id,
|
||||||
db.get_repository_cursor,
|
db.repository_map,
|
||||||
db.commit_repository,
|
db.commit_repository,
|
||||||
db.rprefix)
|
db.rprefix)
|
||||||
|
|
||||||
@ -145,19 +144,16 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
db.transaction_commit(self.trans,_("Reorder GRAMPS IDs"))
|
db.transaction_commit(self.trans,_("Reorder GRAMPS IDs"))
|
||||||
|
|
||||||
def reorder(self, class_type, find_from_id, find_from_handle,
|
def reorder(self, class_type, find_from_id, find_from_handle,
|
||||||
find_next_id, get_cursor, commit, prefix):
|
find_next_id, table, commit, prefix):
|
||||||
dups = []
|
dups = []
|
||||||
newids = {}
|
newids = {}
|
||||||
key_list = []
|
key_list = []
|
||||||
|
|
||||||
# search all ids in the map
|
for handle in table.keys():
|
||||||
|
|
||||||
cursor = get_cursor()
|
|
||||||
data = cursor.first()
|
|
||||||
while data:
|
|
||||||
if self.uistate:
|
if self.uistate:
|
||||||
self.progress.step()
|
self.progress.step()
|
||||||
(handle,sdata) = data
|
|
||||||
|
sdata = table[handle]
|
||||||
|
|
||||||
obj = class_type()
|
obj = class_type()
|
||||||
obj.unserialize(sdata)
|
obj.unserialize(sdata)
|
||||||
@ -187,9 +183,6 @@ class ReorderIds(Tool.BatchTool):
|
|||||||
else:
|
else:
|
||||||
dups.append(handle)
|
dups.append(handle)
|
||||||
|
|
||||||
data = cursor.next()
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user