diff --git a/src/calibre/gui2/preferences/social.py b/src/calibre/gui2/preferences/social.py index 5f66f12326..a22bcce091 100644 --- a/src/calibre/gui2/preferences/social.py +++ b/src/calibre/gui2/preferences/social.py @@ -62,6 +62,7 @@ class SocialMetadata(QDialog): return if not self.worker.is_alive(): self.accept() + return QTimer.singleShot(50, self.update) def accept(self): diff --git a/src/calibre/gui2/preferences/template_functions.py b/src/calibre/gui2/preferences/template_functions.py index efcf9e6379..2e16b0f4c3 100644 --- a/src/calibre/gui2/preferences/template_functions.py +++ b/src/calibre/gui2/preferences/template_functions.py @@ -25,37 +25,49 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): template function is written in python. It takes information from the book, processes it in some way, then returns a string result. Functions defined here are usable in templates in the same way that builtin - functions are usable. The function must be named evaluate, and must - have the signature shown below.

-

evaluate(self, formatter, kwargs, mi, locals, your_arguments) + functions are usable. The function must be named evaluate, and + must have the signature shown below.

+

evaluate(self, formatter, kwargs, mi, locals, your parameters) → returning a unicode string

-

The arguments to evaluate are: +

The parameters of the evaluate function are:

- The following example function looks for various values in the tags - metadata field, returning those values that appear in tags. + The following example function checks the value of the field. If the + field is not empty, the field's value is returned, otherwise the value + EMPTY is returned.

+        name: my_ifempty
+        arg count: 1
+        doc: my_ifempty(val) -- return val if it is not empty, otherwise the string 'EMPTY'
+        program code:
         def evaluate(self, formatter, kwargs, mi, locals, val):
-            awards=['allbooks', 'PBook', 'ggff']
-            return ', '.join([t for t in kwargs.get('tags') if t in awards])
-        
+ if val: + return val + else: + return 'EMPTY' + This function can be called in any of the three template program modes: +