9742: Rewrite get_*_gramps_ids methods
Use get_gramps_ids rather than table maps.
This commit is contained in:
parent
41f3475681
commit
7b183fc79c
@ -1544,20 +1544,6 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
if name in self.surname_list:
|
if name in self.surname_list:
|
||||||
self.surname_list.remove(name)
|
self.surname_list.remove(name)
|
||||||
|
|
||||||
def get_gramps_ids(self, obj_key):
|
|
||||||
key2table = {
|
|
||||||
PERSON_KEY: self.person_id_map,
|
|
||||||
FAMILY_KEY: self.family_id_map,
|
|
||||||
CITATION_KEY: self.citation_id_map,
|
|
||||||
SOURCE_KEY: self.source_id_map,
|
|
||||||
EVENT_KEY: self.event_id_map,
|
|
||||||
MEDIA_KEY: self.media_id_map,
|
|
||||||
PLACE_KEY: self.place_id_map,
|
|
||||||
REPOSITORY_KEY: self.repository_id_map,
|
|
||||||
NOTE_KEY: self.note_id_map,
|
|
||||||
}
|
|
||||||
return list(key2table[obj_key].keys())
|
|
||||||
|
|
||||||
def set_researcher(self, owner):
|
def set_researcher(self, owner):
|
||||||
self.owner.set_from(owner)
|
self.owner.set_from(owner)
|
||||||
|
|
||||||
|
@ -1623,50 +1623,49 @@ class DBAPI(DbGeneric):
|
|||||||
def has_note_gramps_id(self, gramps_id):
|
def has_note_gramps_id(self, gramps_id):
|
||||||
return self.has_gramps_id(NOTE_KEY, gramps_id)
|
return self.has_gramps_id(NOTE_KEY, gramps_id)
|
||||||
|
|
||||||
def get_person_gramps_ids(self):
|
def get_gramps_ids(self, obj_key):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM person;")
|
key2table = {
|
||||||
|
PERSON_KEY: 'person',
|
||||||
|
FAMILY_KEY: 'family',
|
||||||
|
SOURCE_KEY: 'source',
|
||||||
|
CITATION_KEY: 'citation',
|
||||||
|
EVENT_KEY: 'event',
|
||||||
|
MEDIA_KEY: 'media',
|
||||||
|
PLACE_KEY: 'place',
|
||||||
|
REPOSITORY_KEY: 'repository',
|
||||||
|
NOTE_KEY: 'note',
|
||||||
|
}
|
||||||
|
sql = "SELECT gramps_id FROM %s;" % key2table[obj_key]
|
||||||
|
self.dbapi.execute(sql)
|
||||||
rows = self.dbapi.fetchall()
|
rows = self.dbapi.fetchall()
|
||||||
return [row[0] for row in rows]
|
return [row[0] for row in rows]
|
||||||
|
|
||||||
|
def get_person_gramps_ids(self):
|
||||||
|
return self.get_gramps_ids(PERSON_KEY)
|
||||||
|
|
||||||
def get_family_gramps_ids(self):
|
def get_family_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM family;")
|
return self.get_gramps_ids(FAMILY_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_source_gramps_ids(self):
|
def get_source_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM source;")
|
return self.get_gramps_ids(SOURCE_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_citation_gramps_ids(self):
|
def get_citation_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM citation;")
|
return self.get_gramps_ids(CITATION_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_event_gramps_ids(self):
|
def get_event_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM event;")
|
return self.get_gramps_ids(EVENT_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_media_gramps_ids(self):
|
def get_media_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM media;")
|
return self.get_gramps_ids(MEDIA_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_place_gramps_ids(self):
|
def get_place_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps FROM place;")
|
return self.get_gramps_ids(PLACE_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_repository_gramps_ids(self):
|
def get_repository_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM repository;")
|
return self.get_gramps_ids(REPOSITORY_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_note_gramps_ids(self):
|
def get_note_gramps_ids(self):
|
||||||
self.dbapi.execute("SELECT gramps_id FROM note;")
|
return self.get_gramps_ids(NOTE_KEY)
|
||||||
rows = self.dbapi.fetchall()
|
|
||||||
return [row[0] for row in rows]
|
|
||||||
|
|
||||||
def get_raw_person_data(self, key):
|
def get_raw_person_data(self, key):
|
||||||
if isinstance(key, bytes):
|
if isinstance(key, bytes):
|
||||||
|
Loading…
Reference in New Issue
Block a user