diff --git a/src/plugins/import/ImportGrdb.py b/src/plugins/import/ImportGrdb.py index 89b6097f1..2a4000b7e 100644 --- a/src/plugins/import/ImportGrdb.py +++ b/src/plugins/import/ImportGrdb.py @@ -1050,14 +1050,14 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # Now we use the functions and classes defined above # to loop through each of the primary object tables. - for primary_table_name in primary_tables.keys(): + for primary_table_name, primary_table_dict in primary_tables.iteritems(): - cursor = primary_tables[primary_table_name]['cursor_func']() + cursor = primary_table_dict['cursor_func']() data = cursor.first() # Grab the real object class here so that the lookup does # not happen inside the cursor loop. - class_func = primary_tables[primary_table_name]['class_func'] + class_func = primary_table_dict['class_func'] while data: found_handle, val = data obj = class_func() @@ -1331,6 +1331,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): The function must be overridden in the derived class. """ name = str(person.get_primary_name().get_surname()) + print type(surnames) try: if self.surnames.keys().count(name) == 1: self.surname_list.remove(unicode(name)) @@ -1670,9 +1671,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): + self.get_number_of_families() self.set_total(length) - for handle in self.event_map.keys(): - info = self.event_map[handle] - + for handle, info in self.event_map.iteritems(): + (junk_handle, gramps_id, the_type, date, description, place, cause, source_list, note, media_list, change, marker, private) = info @@ -1703,9 +1703,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): self.event_map.sync() # Personal event references - for handle in self.person_map.keys(): - info = self.person_map[handle] - + for handle, info in self.person_map.iteritems(): + (junk_handle, gramps_id, gender, primary_name, alternate_names, death_ref_index, birth_ref_index, event_ref_list, family_list, @@ -1743,8 +1742,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): self.person_map.sync() # Family event references - for handle in self.family_map.keys(): - info = self.family_map[handle] + for handle, info in self.family_map.iteritems(): (junk_handle, gramps_id, father_handle, mother_handle, child_ref_list, the_type, event_ref_list, @@ -1796,9 +1794,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): self.set_total(length) # Personal addresses - for handle in self.person_map.keys(): - info = self.person_map[handle] - + for handle, info in self.person_map.iteritems(): + (junk_handle, gramps_id, gender, primary_name, alternate_names, death_ref_index, birth_ref_index, event_ref_list, family_list, @@ -1830,8 +1827,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): self.person_map.sync() # Repositories - for handle in self.repository_map.keys(): - info = self.repository_map[handle] + for handle, info in self.repository_map.iteritems(): (junk_handle, gramps_id, the_type, name, note, address_list, urls, marker, private) = info @@ -1855,8 +1851,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): self.repository_map.sync() # Places - for handle in self.place_map.keys(): - info = self.place_map[handle] + for handle, info in self.place_map.iteritems(): (junk_handle, gramps_id, title, long, lat, main_loc, alt_loc, urls, media_list, source_list, note, change, marker, private) = info @@ -1949,50 +1944,50 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): self.change_13 = int(time.time()) # Person upgrade - for handle in self.person_map.keys(): - info = self.person_map[handle] + for handle, info in self.person_map.iteritems(): + (new_info, note_handles) = self.convert_notes_13('Person', info) self.commit_13(new_info, PERSON_KEY, self.person_map, note_handles) self.update() # Family upgrade - for handle in self.family_map.keys(): - info = self.family_map[handle] + for handle, info in self.family_map.iteritems(): + (new_info, note_handles) = self.convert_notes_13('Family', info) self.commit_13(new_info, FAMILY_KEY, self.family_map, note_handles) self.update() # Event upgrade - for handle in self.event_map.keys(): - info = self.event_map[handle] + for handle, info in self.event_map.iteritems(): + (new_info, note_handles) = self.convert_notes_13('Event', info) self.commit_13(new_info, EVENT_KEY, self.event_map, note_handles) self.update() # Source upgrade - for handle in self.source_map.keys(): - info = self.source_map[handle] + for handle, info in self.source_map.iteritems(): + (new_info, note_handles) = self.convert_notes_13('Source', info) self.commit_13(new_info, SOURCE_KEY, self.source_map, note_handles) self.update() # Place upgrade - for handle in self.place_map.keys(): - info = self.place_map[handle] + for handle, info in self.place_map.iteritems(): + (new_info, note_handles) = self.convert_notes_13('Place', info) self.commit_13(new_info, PLACE_KEY, self.place_map, note_handles) self.update() # Media upgrade - for handle in self.media_map.keys(): - info = self.media_map[handle] + for handle, info in self.media_map.iteritems(): + (new_info, note_handles) = self.convert_notes_13('MediaObject', info) self.commit_13(new_info, MEDIA_KEY, self.media_map, note_handles) self.update() # Repo upgrade - for handle in self.repository_map.keys(): - info = self.repository_map[handle] + for handle, info in self.repository_map.iteritems(): + (new_info, note_handles) = self.convert_notes_13('Repository', info) self.commit_13(new_info, REPOSITORY_KEY, self.repository_map, note_handles) @@ -2404,8 +2399,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # Modify Notes # --------------------------------- # replace clear text with StyledText in Notes - for handle in self.note_map.keys(): - note = self.note_map[handle] + for handle, note in self.note_map.iteritems(): + (junk_handle, gramps_id, text, format, note_type, change, marker, private) = note styled_text = (text, []) @@ -2420,8 +2415,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # Modify Event # --------------------------------- # update dates with newyear - for handle in self.event_map.keys(): - event = self.event_map[handle] + for handle, event in self.event_map.iteritems(): + (junk_handle, gramps_id, the_type, date, description, place, source_list, note_list, media_list, attribute_list, change, marker, private) = event @@ -2441,8 +2436,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # Modify Person # --------------------------------- # update dates with newyear - for handle in self.person_map.keys(): - person = self.person_map[handle] + for handle, person in self.person_map.iteritems(): + (junk_handle, # 0 gramps_id, # 1 gender, # 2 @@ -2523,8 +2518,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # Modify Family # --------------------------------- # update dates with newyear - for handle in self.family_map.keys(): - family = self.family_map[handle] + for handle, family in self.family_map.iteritems(): + (junk_handle, gramps_id, father_handle, mother_handle, child_ref_list, the_type, event_ref_list, media_list, attribute_list, lds_seal_list, source_list, note_list, @@ -2554,8 +2549,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # Modify Repository # --------------------------------- # update dates with newyear - for handle in self.repository_map.keys(): - repository = self.repository_map[handle] + for handle, repository in self.repository_map.iteritems(): + # address (junk_handle, gramps_id, the_type, name, note_list, address_list, urls, change, marker, private) = repository @@ -2579,8 +2574,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # --------------------------------- # Modify Media # --------------------------------- - for media_handle in self.media_map.keys(): - media = self.media_map[media_handle] + for media_handle, media in self.media_map.iteritems(): + (handle, gramps_id, path, mime, desc, attribute_list, source_list, note_list, change, date, marker, private) = media @@ -2598,8 +2593,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # --------------------------------- # Modify Place # --------------------------------- - for place_handle in self.place_map.keys(): - place = self.place_map[place_handle] + for place_handle, place in self.place_map.iteritems(): + (handle, gramps_id, title, long, lat, main_loc, alt_loc, urls, media_list, source_list, note_list, change, marker, private) = place @@ -2617,8 +2612,8 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): # --------------------------------- # Modify Source # --------------------------------- - for source_handle in self.source_map.keys(): - source = self.source_map[source_handle] + for source_handle, source in self.source_map.iteritems(): + (handle, gramps_id, title, author, pubinfo, note_list, media_list, abbrev, change, datamap, reporef_list, @@ -2871,13 +2866,13 @@ def importData(database, filename, callback=None, cl=0): } uc = UpdateCallback(callback) - uc.set_total(len(tables.keys())) + uc.set_total(len(tables)) the_len = 0 # Check for duplicate handles. - for key in tables: - table_dict = tables[key] + for key, table_dict in tables.iteritems(): + table = table_dict['table'] other_table = table_dict['other_table'] msg = '%s handles in two databases overlap.' % key @@ -2954,7 +2949,7 @@ def check_common_handles(table, other_table, msg): def import_table(id_table, add_obj, find_next_gramps_id, other_table, other_get_from_handle, trans, uc): - for handle in other_table.keys(): + for handle in other_table: obj = other_get_from_handle(handle) # Then we check gramps_id for conflicts and change it if needed