1278 # adjust for weird terminal size |
1278 # adjust for weird terminal size |
1279 width = max(78, hangindent + 1) |
1279 width = max(78, hangindent + 1) |
1280 padding = '\n' + ' ' * hangindent |
1280 padding = '\n' + ' ' * hangindent |
1281 # To avoid corrupting multi-byte characters in line, we must wrap |
1281 # To avoid corrupting multi-byte characters in line, we must wrap |
1282 # a Unicode string instead of a bytestring. |
1282 # a Unicode string instead of a bytestring. |
1283 u = line.decode(encoding.encoding) |
1283 try: |
1284 w = padding.join(textwrap.wrap(u, width=width - hangindent)) |
1284 u = line.decode(encoding.encoding) |
1285 return w.encode(encoding.encoding) |
1285 w = padding.join(textwrap.wrap(u, width=width - hangindent)) |
|
1286 return w.encode(encoding.encoding) |
|
1287 except UnicodeDecodeError: |
|
1288 return padding.join(textwrap.wrap(line, width=width - hangindent)) |
1286 |
1289 |
1287 def iterlines(iterator): |
1290 def iterlines(iterator): |
1288 for chunk in iterator: |
1291 for chunk in iterator: |
1289 for line in chunk.splitlines(): |
1292 for line in chunk.splitlines(): |
1290 yield line |
1293 yield line |