Thread: size column
View Single Post
Old 09-30-2011, 06:34 AM   #6
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by iomari View Post
Is it possible to format the {:'formats_sizes()'} function with human readable? I tried {:'human_readable(formats_sizes())'} but it returned an error.
No. Human_readable requires a single number.

You can, of course, do this in a user-defined formatter function. It would look something like
Code:
Function name: mySizes
Arg count: 1
Program code:
def evaluate(self, formatter, kwargs, mi, locals, x):
	from calibre import human_readable
	r = []
	if x.strip():
		for p in x.split(','):
			v = p.split(':')
			r.append(v[0] + ': ' + human_readable(long(v[1])))
	return ', '.join(r)
and would be used something like
Code:
{:'mySizes(formats_sizes())'}
chaley is offline   Reply With Quote