mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow user-defined functions to be directly used in save-to-disk templates
This commit is contained in:
parent
7e6d4fd68b
commit
4ece2a59e2
@ -249,6 +249,7 @@ class SaveWorker(Thread):
|
||||
recs[pref.name] = getattr(self.opts, pref.name)
|
||||
|
||||
plugboards = self.db.prefs.get('plugboards', {})
|
||||
template_functions = self.db.prefs.get('user_template_functions', [])
|
||||
|
||||
for i, task in enumerate(tasks):
|
||||
tids = [x[-1] for x in task]
|
||||
@ -260,7 +261,7 @@ class SaveWorker(Thread):
|
||||
job = ParallelJob('save_book',
|
||||
'Save books (%d of %d)'%(i, len(tasks)),
|
||||
lambda x,y:x,
|
||||
args=[tids, dpath, plugboards, self.path, recs])
|
||||
args=[tids, dpath, plugboards, template_functions, self.path, recs])
|
||||
jobs.add(job)
|
||||
server.add_job(job)
|
||||
|
||||
@ -312,9 +313,12 @@ class SaveWorker(Thread):
|
||||
break
|
||||
|
||||
|
||||
def save_book(ids, dpath, plugboards, path, recs, notification=lambda x,y:x):
|
||||
def save_book(ids, dpath, plugboards, template_functions, path, recs,
|
||||
notification=lambda x,y:x):
|
||||
from calibre.library.save_to_disk import config, save_serialized_to_disk
|
||||
from calibre.customize.ui import apply_null_metadata
|
||||
from calibre.utils.formatter_functions import load_user_template_functions
|
||||
load_user_template_functions(template_functions)
|
||||
opts = config().parse()
|
||||
for name in recs:
|
||||
setattr(opts, name, recs[name])
|
||||
|
Loading…
x
Reference in New Issue
Block a user