DictionaryDb: give handle in bytes, handle as str internally in dict

This commit is contained in:
Doug Blank 2015-05-17 19:01:21 -04:00
parent 92f435d45b
commit a9b7b43ffb

View File

@ -735,60 +735,80 @@ class DictionaryDb(DbWriteBase, DbReadBase, UpdateCallback, Callback):
return self.tag_map.keys() return self.tag_map.keys()
def get_event_from_handle(self, handle): def get_event_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
event = None event = None
if handle in self.event_map: if handle in self.event_map:
event = Event.create(self.event_map[handle]) event = Event.create(self.event_map[handle])
return event return event
def get_family_from_handle(self, handle): def get_family_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
family = None family = None
if handle in self.family_map: if handle in self.family_map:
family = Family.create(self.family_map[handle]) family = Family.create(self.family_map[handle])
return family return family
def get_repository_from_handle(self, handle): def get_repository_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
repository = None repository = None
if handle in self.repository_map: if handle in self.repository_map:
repository = Repository.create(self.repository_map[handle]) repository = Repository.create(self.repository_map[handle])
return repository return repository
def get_person_from_handle(self, handle): def get_person_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
person = None person = None
if handle in self.person_map: if handle in self.person_map:
person = Person.create(self.person_map[handle]) person = Person.create(self.person_map[handle])
return person return person
def get_place_from_handle(self, handle): def get_place_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
place = None place = None
if handle in self.place_map: if handle in self.place_map:
place = Place.create(self.place_map[handle]) place = Place.create(self.place_map[handle])
return place return place
def get_citation_from_handle(self, handle): def get_citation_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
citation = None citation = None
if handle in self.citation_map: if handle in self.citation_map:
citation = Citation.create(self.citation_map[handle]) citation = Citation.create(self.citation_map[handle])
return citation return citation
def get_source_from_handle(self, handle): def get_source_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
source = None source = None
if handle in self.source_map: if handle in self.source_map:
source = Source.create(self.source_map[handle]) source = Source.create(self.source_map[handle])
return source return source
def get_note_from_handle(self, handle): def get_note_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
note = None note = None
if handle in self.note_map: if handle in self.note_map:
note = Note.create(self.note_map[handle]) note = Note.create(self.note_map[handle])
return note return note
def get_object_from_handle(self, handle): def get_object_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
media = None media = None
if handle in self.media_map: if handle in self.media_map:
media = MediaObject.create(self.media_map[handle]) media = MediaObject.create(self.media_map[handle])
return media return media
def get_tag_from_handle(self, handle): def get_tag_from_handle(self, handle):
if isinstance(handle, bytes):
handle = str(handle, "utf-8")
tag = None tag = None
if handle in self.tag_map: if handle in self.tag_map:
tag = Tag.create(self.tag_map[handle]) tag = Tag.create(self.tag_map[handle])