mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Allow specifying a separator in the formats_paths() function.
This commit is contained in:
parent
e21256c483
commit
89827fde3a
@ -1300,20 +1300,25 @@ format names are always uppercase, as in EPUB.
|
|||||||
|
|
||||||
class BuiltinFormatsPaths(BuiltinFormatterFunction):
|
class BuiltinFormatsPaths(BuiltinFormatterFunction):
|
||||||
name = 'formats_paths'
|
name = 'formats_paths'
|
||||||
arg_count = 0
|
arg_count = -1
|
||||||
category = GET_FROM_METADATA
|
category = GET_FROM_METADATA
|
||||||
__doc__ = doc = _(
|
__doc__ = doc = _(
|
||||||
r'''
|
r'''
|
||||||
``formats_paths()`` -- return a comma-separated list of colon-separated items
|
|
||||||
``FMT:PATH`` giving the full path to the formats of a book.[/] You can use the
|
``formats_paths([separator])`` -- return a ``separator``-separated list of
|
||||||
``select()`` function to get the path for a specific format. Note that format names
|
colon-separated items ``FMT:PATH`` giving the full path to the formats of a
|
||||||
are always uppercase, as in EPUB.
|
book.[/] The ``separator`` argument is optional. If not supplied then the
|
||||||
|
seoarator is ``', '`` (comma space). If the separator is a comma then you can
|
||||||
|
use the ``select()`` function to get the path for a specific format. Note that
|
||||||
|
format names are always uppercase, as in EPUB.
|
||||||
|
|
||||||
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
def evaluate(self, formatter, kwargs, mi, locals):
|
def evaluate(self, formatter, kwargs, mi, locals, sep=','):
|
||||||
fmt_data = mi.get('format_metadata', {})
|
fmt_data = mi.get('format_metadata', {})
|
||||||
try:
|
try:
|
||||||
return ','.join(k.upper()+':'+str(v['path']) for k,v in iteritems(fmt_data))
|
return sep.join(k.upper()+':'+str(v['path']) for k,v in iteritems(fmt_data))
|
||||||
except:
|
except:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user