diff --git a/gramps/gen/db/base.py b/gramps/gen/db/base.py index f3a91453d..533e11a95 100644 --- a/gramps/gen/db/base.py +++ b/gramps/gen/db/base.py @@ -847,12 +847,6 @@ class DbReadBase: """ raise NotImplementedError - def get_gramps_ids(self, obj_key): - """ - Returns all the keys from a table given a table name - """ - raise NotImplementedError - def get_mediapath(self): """ Return the default media path of the database. diff --git a/gramps/gen/db/dummydb.py b/gramps/gen/db/dummydb.py index 93f408a98..a31b65cc1 100644 --- a/gramps/gen/db/dummydb.py +++ b/gramps/gen/db/dummydb.py @@ -555,14 +555,6 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})): LOG.warning("database is closed") return [] - def get_gramps_ids(self, obj_key): - """ - Returns all the keys from a table given a table name - """ - if not self.db_is_open: - LOG.warning("database is closed") - return [] - def get_media_attribute_types(self): """ Return a list of all Attribute types associated with Media and MediaRef diff --git a/gramps/gen/db/generic.py b/gramps/gen/db/generic.py index 2eddc2c93..53ba4e118 100644 --- a/gramps/gen/db/generic.py +++ b/gramps/gen/db/generic.py @@ -1195,7 +1195,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): # ################################################################ - def get_gramps_ids(self, obj_key): + def _get_gramps_ids(self, obj_key): """ Return a list of Gramps IDs, one ID for each object in the database. @@ -1207,63 +1207,63 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): Return a list of Gramps IDs, one ID for each Person in the database. """ - return self.get_gramps_ids(PERSON_KEY) + return self._get_gramps_ids(PERSON_KEY) def get_family_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Family in the database. """ - return self.get_gramps_ids(FAMILY_KEY) + return self._get_gramps_ids(FAMILY_KEY) def get_source_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Source in the database. """ - return self.get_gramps_ids(SOURCE_KEY) + return self._get_gramps_ids(SOURCE_KEY) def get_citation_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Citation in the database. """ - return self.get_gramps_ids(CITATION_KEY) + return self._get_gramps_ids(CITATION_KEY) def get_event_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Event in the database. """ - return self.get_gramps_ids(EVENT_KEY) + return self._get_gramps_ids(EVENT_KEY) def get_media_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Media in the database. """ - return self.get_gramps_ids(MEDIA_KEY) + return self._get_gramps_ids(MEDIA_KEY) def get_place_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Place in the database. """ - return self.get_gramps_ids(PLACE_KEY) + return self._get_gramps_ids(PLACE_KEY) def get_repository_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Repository in the database. """ - return self.get_gramps_ids(REPOSITORY_KEY) + return self._get_gramps_ids(REPOSITORY_KEY) def get_note_gramps_ids(self): """ Return a list of Gramps IDs, one ID for each Note in the database. """ - return self.get_gramps_ids(NOTE_KEY) + return self._get_gramps_ids(NOTE_KEY) ################################################################ # diff --git a/gramps/gen/proxy/proxybase.py b/gramps/gen/proxy/proxybase.py index 362a8a1b6..a4f74739c 100644 --- a/gramps/gen/proxy/proxybase.py +++ b/gramps/gen/proxy/proxybase.py @@ -936,9 +936,6 @@ class ProxyDbBase(DbReadBase): """returns the default media path of the database""" return self.db.get_mediapath() - def get_gramps_ids(self, obj_key): - return self.db.get_gramps_ids(obj_key) - def has_gramps_id(self, obj_key, gramps_id): return self.db.has_gramps_id(obj_key, gramps_id) diff --git a/gramps/plugins/db/bsddb/read.py b/gramps/plugins/db/bsddb/read.py index e4bd998ee..9b686d810 100644 --- a/gramps/plugins/db/bsddb/read.py +++ b/gramps/plugins/db/bsddb/read.py @@ -1179,22 +1179,6 @@ class DbBsddbRead(DbReadBase, Callback): iter_tags = _f(get_tag_cursor, Tag) del _f - def get_gramps_ids(self, obj_key): - key2table = { - PERSON_KEY: self.id_trans, - FAMILY_KEY: self.fid_trans, - SOURCE_KEY: self.sid_trans, - CITATION_KEY: self.cid_trans, - EVENT_KEY: self.eid_trans, - MEDIA_KEY: self.oid_trans, - PLACE_KEY: self.pid_trans, - REPOSITORY_KEY: self.rid_trans, - NOTE_KEY: self.nid_trans, - } - - table = key2table[obj_key] - return [key.decode('utf-8') for key in table.keys()] - def has_gramps_id(self, obj_key, gramps_id): key2table = { PERSON_KEY: self.id_trans, @@ -1215,7 +1199,9 @@ class DbBsddbRead(DbReadBase, Callback): def find_initial_person(self): person = self.get_default_person() if not person: - the_ids = self.get_gramps_ids(PERSON_KEY) + the_ids = [] + for this_person in self.iter_people(): + the_ids.append(this_person.gramps_id) if the_ids: person = self.get_person_from_gramps_id(min(the_ids)) return person diff --git a/gramps/plugins/db/bsddb/test/db_test.py b/gramps/plugins/db/bsddb/test/db_test.py index f0c62ff4b..253655f47 100644 --- a/gramps/plugins/db/bsddb/test/db_test.py +++ b/gramps/plugins/db/bsddb/test/db_test.py @@ -57,7 +57,6 @@ class DbTest(unittest.TestCase): "get_family_from_handle", "get_family_handles", "get_family_relation_types", - "get_gramps_ids", "get_media_attribute_types", "get_media_bookmarks", "get_media_cursor", diff --git a/gramps/plugins/db/dbapi/dbapi.py b/gramps/plugins/db/dbapi/dbapi.py index 85635135a..6baecf977 100644 --- a/gramps/plugins/db/dbapi/dbapi.py +++ b/gramps/plugins/db/dbapi/dbapi.py @@ -833,7 +833,7 @@ class DBAPI(DbGeneric): self.dbapi.execute(sql, [gramps_id]) return self.dbapi.fetchone() != None - def get_gramps_ids(self, obj_key): + def _get_gramps_ids(self, obj_key): table = KEY_TO_NAME_MAP[obj_key] sql = "SELECT gramps_id FROM %s" % table self.dbapi.execute(sql) diff --git a/gramps/plugins/lib/libgedcom.py b/gramps/plugins/lib/libgedcom.py index 75ca172d3..c4d5975e3 100644 --- a/gramps/plugins/lib/libgedcom.py +++ b/gramps/plugins/lib/libgedcom.py @@ -1885,8 +1885,10 @@ class GedcomParser(UpdateCallback): self.maxpeople = stage_one.get_person_count() self.dbase = dbase self.import_researcher = self.dbase.get_total() == 0 - self.emapper = IdFinder(dbase.get_gramps_ids(EVENT_KEY), - dbase.event_prefix) + event_ids = [] + for event in dbase.iter_events(): + event_ids.append(event.gramps_id) + self.emapper = IdFinder(event_ids, dbase.event_prefix) self.famc_map = stage_one.get_famc_map() self.fams_map = stage_one.get_fams_map()