mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Make merge_list into an alias of list_union. Change documentation. If running from source, get source code for new functions via inspection.
This commit is contained in:
parent
d5e3693eb5
commit
40dcb80ad1
@ -289,9 +289,8 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||
self.documentation.clear()
|
||||
if name in self.funcs:
|
||||
self.documentation.setPlainText(self.funcs[name].doc)
|
||||
if name in self.builtins:
|
||||
if name in self.builtin_source_dict:
|
||||
self.source_code.setPlainText(self.builtin_source_dict[name])
|
||||
if name in self.builtins and name in self.builtin_source_dict:
|
||||
self.source_code.setPlainText(self.builtin_source_dict[name])
|
||||
else:
|
||||
self.source_code.setPlainText(self.funcs[name].program_text)
|
||||
|
||||
|
@ -266,7 +266,7 @@ The following functions are available in addition to those described in single-f
|
||||
* ``list_difference(list1, list2, separator)`` -- return a list made by removing from `list1` any item found in `list2`, using a case-insensitive compare. The items in `list1` and `list2` are separated by separator, as are the items in the returned list.
|
||||
* ``list_intersection(list1, list2, separator)`` -- return a list made by removing from `list1` any item not found in `list2`, using a case-insensitive compare. The items in `list1` and `list2` are separated by separator, as are the items in the returned list.
|
||||
* ``list_sort(list, direction, separator)`` -- return list sorted using a case-insensitive sort. If `direction` is zero, the list is sorted ascending, otherwise descending. The list items are separated by separator, as are the items in the returned list.
|
||||
* ``merge_lists(list1, list2, separator)`` -- return a list made by merging the items in list1 and list2, removing duplicate items using a case-insensitive compare. If items differ in case, the one in list1 is used. The items in list1 and list2 are separated by separator, as are the items in the returned list.
|
||||
* ``list_union(list1, list2, separator)`` -- return a list made by merging the items in list1 and list2, removing duplicate items using a case-insensitive compare. If items differ in case, the one in list1 is used. The items in list1 and list2 are separated by separator, as are the items in the returned list.
|
||||
* ``multiply(x, y)`` -- returns x * y. Throws an exception if either x or y are not numbers.
|
||||
* ``ondevice()`` -- return the string "Yes" if ondevice is set, otherwise return the empty string
|
||||
* ``or(value, value, ...)`` -- returns the string "1" if any value is not empty, otherwise returns the empty string. This function works well with test or first_non_empty. You can have as many values as you want.
|
||||
|
@ -829,11 +829,11 @@ class BuiltinNot(BuiltinFormatterFunction):
|
||||
def evaluate(self, formatter, kwargs, mi, locals, val):
|
||||
return '' if val else '1'
|
||||
|
||||
class BuiltinMergeLists(BuiltinFormatterFunction):
|
||||
name = 'merge_lists'
|
||||
class BuiltinListUnion(BuiltinFormatterFunction):
|
||||
name = 'list_union'
|
||||
arg_count = 3
|
||||
category = 'List Manipulation'
|
||||
__doc__ = doc = _('merge_lists(list1, list2, separator) -- '
|
||||
__doc__ = doc = _('list_union(list1, list2, separator) -- '
|
||||
'return a list made by merging the items in list1 and list2, '
|
||||
'removing duplicate items using a case-insensitive compare. If '
|
||||
'items differ in case, the one in list1 is used. '
|
||||
@ -853,6 +853,9 @@ class BuiltinMergeLists(BuiltinFormatterFunction):
|
||||
res.append(i)
|
||||
return ', '.join(res)
|
||||
|
||||
class BuiltinMergeLists(BuiltinListUnion):
|
||||
name = 'merge_lists'
|
||||
|
||||
class BuiltinListDifference(BuiltinFormatterFunction):
|
||||
name = 'list_difference'
|
||||
arg_count = 3
|
||||
@ -945,7 +948,8 @@ formatter_builtins = [
|
||||
BuiltinFormatNumber(), BuiltinFormatsModtimes(), BuiltinFormatsSizes(),
|
||||
BuiltinHasCover(), BuiltinHumanReadable(), BuiltinIdentifierInList(),
|
||||
BuiltinIfempty(), BuiltinInList(), BuiltinListDifference(),
|
||||
BuiltinListIntersection(), BuiltinListitem(), BuiltinListSort(), BuiltinLookup(),
|
||||
BuiltinListIntersection(), BuiltinListitem(), BuiltinListSort(),
|
||||
BuiltinListUnion(), BuiltinLookup(),
|
||||
BuiltinLowercase(), BuiltinMergeLists(), BuiltinMultiply(), BuiltinNot(),
|
||||
BuiltinOndevice(), BuiltinOr(), BuiltinPrint(), BuiltinRawField(),
|
||||
BuiltinRe(), BuiltinSelect(), BuiltinShorten(), BuiltinStrcat(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user