mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-29 05:03:03 +02:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
9b492bfcd6
2 changed files with 10 additions and 1 deletions
|
|
@ -607,7 +607,8 @@ def format_metadata(self, book_id, fmt, allow_cache=True, update_db=False):
|
|||
if not fmt:
|
||||
return {}
|
||||
fmt = fmt.upper()
|
||||
if allow_cache:
|
||||
# allow_cache and update_db are mutually exclusive. Give priority to update_db
|
||||
if allow_cache and not update_db:
|
||||
x = self.format_metadata_cache[book_id].get(fmt, None)
|
||||
if x is not None:
|
||||
return x
|
||||
|
|
@ -635,6 +636,11 @@ def format_files(self, book_id):
|
|||
fmts = field.table.book_col_map.get(book_id, ())
|
||||
return {fmt:field.format_fname(book_id, fmt) for fmt in fmts}
|
||||
|
||||
@read_api
|
||||
def format_db_size(self, book_id, fmt):
|
||||
field = self.fields['formats']
|
||||
return field.format_size(book_id, fmt)
|
||||
|
||||
@read_api
|
||||
def pref(self, name, default=None, namespace=None):
|
||||
' Return the value for the specified preference or the value specified as ``default`` if the preference is not set. '
|
||||
|
|
|
|||
|
|
@ -623,6 +623,9 @@ def for_book(self, book_id, default_value=None):
|
|||
def format_fname(self, book_id, fmt):
|
||||
return self.table.fname_map[book_id][fmt.upper()]
|
||||
|
||||
def format_size(self, book_id, fmt):
|
||||
return self.table.size_map.get(book_id, {}).get(fmt.upper(), None)
|
||||
|
||||
def iter_searchable_values(self, get_metadata, candidates, default_value=None):
|
||||
val_map = defaultdict(set)
|
||||
cbm = self.table.book_col_map
|
||||
|
|
|
|||
Loading…
Reference in a new issue