calibredb list: Fix error if one of the requested fields if empty for all requested books

This commit is contained in:
Kovid Goyal 2014-02-04 17:32:32 +05:30
parent 3ff7f39b4b
commit 2e608ed179

View File

@ -131,11 +131,11 @@ def do_list(db, fields, afields, sort_by, ascending, search_text, line_width, se
with ColoredStream(sys.stdout, fg='green'): with ColoredStream(sys.stdout, fg='green'):
print ''.join(titles) print ''.join(titles)
wrappers = map(lambda x: TextWrapper(x-1), widths) wrappers = [TextWrapper(x - 1).wrap if x > 1 else lambda y: y for x in widths]
o = cStringIO.StringIO() o = cStringIO.StringIO()
for record in data: for record in data:
text = [wrappers[i].wrap(unicode(record[field])) for i, field in enumerate(fields)] text = [wrappers[i](unicode(record[field])) for i, field in enumerate(fields)]
lines = max(map(len, text)) lines = max(map(len, text))
for l in range(lines): for l in range(lines):
for i, field in enumerate(text): for i, field in enumerate(text):