mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
get_id_from_uuid()
This commit is contained in:
parent
abc9232016
commit
cdf50da034
@ -1353,6 +1353,11 @@ class Cache(object):
|
|||||||
self._mark_as_dirty(changed_books)
|
self._mark_as_dirty(changed_books)
|
||||||
return 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): # {{{
|
class SortKey(object): # {{{
|
||||||
|
@ -153,6 +153,10 @@ class LibraryDatabase(object):
|
|||||||
def refresh(self, field=None, ascending=True):
|
def refresh(self, field=None, ascending=True):
|
||||||
self.data.refresh(field=field, ascending=ascending)
|
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):
|
def add_listener(self, listener):
|
||||||
'''
|
'''
|
||||||
Add a listener. Will be called on change events with two arguments.
|
Add a listener. Will be called on change events with two arguments.
|
||||||
|
@ -137,6 +137,9 @@ class UUIDTable(OneToOneTable):
|
|||||||
clean.add(val)
|
clean.add(val)
|
||||||
return clean
|
return clean
|
||||||
|
|
||||||
|
def lookup_by_uuid(self, uuid):
|
||||||
|
return self.uuid_to_id_map.get(uuid, None)
|
||||||
|
|
||||||
class CompositeTable(OneToOneTable):
|
class CompositeTable(OneToOneTable):
|
||||||
|
|
||||||
def read(self, db):
|
def read(self, db):
|
||||||
|
@ -163,6 +163,7 @@ class LegacyTest(BaseTest):
|
|||||||
|
|
||||||
for meth, args in {
|
for meth, args in {
|
||||||
'get_next_series_num_for': [('A Series One',)],
|
'get_next_series_num_for': [('A Series One',)],
|
||||||
|
'get_id_from_uuid':[('ddddd',), (db.uuid(1, True),)],
|
||||||
'get_author_id': [('author one',), ('unknown',), ('xxxxx',)],
|
'get_author_id': [('author one',), ('unknown',), ('xxxxx',)],
|
||||||
'series_id': [(0,), (1,), (2,)],
|
'series_id': [(0,), (1,), (2,)],
|
||||||
'publisher_id': [(0,), (1,), (2,)],
|
'publisher_id': [(0,), (1,), (2,)],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user