Modify to avoid using table maps

This commit is contained in:
Nick Hall 2016-10-17 23:25:33 +01:00
parent 1494b5d28e
commit 662c5c8866
2 changed files with 80 additions and 129 deletions

View File

@ -121,10 +121,16 @@ def cross_table_duplicates(db, uistate):
logging.info('Looking for cross table duplicates') logging.info('Looking for cross table duplicates')
total_nr_handles = 0 total_nr_handles = 0
all_handles = set([]) all_handles = set([])
for the_map in [db.person_map, db.family_map, db.event_map, db.place_map, for get_handles_func in [db.get_person_handles,
db.source_map, db.citation_map, db.media_map, db.get_family_handles,
db.repository_map, db.note_map]: db.get_event_handles,
handle_list = list(the_map.keys()) db.get_place_handles,
db.get_source_handles,
db.get_citation_handles,
db.get_media_handles,
db.get_repository_handles,
db.get_note_handles]:
handle_list = get_handles_func()
total_nr_handles += len(handle_list) total_nr_handles += len(handle_list)
all_handles.update(handle_list) all_handles.update(handle_list)
progress.step() progress.step()
@ -349,10 +355,9 @@ class CheckIntegrity:
logging.info('Looking for duplicate spouses') logging.info('Looking for duplicate spouses')
previous_errors = len(self.duplicate_links) previous_errors = len(self.duplicate_links)
for bhandle in self.db.person_map.keys(): for bhandle in self.db.get_person_handles():
handle = bhandle.decode('utf-8') handle = bhandle.decode('utf-8')
value = self.db.person_map[bhandle] pers = self.db.get_person_from_handle(handle)
pers = Person(value)
splist = pers.get_family_handle_list() splist = pers.get_family_handle_list()
if len(splist) != len(set(splist)): if len(splist) != len(set(splist)):
new_list = [] new_list = []
@ -372,7 +377,7 @@ class CheckIntegrity:
self.db.get_number_of_media()) self.db.get_number_of_media())
logging.info('Looking for character encoding errors') logging.info('Looking for character encoding errors')
error_count = 0 error_count = 0
for bhandle in self.db.media_map.keys(): for bhandle in self.db.get_media_handles():
handle = bhandle.decode('utf-8') handle = bhandle.decode('utf-8')
data = self.db.media_map[bhandle] data = self.db.media_map[bhandle]
if not isinstance(data[2], str) or not isinstance(data[4], str): if not isinstance(data[2], str) or not isinstance(data[4], str):
@ -413,7 +418,7 @@ class CheckIntegrity:
self.db.get_number_of_notes()) self.db.get_number_of_notes())
logging.info('Looking for ctrl characters in notes') logging.info('Looking for ctrl characters in notes')
error_count = 0 error_count = 0
for bhandle in self.db.note_map.keys(): for bhandle in self.db.get_note_handles():
handle = bhandle.decode('utf-8') handle = bhandle.decode('utf-8')
note = self.db.get_note_from_handle(handle) note = self.db.get_note_from_handle(handle)
stext = note.get_styledtext() stext = note.get_styledtext()
@ -421,7 +426,7 @@ class CheckIntegrity:
new_text = old_text.translate(strip_dict) new_text = old_text.translate(strip_dict)
if old_text != new_text: if old_text != new_text:
logging.warning(' FAIL: control characters found in note' logging.warning(' FAIL: control characters found in note'
' "%s"', self.db.note_map[bhandle][1]) ' "%s"', note.get_gramps_id())
error_count += 1 error_count += 1
# Commit only if ctrl char found. # Commit only if ctrl char found.
note.set_styledtext(StyledText(text=new_text, note.set_styledtext(StyledText(text=new_text,
@ -440,7 +445,7 @@ class CheckIntegrity:
self.progress.set_pass(_('Looking for bad alternate place names'), self.progress.set_pass(_('Looking for bad alternate place names'),
self.db.get_number_of_places()) self.db.get_number_of_places())
logging.info('Looking for bad alternate place names') logging.info('Looking for bad alternate place names')
for bhandle in self.db.place_map.keys(): for bhandle in self.db.get_place_handles():
handle = bhandle.decode('utf-8') handle = bhandle.decode('utf-8')
place = self.db.get_place_from_handle(handle) place = self.db.get_place_from_handle(handle)
fixed_alt_names = [] fixed_alt_names = []
@ -1440,11 +1445,9 @@ class CheckIntegrity:
total) total)
logging.info('Looking for citation reference problems') logging.info('Looking for citation reference problems')
for bhandle in self.db.person_map.keys(): for bhandle in self.db.get_person_handles():
self.progress.step() self.progress.step()
info = self.db.person_map[bhandle] person = self.db.get_person_from_handle(bhandle)
person = Person()
person.unserialize(info)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1456,11 +1459,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.family_map.keys(): for bhandle in self.db.get_family_handles():
self.progress.step() self.progress.step()
info = self.db.family_map[bhandle] family = self.db.get_family_from_handle(bhandle)
family = Family()
family.unserialize(info)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1472,11 +1473,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.place_map.keys(): for bhandle in self.db.get_place_handles():
self.progress.step() self.progress.step()
info = self.db.place_map[bhandle] place = self.db.get_place_from_handle(bhandle)
place = Place()
place.unserialize(info)
handle_list = place.get_referenced_handles_recursively() handle_list = place.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1488,11 +1487,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.citation_map.keys(): for bhandle in self.db.get_citation_handles():
self.progress.step() self.progress.step()
info = self.db.citation_map[bhandle] citation = self.db.get_citation_from_handle(bhandle)
citation = Citation()
citation.unserialize(info)
handle_list = citation.get_referenced_handles_recursively() handle_list = citation.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1504,11 +1501,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.repository_map.keys(): for bhandle in self.db.get_repository_handles():
self.progress.step() self.progress.step()
info = self.db.repository_map[bhandle] repository = self.db.get_repository_from_handle(bhandle)
repository = Repository()
repository.unserialize(info)
handle_list = repository.get_referenced_handles_recursively() handle_list = repository.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1521,11 +1516,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.media_map.keys(): for bhandle in self.db.get_media_handles():
self.progress.step() self.progress.step()
info = self.db.media_map[bhandle] obj = self.db.get_media_from_handle(bhandle)
obj = Media()
obj.unserialize(info)
handle_list = obj.get_referenced_handles_recursively() handle_list = obj.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1537,11 +1530,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_citation_references.add(item[1]) self.invalid_citation_references.add(item[1])
for bhandle in self.db.event_map.keys(): for bhandle in self.db.get_event_handles():
self.progress.step() self.progress.step()
info = self.db.event_map[bhandle] event = self.db.get_event_from_handle(bhandle)
event = Event()
event.unserialize(info)
handle_list = event.get_referenced_handles_recursively() handle_list = event.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Citation': if item[0] == 'Citation':
@ -1616,11 +1607,9 @@ class CheckIntegrity:
'problems'), total) 'problems'), total)
logging.info('Looking for media object reference problems') logging.info('Looking for media object reference problems')
for bhandle in self.db.person_map.keys(): for bhandle in self.db.get_person_handles():
self.progress.step() self.progress.step()
info = self.db.person_map[bhandle] person = self.db.get_person_from_handle(bhandle)
person = Person()
person.unserialize(info)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1632,11 +1621,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.family_map.keys(): for bhandle in self.db.get_family_handles():
self.progress.step() self.progress.step()
info = self.db.family_map[bhandle] family = self.db.get_family_from_handle(bhandle)
family = Family()
family.unserialize(info)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1648,11 +1635,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.place_map.keys(): for bhandle in self.db.get_place_handles():
self.progress.step() self.progress.step()
info = self.db.place_map[bhandle] place = self.db.get_place_from_handle(bhandle)
place = Place()
place.unserialize(info)
handle_list = place.get_referenced_handles_recursively() handle_list = place.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1664,11 +1649,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.event_map.keys(): for bhandle in self.db.get_event_handles():
self.progress.step() self.progress.step()
info = self.db.event_map[bhandle] event = self.db.get_event_from_handle(bhandle)
event = Event()
event.unserialize(info)
handle_list = event.get_referenced_handles_recursively() handle_list = event.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1680,11 +1663,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.citation_map.keys(): for bhandle in self.db.get_citation_handles():
self.progress.step() self.progress.step()
info = self.db.citation_map[bhandle] citation = self.db.get_citation_from_handle(bhandle)
citation = Citation()
citation.unserialize(info)
handle_list = citation.get_referenced_handles_recursively() handle_list = citation.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1696,11 +1677,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_media_references.add(item[1]) self.invalid_media_references.add(item[1])
for bhandle in self.db.source_map.keys(): for bhandle in self.db.get_source_handles():
self.progress.step() self.progress.step()
info = self.db.source_map[bhandle] source = self.db.get_source_from_handle(bhandle)
source = Source()
source.unserialize(info)
handle_list = source.get_referenced_handles_recursively() handle_list = source.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Media': if item[0] == 'Media':
@ -1751,11 +1730,9 @@ class CheckIntegrity:
total) total)
logging.info('Looking for note reference problems') logging.info('Looking for note reference problems')
for bhandle in self.db.person_map.keys(): for bhandle in self.db.get_person_handles():
self.progress.step() self.progress.step()
info = self.db.person_map[bhandle] person = self.db.get_person_from_handle(bhandle)
person = Person()
person.unserialize(info)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1767,11 +1744,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.family_map.keys(): for bhandle in self.db.get_family_handles():
self.progress.step() self.progress.step()
info = self.db.family_map[bhandle] family = self.db.get_family_from_handle(bhandle)
family = Family()
family.unserialize(info)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1783,11 +1758,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.place_map.keys(): for bhandle in self.db.get_place_handles():
self.progress.step() self.progress.step()
info = self.db.place_map[bhandle] place = self.db.get_place_from_handle(bhandle)
place = Place()
place.unserialize(info)
handle_list = place.get_referenced_handles_recursively() handle_list = place.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1799,11 +1772,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.citation_map.keys(): for bhandle in self.db.get_citation_handles():
self.progress.step() self.progress.step()
info = self.db.citation_map[bhandle] citation = self.db.get_citation_from_handle(bhandle)
citation = Citation()
citation.unserialize(info)
handle_list = citation.get_referenced_handles_recursively() handle_list = citation.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1815,11 +1786,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.source_map.keys(): for bhandle in self.db.get_source_handles():
self.progress.step() self.progress.step()
info = self.db.source_map[bhandle] source = self.db.get_source_from_handle(bhandle)
source = Source()
source.unserialize(info)
handle_list = source.get_referenced_handles_recursively() handle_list = source.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1831,11 +1800,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.media_map.keys(): for bhandle in self.db.get_media_handles():
self.progress.step() self.progress.step()
info = self.db.media_map[bhandle] obj = self.db.get_media_from_handle(bhandle)
obj = Media()
obj.unserialize(info)
handle_list = obj.get_referenced_handles_recursively() handle_list = obj.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1847,11 +1814,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.event_map.keys(): for bhandle in self.db.get_event_handles():
self.progress.step() self.progress.step()
info = self.db.event_map[bhandle] event = self.db.get_event_from_handle(bhandle)
event = Event()
event.unserialize(info)
handle_list = event.get_referenced_handles_recursively() handle_list = event.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1863,11 +1828,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_note_references.add(item[1]) self.invalid_note_references.add(item[1])
for bhandle in self.db.repository_map.keys(): for bhandle in self.db.get_repository_handles():
self.progress.step() self.progress.step()
info = self.db.repository_map[bhandle] repo = self.db.get_repository_from_handle(bhandle)
repo = Repository()
repo.unserialize(info)
handle_list = repo.get_referenced_handles_recursively() handle_list = repo.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Note': if item[0] == 'Note':
@ -1918,11 +1881,9 @@ class CheckIntegrity:
total) total)
logging.info('Looking for tag reference problems') logging.info('Looking for tag reference problems')
for bhandle in self.db.person_map.keys(): for bhandle in self.db.get_person_handles():
self.progress.step() self.progress.step()
info = self.db.person_map[bhandle] person = self.db.get_person_from_handle(bhandle)
person = Person()
person.unserialize(info)
handle_list = person.get_referenced_handles_recursively() handle_list = person.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1934,11 +1895,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.family_map.keys(): for bhandle in self.db.get_family_handles():
self.progress.step() self.progress.step()
info = self.db.family_map[bhandle] family = self.db.get_family_from_handle(bhandle)
family = Family()
family.unserialize(info)
handle_list = family.get_referenced_handles_recursively() handle_list = family.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1950,11 +1909,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.media_map.keys(): for bhandle in self.db.get_media_handles():
self.progress.step() self.progress.step()
info = self.db.media_map[bhandle] obj = self.db.get_media_from_handle(bhandle)
obj = Media()
obj.unserialize(info)
handle_list = obj.get_referenced_handles_recursively() handle_list = obj.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -1966,11 +1923,9 @@ class CheckIntegrity:
elif item[1] not in known_handles: elif item[1] not in known_handles:
self.invalid_tag_references.add(item[1]) self.invalid_tag_references.add(item[1])
for bhandle in self.db.note_map.keys(): for bhandle in self.db.get_note_handles():
self.progress.step() self.progress.step()
info = self.db.note_map[bhandle] note = self.db.get_note_from_handle(bhandle)
note = Note()
note.unserialize(info)
handle_list = note.get_referenced_handles_recursively() handle_list = note.get_referenced_handles_recursively()
for item in handle_list: for item in handle_list:
if item[0] == 'Tag': if item[0] == 'Tag':
@ -2001,11 +1956,9 @@ class CheckIntegrity:
'problems'), total) 'problems'), total)
logging.info('Looking for media source reference problems') logging.info('Looking for media source reference problems')
for handle in self.db.source_map.keys(): for handle in self.db.get_source_handles():
self.progress.step() self.progress.step()
info = self.db.source_map[handle] source = self.db.get_source_from_handle(handle)
source = Source()
source.unserialize(info)
new_media_ref_list = [] new_media_ref_list = []
for media_ref in source.get_media_list(): for media_ref in source.get_media_list():
citation_list = media_ref.get_citation_list() citation_list = media_ref.get_citation_list()

View File

@ -80,7 +80,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.person_map, db.get_person_handles,
db.commit_person, db.commit_person,
db.person_prefix) db.person_prefix)
@ -91,7 +91,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.family_map, db.get_family_handles,
db.commit_family, db.commit_family,
db.family_prefix) db.family_prefix)
if uistate: if uistate:
@ -101,7 +101,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.event_map, db.get_event_handles,
db.commit_event, db.commit_event,
db.event_prefix) db.event_prefix)
if uistate: if uistate:
@ -111,7 +111,7 @@ class ReorderIds(tool.BatchTool):
db.get_media_from_gramps_id, db.get_media_from_gramps_id,
db.get_media_from_handle, db.get_media_from_handle,
db.find_next_media_gramps_id, db.find_next_media_gramps_id,
db.media_map, db.get_media_handles,
db.commit_media, db.commit_media,
db.media_prefix) db.media_prefix)
if uistate: if uistate:
@ -121,7 +121,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.source_map, db.get_source_handles,
db.commit_source, db.commit_source,
db.source_prefix) db.source_prefix)
if uistate: if uistate:
@ -131,7 +131,7 @@ class ReorderIds(tool.BatchTool):
db.get_citation_from_gramps_id, db.get_citation_from_gramps_id,
db.get_citation_from_handle, db.get_citation_from_handle,
db.find_next_citation_gramps_id, db.find_next_citation_gramps_id,
db.citation_map, db.get_citation_handles,
db.commit_citation, db.commit_citation,
db.citation_prefix) db.citation_prefix)
if uistate: if uistate:
@ -141,7 +141,7 @@ 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.place_map, db.get_place_handles,
db.commit_place, db.commit_place,
db.place_prefix) db.place_prefix)
if uistate: if uistate:
@ -151,7 +151,7 @@ class ReorderIds(tool.BatchTool):
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.repository_map, db.get_repository_handles,
db.commit_repository, db.commit_repository,
db.repository_prefix) db.repository_prefix)
#add reorder notes ID #add reorder notes ID
@ -162,7 +162,7 @@ class ReorderIds(tool.BatchTool):
db.get_note_from_gramps_id, db.get_note_from_gramps_id,
db.get_note_from_handle, db.get_note_from_handle,
db.find_next_note_gramps_id, db.find_next_note_gramps_id,
db.note_map, db.get_note_handles,
db.commit_note, db.commit_note,
db.note_prefix) db.note_prefix)
if uistate: if uistate:
@ -174,20 +174,18 @@ class ReorderIds(tool.BatchTool):
db.request_rebuild() db.request_rebuild()
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, table, commit, prefix): find_next_id, find_handles, commit, prefix):
dups = [] dups = []
newids = {} newids = {}
formatmatch = _parseformat.match(prefix) formatmatch = _parseformat.match(prefix)
for handle in list(table.keys()): for handle in find_handles():
if self.uistate: if self.uistate:
self.progress.step() self.progress.step()
sdata = table[handle] obj = find_from_handle(handle)
obj = class_type()
obj.unserialize(sdata)
gramps_id = obj.get_gramps_id() gramps_id = obj.get_gramps_id()
# attempt to extract integer, if we can't, treat it as a # attempt to extract integer, if we can't, treat it as a
# duplicate # duplicate