Fix #1864340 [calibredb list output to file is broken](https://bugs.launchpad.net/calibre/+bug/1864340)

py3 apparently cant print newlines correctly when stdout is redirected
to a file. Sigh.
This commit is contained in:
Kovid Goyal 2020-02-23 08:40:11 +05:30
parent 6290903cbf
commit a41fcfd3db
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -214,12 +214,12 @@ def do_list(
lines = max(map(len, text))
for l in range(lines):
for i, field in enumerate(text):
ft = text[i][l] if l < len(text[i]) else u''
ft = text[i][l] if l < len(text[i]) else ''
stdout.write(ft.encode('utf-8'))
if i < len(text) - 1:
filler = (u'%*s' % (widths[i] - str_width(ft) - 1, u''))
filler = ('%*s' % (widths[i] - str_width(ft) - 1, ''))
stdout.write((filler + separator).encode('utf-8'))
print()
stdout.write(b'\n')
def option_parser(get_parser, args):