Don't repeatedly check for existing records; whitespace cleanup

This commit is contained in:
Doug Blank 2015-08-21 08:14:11 -04:00
parent 5bb4021b2a
commit ccbed9cb95

View File

@ -1083,87 +1083,55 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
def get_event_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
event = None
if handle in self.event_map:
event = Event.create(self._get_raw_event_data(handle))
return event
return Event.create(self._get_raw_event_data(handle))
def get_family_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
family = None
if handle in self.family_map:
family = Family.create(self._get_raw_family_data(handle))
return family
return Family.create(self._get_raw_family_data(handle))
def get_repository_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
repository = None
if handle in self.repository_map:
repository = Repository.create(self._get_raw_repository_data(handle))
return repository
return Repository.create(self._get_raw_repository_data(handle))
def get_person_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
person = None
if handle in self.person_map:
person = Person.create(self._get_raw_person_data(handle))
return person
return Person.create(self._get_raw_person_data(handle))
def get_place_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
place = None
if handle in self.place_map:
place = Place.create(self._get_raw_place_data(handle))
return place
return Place.create(self._get_raw_place_data(handle))
def get_citation_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
citation = None
if handle in self.citation_map:
citation = Citation.create(self._get_raw_citation_data(handle))
return citation
return Citation.create(self._get_raw_citation_data(handle))
def get_source_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
source = None
if handle in self.source_map:
source = Source.create(self._get_raw_source_data(handle))
return source
return Source.create(self._get_raw_source_data(handle))
def get_note_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
note = None
if handle in self.note_map:
note = Note.create(self._get_raw_note_data(handle))
return note
return Note.create(self._get_raw_note_data(handle))
def get_object_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
media = None
if handle in self.media_map:
media = MediaObject.create(self._get_raw_media_data(handle))
return media
return MediaObject.create(self._get_raw_media_data(handle))
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 None
def get_tag_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
tag = None
if handle in self.tag_map:
tag = Tag.create(self._get_raw_tag_data(handle))
return tag
return Tag.create(self._get_raw_tag_data(handle))
def get_default_person(self):
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())
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 None
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 None
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 None
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 None
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 None
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 None
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 None
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 None
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 None
def get_place_cursor(self):
return Cursor(self.place_map)
@ -1301,54 +1251,34 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
return handle in self.media_map
def get_raw_person_data(self, handle):
if handle in self.person_map:
return self.person_map[handle]
return None
def get_raw_family_data(self, handle):
if handle in self.family_map:
return self.family_map[handle]
return None
def get_raw_citation_data(self, handle):
if handle in self.citation_map:
return self.citation_map[handle]
return None
def get_raw_source_data(self, handle):
if handle in self.source_map:
return self.source_map[handle]
return None
def get_raw_repository_data(self, handle):
if handle in self.repository_map:
return self.repository_map[handle]
return None
def get_raw_note_data(self, handle):
if handle in self.note_map:
return self.note_map[handle]
return None
def get_raw_place_data(self, handle):
if handle in self.place_map:
return self.place_map[handle]
return None
def get_raw_object_data(self, handle):
if handle in self.media_map:
return self.media_map[handle]
return None
def get_raw_tag_data(self, handle):
if handle in self.tag_map:
return self.tag_map[handle]
return None
def get_raw_event_data(self, handle):
if handle in self.event_map:
return self.event_map[handle]
return None
def add_person(self, person, trans, set_gid=True):
if not person.handle:
@ -2056,4 +1986,3 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
def set_default_person_handle(self, handle):
self.set_metadata("default-person-handle", handle)
self.emit('home-person-changed')