This commit is contained in:
Kovid Goyal 2013-07-12 18:04:27 +05:30
parent 3719dfb4d8
commit ecbea8b0e2
2 changed files with 19 additions and 0 deletions

View File

@ -109,6 +109,9 @@ class LibraryDatabase(object):
self.last_update_check = self.last_modified()
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):
self.backend.close()
@ -352,6 +355,19 @@ class LibraryDatabase(object):
def set_book_on_device_func(self, 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 {{{
def __iter__(self):

View File

@ -176,6 +176,7 @@ class LegacyTest(BaseTest):
'author_sort_from_book':[(0,), (1,), (2,)],
'authors_with_sort_strings':[(0,), (1,), (2,)],
'book_on_device_string':[(1,), (2,), (3,)],
'books_in_series_of':[(0,), (1,), (2,)],
}.iteritems():
for a in args:
fmt = lambda x: x
@ -265,6 +266,8 @@ class LegacyTest(BaseTest):
'author_id', # replaced by get_author_id
'books_for_author', # broken
'books_in_old_database', # unused
'clean_user_categories', # internal API
'cleanup_tags', # internal API
}
SKIP_ARGSPEC = {
'__init__', 'get_next_series_num_for', 'has_book', 'author_sort_from_authors',