Don't repeatedly check for existing records; whitespace cleanup
This commit is contained in:
parent
5bb4021b2a
commit
ccbed9cb95
@ -1083,87 +1083,55 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
def get_event_from_handle(self, handle):
|
def get_event_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
event = None
|
return Event.create(self._get_raw_event_data(handle))
|
||||||
if handle in self.event_map:
|
|
||||||
event = Event.create(self._get_raw_event_data(handle))
|
|
||||||
return event
|
|
||||||
|
|
||||||
def get_family_from_handle(self, handle):
|
def get_family_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
family = None
|
return Family.create(self._get_raw_family_data(handle))
|
||||||
if handle in self.family_map:
|
|
||||||
family = Family.create(self._get_raw_family_data(handle))
|
|
||||||
return family
|
|
||||||
|
|
||||||
def get_repository_from_handle(self, handle):
|
def get_repository_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
repository = None
|
return Repository.create(self._get_raw_repository_data(handle))
|
||||||
if handle in self.repository_map:
|
|
||||||
repository = Repository.create(self._get_raw_repository_data(handle))
|
|
||||||
return repository
|
|
||||||
|
|
||||||
def get_person_from_handle(self, handle):
|
def get_person_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
person = None
|
return Person.create(self._get_raw_person_data(handle))
|
||||||
if handle in self.person_map:
|
|
||||||
person = Person.create(self._get_raw_person_data(handle))
|
|
||||||
return person
|
|
||||||
|
|
||||||
def get_place_from_handle(self, handle):
|
def get_place_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
place = None
|
return Place.create(self._get_raw_place_data(handle))
|
||||||
if handle in self.place_map:
|
|
||||||
place = Place.create(self._get_raw_place_data(handle))
|
|
||||||
return place
|
|
||||||
|
|
||||||
def get_citation_from_handle(self, handle):
|
def get_citation_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
citation = None
|
return Citation.create(self._get_raw_citation_data(handle))
|
||||||
if handle in self.citation_map:
|
|
||||||
citation = Citation.create(self._get_raw_citation_data(handle))
|
|
||||||
return citation
|
|
||||||
|
|
||||||
def get_source_from_handle(self, handle):
|
def get_source_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
source = None
|
return Source.create(self._get_raw_source_data(handle))
|
||||||
if handle in self.source_map:
|
|
||||||
source = Source.create(self._get_raw_source_data(handle))
|
|
||||||
return source
|
|
||||||
|
|
||||||
def get_note_from_handle(self, handle):
|
def get_note_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
note = None
|
return Note.create(self._get_raw_note_data(handle))
|
||||||
if handle in self.note_map:
|
|
||||||
note = Note.create(self._get_raw_note_data(handle))
|
|
||||||
return note
|
|
||||||
|
|
||||||
def get_object_from_handle(self, handle):
|
def get_object_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
media = None
|
return MediaObject.create(self._get_raw_media_data(handle))
|
||||||
if handle in self.media_map:
|
|
||||||
media = MediaObject.create(self._get_raw_media_data(handle))
|
|
||||||
return media
|
|
||||||
|
|
||||||
def get_object_from_gramps_id(self, gramps_id):
|
def get_object_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.media_id_map:
|
|
||||||
return MediaObject.create(self.media_id_map[gramps_id])
|
return MediaObject.create(self.media_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_tag_from_handle(self, handle):
|
def get_tag_from_handle(self, handle):
|
||||||
if isinstance(handle, bytes):
|
if isinstance(handle, bytes):
|
||||||
handle = str(handle, "utf-8")
|
handle = str(handle, "utf-8")
|
||||||
tag = None
|
return Tag.create(self._get_raw_tag_data(handle))
|
||||||
if handle in self.tag_map:
|
|
||||||
tag = Tag.create(self._get_raw_tag_data(handle))
|
|
||||||
return tag
|
|
||||||
|
|
||||||
def get_default_person(self):
|
def get_default_person(self):
|
||||||
handle = self.get_default_handle()
|
handle = self.get_default_handle()
|
||||||
@ -1179,49 +1147,31 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
return (Family.create(data[1]) for data in self.get_family_cursor())
|
return (Family.create(data[1]) for data in self.get_family_cursor())
|
||||||
|
|
||||||
def get_person_from_gramps_id(self, gramps_id):
|
def get_person_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.person_id_map:
|
|
||||||
return Person.create(self.person_id_map[gramps_id])
|
return Person.create(self.person_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_family_from_gramps_id(self, gramps_id):
|
def get_family_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.family_id_map:
|
|
||||||
return Family.create(self.family_id_map[gramps_id])
|
return Family.create(self.family_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_citation_from_gramps_id(self, gramps_id):
|
def get_citation_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.citation_id_map:
|
|
||||||
return Citation.create(self.citation_id_map[gramps_id])
|
return Citation.create(self.citation_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_source_from_gramps_id(self, gramps_id):
|
def get_source_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.source_id_map:
|
|
||||||
return Source.create(self.source_id_map[gramps_id])
|
return Source.create(self.source_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_event_from_gramps_id(self, gramps_id):
|
def get_event_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.event_id_map:
|
|
||||||
return Event.create(self.event_id_map[gramps_id])
|
return Event.create(self.event_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_media_from_gramps_id(self, gramps_id):
|
def get_media_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.media_id_map:
|
|
||||||
return MediaObject.create(self.media_id_map[gramps_id])
|
return MediaObject.create(self.media_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_place_from_gramps_id(self, gramps_id):
|
def get_place_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.place_id_map:
|
|
||||||
return Place.create(self.place_id_map[gramps_id])
|
return Place.create(self.place_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_repository_from_gramps_id(self, gramps_id):
|
def get_repository_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.repository_id_map:
|
|
||||||
return Repository.create(self.repository_id_map[gramps_id])
|
return Repository.create(self.repository_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_note_from_gramps_id(self, gramps_id):
|
def get_note_from_gramps_id(self, gramps_id):
|
||||||
if gramps_id in self.note_id_map:
|
|
||||||
return Note.create(self.note_id_map[gramps_id])
|
return Note.create(self.note_id_map[gramps_id])
|
||||||
return None
|
|
||||||
|
|
||||||
def get_place_cursor(self):
|
def get_place_cursor(self):
|
||||||
return Cursor(self.place_map)
|
return Cursor(self.place_map)
|
||||||
@ -1301,54 +1251,34 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
return handle in self.media_map
|
return handle in self.media_map
|
||||||
|
|
||||||
def get_raw_person_data(self, handle):
|
def get_raw_person_data(self, handle):
|
||||||
if handle in self.person_map:
|
|
||||||
return self.person_map[handle]
|
return self.person_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_family_data(self, handle):
|
def get_raw_family_data(self, handle):
|
||||||
if handle in self.family_map:
|
|
||||||
return self.family_map[handle]
|
return self.family_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_citation_data(self, handle):
|
def get_raw_citation_data(self, handle):
|
||||||
if handle in self.citation_map:
|
|
||||||
return self.citation_map[handle]
|
return self.citation_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_source_data(self, handle):
|
def get_raw_source_data(self, handle):
|
||||||
if handle in self.source_map:
|
|
||||||
return self.source_map[handle]
|
return self.source_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_repository_data(self, handle):
|
def get_raw_repository_data(self, handle):
|
||||||
if handle in self.repository_map:
|
|
||||||
return self.repository_map[handle]
|
return self.repository_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_note_data(self, handle):
|
def get_raw_note_data(self, handle):
|
||||||
if handle in self.note_map:
|
|
||||||
return self.note_map[handle]
|
return self.note_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_place_data(self, handle):
|
def get_raw_place_data(self, handle):
|
||||||
if handle in self.place_map:
|
|
||||||
return self.place_map[handle]
|
return self.place_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_object_data(self, handle):
|
def get_raw_object_data(self, handle):
|
||||||
if handle in self.media_map:
|
|
||||||
return self.media_map[handle]
|
return self.media_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_tag_data(self, handle):
|
def get_raw_tag_data(self, handle):
|
||||||
if handle in self.tag_map:
|
|
||||||
return self.tag_map[handle]
|
return self.tag_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def get_raw_event_data(self, handle):
|
def get_raw_event_data(self, handle):
|
||||||
if handle in self.event_map:
|
|
||||||
return self.event_map[handle]
|
return self.event_map[handle]
|
||||||
return None
|
|
||||||
|
|
||||||
def add_person(self, person, trans, set_gid=True):
|
def add_person(self, person, trans, set_gid=True):
|
||||||
if not person.handle:
|
if not person.handle:
|
||||||
@ -2056,4 +1986,3 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
def set_default_person_handle(self, handle):
|
def set_default_person_handle(self, handle):
|
||||||
self.set_metadata("default-person-handle", handle)
|
self.set_metadata("default-person-handle", handle)
|
||||||
self.emit('home-person-changed')
|
self.emit('home-person-changed')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user