mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add new formatter function "current_virtual_library_name().
This commit is contained in:
parent
8f6c3dff7e
commit
cfcbc407a3
@ -389,6 +389,7 @@ In `GPM` the functions described in `Single Function Mode` all require an additi
|
|||||||
* ``connected_device_uuid(storage_location_key)`` -- if a device is connected then return the device uuid (unique id), otherwise return the empty string. Each storage location on a device has a different uuid. The ``storage_location_key`` location names are ``'main'``, ``'carda'`` and ``'cardb'``. This function works only in the GUI.
|
* ``connected_device_uuid(storage_location_key)`` -- if a device is connected then return the device uuid (unique id), otherwise return the empty string. Each storage location on a device has a different uuid. The ``storage_location_key`` location names are ``'main'``, ``'carda'`` and ``'cardb'``. This function works only in the GUI.
|
||||||
* ``current_library_name()`` -- return the last name on the path to the current calibre library.
|
* ``current_library_name()`` -- return the last name on the path to the current calibre library.
|
||||||
* ``current_library_path()`` -- return the full path to the current calibre library.
|
* ``current_library_path()`` -- return the full path to the current calibre library.
|
||||||
|
* ``current_virtual_library_name()`` -- return the name of the current virtual library if there is one, otherwise the empty string. Library name case is preserved. Example: ``program: current_virtual_library_name()``. This function works only in the GUI.
|
||||||
* ``date_arithmetic(date, calc_spec, fmt)`` -- Calculate a new date from ``date`` using ``calc_spec``. Return the new date formatted according to optional ``fmt``: if not supplied then the result will be in ISO format. The calc_spec is a string formed by concatenating pairs of ``vW`` (``valueWhat``) where ``v`` is a possibly-negative number and W is one of the following letters:
|
* ``date_arithmetic(date, calc_spec, fmt)`` -- Calculate a new date from ``date`` using ``calc_spec``. Return the new date formatted according to optional ``fmt``: if not supplied then the result will be in ISO format. The calc_spec is a string formed by concatenating pairs of ``vW`` (``valueWhat``) where ``v`` is a possibly-negative number and W is one of the following letters:
|
||||||
|
|
||||||
* ``s``: add ``v`` seconds to ``date``
|
* ``s``: add ``v`` seconds to ``date``
|
||||||
|
@ -1762,6 +1762,22 @@ class BuiltinVirtualLibraries(BuiltinFormatterFunction):
|
|||||||
return _('This function can be used only in the GUI')
|
return _('This function can be used only in the GUI')
|
||||||
|
|
||||||
|
|
||||||
|
class BuiltinCurrentVirtualLibraryName(BuiltinFormatterFunction):
|
||||||
|
name = 'current_virtual_library_name'
|
||||||
|
arg_count = 0
|
||||||
|
category = 'Get values from metadata'
|
||||||
|
__doc__ = doc = _('current_virtual_library_name() -- '
|
||||||
|
'return the name of the current virtual library if there is one, '
|
||||||
|
'otherwise the empty string. Library name case is preserved. '
|
||||||
|
'Example: "program: current_virtual_library_name()".')
|
||||||
|
|
||||||
|
def evaluate(self, formatter, kwargs, mi, locals):
|
||||||
|
with suppress(Exception):
|
||||||
|
from calibre.gui2.ui import get_gui
|
||||||
|
return get_gui().current_db.data.get_base_restriction_name()
|
||||||
|
return _('This function can be used only in the GUI')
|
||||||
|
|
||||||
|
|
||||||
class BuiltinUserCategories(BuiltinFormatterFunction):
|
class BuiltinUserCategories(BuiltinFormatterFunction):
|
||||||
name = 'user_categories'
|
name = 'user_categories'
|
||||||
arg_count = 0
|
arg_count = 0
|
||||||
@ -2086,7 +2102,7 @@ _formatter_builtins = [
|
|||||||
BuiltinCapitalize(), BuiltinCharacter(), BuiltinCheckYesNo(), BuiltinCeiling(),
|
BuiltinCapitalize(), BuiltinCharacter(), BuiltinCheckYesNo(), BuiltinCeiling(),
|
||||||
BuiltinCmp(), BuiltinConnectedDeviceName(), BuiltinConnectedDeviceUUID(), BuiltinContains(),
|
BuiltinCmp(), BuiltinConnectedDeviceName(), BuiltinConnectedDeviceUUID(), BuiltinContains(),
|
||||||
BuiltinCount(), BuiltinCurrentLibraryName(), BuiltinCurrentLibraryPath(),
|
BuiltinCount(), BuiltinCurrentLibraryName(), BuiltinCurrentLibraryPath(),
|
||||||
BuiltinDateArithmetic(),
|
BuiltinCurrentVirtualLibraryName(), BuiltinDateArithmetic(),
|
||||||
BuiltinDaysBetween(), BuiltinDivide(), BuiltinEval(), BuiltinFirstNonEmpty(),
|
BuiltinDaysBetween(), BuiltinDivide(), BuiltinEval(), BuiltinFirstNonEmpty(),
|
||||||
BuiltinField(), BuiltinFieldExists(),
|
BuiltinField(), BuiltinFieldExists(),
|
||||||
BuiltinFinishFormatting(), BuiltinFirstMatchingCmp(), BuiltinFloor(),
|
BuiltinFinishFormatting(), BuiltinFirstMatchingCmp(), BuiltinFloor(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user