mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
all_formats()
This commit is contained in:
parent
c1cca5213a
commit
998a79075c
@ -363,6 +363,9 @@ class Cache(object):
|
||||
@read_api
|
||||
def all_field_names(self, field):
|
||||
''' Frozen set of all fields names (should only be used for many-one and many-many fields) '''
|
||||
if field == 'formats':
|
||||
return frozenset(self.fields[field].table.col_book_map)
|
||||
|
||||
try:
|
||||
return frozenset(self.fields[field].table.id_map.itervalues())
|
||||
except AttributeError:
|
||||
|
@ -68,6 +68,7 @@ class LibraryDatabase(object):
|
||||
for field in ('authors', 'tags', 'publisher', 'series'):
|
||||
name = field[:-1] if field in {'authors', 'tags'} else field
|
||||
setattr(self, 'all_%s_names' % name, partial(self.new_api.all_field_names, field))
|
||||
self.all_formats = partial(self.new_api.all_field_names, 'formats')
|
||||
|
||||
for func, field in {'all_authors':'authors', 'all_titles':'title', 'all_tags2':'tags', 'all_series':'series', 'all_publishers':'publisher'}.iteritems():
|
||||
setattr(self, func, partial(self.field_id_map, field))
|
||||
|
@ -158,6 +158,7 @@ class LegacyTest(BaseTest):
|
||||
'custom_field_keys':[(True,), (False,)],
|
||||
'get_usage_count_by_id':[('authors',), ('tags',), ('series',), ('publisher',), ('#tags',), ('languages',)],
|
||||
'get_field':[(1, 'title'), (2, 'tags'), (0, 'rating'), (1, 'authors'), (2, 'series'), (1, '#tags')],
|
||||
'all_formats':[()],
|
||||
}.iteritems():
|
||||
for a in args:
|
||||
fmt = lambda x: x
|
||||
|
Loading…
x
Reference in New Issue
Block a user