mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
384e24a06a
commit
3f50c415c4
@ -347,8 +347,9 @@ class Cache(object):
|
||||
as_path=as_path)
|
||||
|
||||
@read_api
|
||||
def multisort(self, fields):
|
||||
all_book_ids = frozenset(self._all_book_ids())
|
||||
def multisort(self, fields, ids_to_sort=None):
|
||||
all_book_ids = frozenset(self._all_book_ids() if ids_to_sort is None
|
||||
else ids_to_sort)
|
||||
get_metadata = partial(self._get_metadata, get_user_categories=False)
|
||||
|
||||
sort_keys = tuple(self.fields[field[0]].sort_keys_for_books(get_metadata,
|
||||
|
@ -51,9 +51,13 @@ class Field(object):
|
||||
|
||||
def __iter__(self):
|
||||
'''
|
||||
Iterate over the ids for all values in this field
|
||||
Iterate over the ids for all values in this field.
|
||||
|
||||
WARNING: Some fields such as composite fields and virtual
|
||||
fields like ondevice do not have ids for their values, in such
|
||||
cases this is an empty iterator.
|
||||
'''
|
||||
raise NotImplementedError()
|
||||
return iter(())
|
||||
|
||||
def sort_keys_for_books(self, get_metadata, all_book_ids):
|
||||
'''
|
||||
@ -78,9 +82,6 @@ class OneToOneField(Field):
|
||||
def __iter__(self):
|
||||
return self.table.book_col_map.iterkeys()
|
||||
|
||||
def iter_book_ids(self):
|
||||
return self.table.book_col_map.iterkeys()
|
||||
|
||||
def sort_keys_for_books(self, get_metadata, all_book_ids):
|
||||
return {id_ : self._sort_key(self.book_col_map.get(id_, '')) for id_ in
|
||||
all_book_ids}
|
||||
@ -154,9 +155,6 @@ class OnDeviceField(OneToOneField):
|
||||
def __iter__(self):
|
||||
return iter(())
|
||||
|
||||
def iter_book_ids(self):
|
||||
return iter(())
|
||||
|
||||
def sort_keys_for_books(self, get_metadata, all_book_ids):
|
||||
return {id_ : self.for_book(id_) for id_ in
|
||||
all_book_ids}
|
||||
|
Loading…
x
Reference in New Issue
Block a user