Extends line with nicely formatted (possibly multi-line) string ``word``.
(s, line, word, line_width, next_line_prefix, legacy)
| 751 | |
| 752 | |
| 753 | def _extendLine_pretty(s, line, word, line_width, next_line_prefix, legacy): |
| 754 | """ |
| 755 | Extends line with nicely formatted (possibly multi-line) string ``word``. |
| 756 | """ |
| 757 | words = word.splitlines() |
| 758 | if len(words) == 1 or legacy <= 113: |
| 759 | return _extendLine(s, line, word, line_width, next_line_prefix, legacy) |
| 760 | |
| 761 | max_word_length = max(len(word) for word in words) |
| 762 | if (len(line) + max_word_length > line_width and |
| 763 | len(line) > len(next_line_prefix)): |
| 764 | s += line.rstrip() + '\n' |
| 765 | line = next_line_prefix + words[0] |
| 766 | indent = next_line_prefix |
| 767 | else: |
| 768 | indent = len(line)*' ' |
| 769 | line += words[0] |
| 770 | |
| 771 | for word in words[1::]: |
| 772 | s += line.rstrip() + '\n' |
| 773 | line = indent + word |
| 774 | |
| 775 | suffix_length = max_word_length - len(words[-1]) |
| 776 | line += suffix_length*' ' |
| 777 | |
| 778 | return s, line |
| 779 | |
| 780 | def _formatArray(a, format_function, line_width, next_line_prefix, |
| 781 | separator, edge_items, summary_insert, legacy): |
no test coverage detected