mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 13:43:39 +02:00
get_id_from_uuid()
This commit is contained in:
parent
abc9232016
commit
cdf50da034
4 changed files with 13 additions and 0 deletions
|
|
@ -1353,6 +1353,11 @@ def set_link_for_authors(self, author_id_to_link_map):
|
|||
self._mark_as_dirty(changed_books)
|
||||
return changed_books
|
||||
|
||||
@read_api
|
||||
def lookup_by_uuid(self, uuid):
|
||||
return self.fields['uuid'].table.lookup_by_uuid(uuid)
|
||||
|
||||
|
||||
# }}}
|
||||
|
||||
class SortKey(object): # {{{
|
||||
|
|
|
|||
|
|
@ -153,6 +153,10 @@ def field_id_map(self, field):
|
|||
def refresh(self, field=None, ascending=True):
|
||||
self.data.refresh(field=field, ascending=ascending)
|
||||
|
||||
def get_id_from_uuid(self, uuid):
|
||||
if uuid:
|
||||
return self.new_api.lookup_by_uuid(uuid)
|
||||
|
||||
def add_listener(self, listener):
|
||||
'''
|
||||
Add a listener. Will be called on change events with two arguments.
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ def remove_books(self, book_ids, db):
|
|||
clean.add(val)
|
||||
return clean
|
||||
|
||||
def lookup_by_uuid(self, uuid):
|
||||
return self.uuid_to_id_map.get(uuid, None)
|
||||
|
||||
class CompositeTable(OneToOneTable):
|
||||
|
||||
def read(self, db):
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ def test_legacy_direct(self): # {{{
|
|||
|
||||
for meth, args in {
|
||||
'get_next_series_num_for': [('A Series One',)],
|
||||
'get_id_from_uuid':[('ddddd',), (db.uuid(1, True),)],
|
||||
'get_author_id': [('author one',), ('unknown',), ('xxxxx',)],
|
||||
'series_id': [(0,), (1,), (2,)],
|
||||
'publisher_id': [(0,), (1,), (2,)],
|
||||
|
|
|
|||
Loading…
Reference in a new issue