Remove get_gramps_ids method from the public API

Issue #9541.
This commit is contained in:
Nick Hall 2017-09-29 23:10:45 +01:00
parent fc92bbcdba
commit d7cba793cf
8 changed files with 18 additions and 48 deletions

View File

@ -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.

View File

@ -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

View File

@ -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)
################################################################
#

View File

@ -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)

View File

@ -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

View File

@ -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",

View File

@ -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)

View File

@ -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()