From 755254cf7c6a2b21e45030bd9404f4abf1830a3f Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Fri, 29 Sep 2017 19:42:39 +0100 Subject: [PATCH] Remove get_from_name_and_gramps_id method Issue #9541. --- gramps/gen/db/generic.py | 15 --------------- gramps/gui/editors/editreference.py | 3 ++- gramps/plugins/db/bsddb/read.py | 15 --------------- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/gramps/gen/db/generic.py b/gramps/gen/db/generic.py index e6abf04df..9fbd88561 100644 --- a/gramps/gen/db/generic.py +++ b/gramps/gen/db/generic.py @@ -800,21 +800,6 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback): return self._get_table_func(table_name) return None - def get_from_name_and_gramps_id(self, table_name, gramps_id): - """ - Returns a gen.lib object (or None) given table_name and - Gramps ID. - - Examples: - - >>> self.get_from_name_and_gramps_id("Person", "I00002") - >>> self.get_from_name_and_gramps_id("Family", "F056") - >>> self.get_from_name_and_gramps_id("Media", "M00012") - """ - if table_name in self._get_table_func(): - return self._get_table_func(table_name, "gramps_id_func")(gramps_id) - return None - def _txn_begin(self): """ Lowlevel interface to the backend transaction. diff --git a/gramps/gui/editors/editreference.py b/gramps/gui/editors/editreference.py index 2529a91ae..8c5d38557 100644 --- a/gramps/gui/editors/editreference.py +++ b/gramps/gui/editors/editreference.py @@ -269,7 +269,8 @@ class EditReference(ManagedWindow, DbGUIElement): """ new_id = self.source.get_gramps_id() if new_id: - old_primary = self.db.get_from_name_and_gramps_id(type, new_id) + id_func = getattr(self.db, 'get_%s_from_gramps_id' % type.lower()) + old_primary = id_func(new_id) if old_primary: description = None if type == 'Event': diff --git a/gramps/plugins/db/bsddb/read.py b/gramps/plugins/db/bsddb/read.py index 3d222d5d5..e4bd998ee 100644 --- a/gramps/plugins/db/bsddb/read.py +++ b/gramps/plugins/db/bsddb/read.py @@ -488,21 +488,6 @@ class DbBsddbRead(DbReadBase, Callback): return self._get_table_func(table_name) return None - def get_from_name_and_gramps_id(self, table_name, gramps_id): - """ - Returns a gen.lib object (or None) given table_name and - Gramps ID. - - Examples: - - >>> self.get_from_name_and_gramps_id("Person", "I00002") - >>> self.get_from_name_and_gramps_id("Family", "F056") - >>> self.get_from_name_and_gramps_id("Media", "M00012") - """ - if table_name in self._get_table_func(): - return self._get_table_func(table_name,"gramps_id_func")(gramps_id) - return None - def set_prefixes(self, person, media, family, source, citation, place, event, repository, note): self.set_person_id_prefix(person)