View Single Post
Old 04-24-2023, 04:06 AM   #599
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
@chaley - After updating Calibre to source, has_data() broke with this error:

EXCEPTION: Error in function evaluate on line 4 : AttributeError - 'Cache' object has no attribute 'list_extra_files_matching'

What changed?

EDIT: Maybe this change https://github.com/kovidgoyal/calibr...095525b6e24e92
Yes, because of that commit. The API was improved for this use case, making it faster.

The template should be:
Code:
python:
def evaluate(book, context):
	db = context.db.new_api
	files = db.list_extra_files(book.id, pattern='data/**/*', use_cache=True)
	return 'Yes' if files else ''
Note: I will be adding template functions for queries about extra files.
chaley is offline   Reply With Quote