mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
More API
This commit is contained in:
parent
3719dfb4d8
commit
ecbea8b0e2
@ -109,6 +109,9 @@ class LibraryDatabase(object):
|
|||||||
|
|
||||||
self.last_update_check = self.last_modified()
|
self.last_update_check = self.last_modified()
|
||||||
self.book_on_device_func = None
|
self.book_on_device_func = None
|
||||||
|
# Cleaning is not required anymore
|
||||||
|
self.clean = self.clean_custom = MT(lambda self:None)
|
||||||
|
self.clean_standard_field = MT(lambda self, field, commit=False:None)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.backend.close()
|
self.backend.close()
|
||||||
@ -352,6 +355,19 @@ class LibraryDatabase(object):
|
|||||||
def set_book_on_device_func(self, func):
|
def set_book_on_device_func(self, func):
|
||||||
self.book_on_device_func = func
|
self.book_on_device_func = func
|
||||||
|
|
||||||
|
def books_in_series(self, series_id):
|
||||||
|
with self.new_api.read_lock:
|
||||||
|
book_ids = self.new_api._books_for_field('series', series_id)
|
||||||
|
ff = self.new_api._field_for
|
||||||
|
return sorted(book_ids, key=lambda x:ff('series_index', x))
|
||||||
|
|
||||||
|
def books_in_series_of(self, index, index_is_id=False):
|
||||||
|
book_id = index if index_is_id else self.data.index_to_id(index)
|
||||||
|
series_ids = self.new_api.field_ids_for('series', book_id)
|
||||||
|
if not series_ids:
|
||||||
|
return []
|
||||||
|
return self.books_in_series(series_ids[0])
|
||||||
|
|
||||||
# Private interface {{{
|
# Private interface {{{
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
@ -176,6 +176,7 @@ class LegacyTest(BaseTest):
|
|||||||
'author_sort_from_book':[(0,), (1,), (2,)],
|
'author_sort_from_book':[(0,), (1,), (2,)],
|
||||||
'authors_with_sort_strings':[(0,), (1,), (2,)],
|
'authors_with_sort_strings':[(0,), (1,), (2,)],
|
||||||
'book_on_device_string':[(1,), (2,), (3,)],
|
'book_on_device_string':[(1,), (2,), (3,)],
|
||||||
|
'books_in_series_of':[(0,), (1,), (2,)],
|
||||||
}.iteritems():
|
}.iteritems():
|
||||||
for a in args:
|
for a in args:
|
||||||
fmt = lambda x: x
|
fmt = lambda x: x
|
||||||
@ -265,6 +266,8 @@ class LegacyTest(BaseTest):
|
|||||||
'author_id', # replaced by get_author_id
|
'author_id', # replaced by get_author_id
|
||||||
'books_for_author', # broken
|
'books_for_author', # broken
|
||||||
'books_in_old_database', # unused
|
'books_in_old_database', # unused
|
||||||
|
'clean_user_categories', # internal API
|
||||||
|
'cleanup_tags', # internal API
|
||||||
}
|
}
|
||||||
SKIP_ARGSPEC = {
|
SKIP_ARGSPEC = {
|
||||||
'__init__', 'get_next_series_num_for', 'has_book', 'author_sort_from_authors',
|
'__init__', 'get_next_series_num_for', 'has_book', 'author_sort_from_authors',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user