Extends line with nicely formatted (possibly multi-line) string ``word``.
(s, line, word, line_width, next_line_prefix, legacy)
| 825 | |
| 826 | |
| 827 | def _extendLine_pretty(s, line, word, line_width, next_line_prefix, legacy): |
| 828 | """ |
| 829 | Extends line with nicely formatted (possibly multi-line) string ``word``. |
| 830 | """ |
| 831 | words = word.splitlines() |
| 832 | if len(words) == 1 or legacy <= 113: |
| 833 | return _extendLine(s, line, word, line_width, next_line_prefix, legacy) |
| 834 | |
| 835 | max_word_length = max(len(word) for word in words) |
| 836 | if (len(line) + max_word_length > line_width and |
| 837 | len(line) > len(next_line_prefix)): |
| 838 | s += line.rstrip() + '\n' |
| 839 | line = next_line_prefix + words[0] |
| 840 | indent = next_line_prefix |
| 841 | else: |
| 842 | indent = len(line) * ' ' |
| 843 | line += words[0] |
| 844 | |
| 845 | for word in words[1::]: |
| 846 | s += line.rstrip() + '\n' |
| 847 | line = indent + word |
| 848 | |
| 849 | suffix_length = max_word_length - len(words[-1]) |
| 850 | line += suffix_length * ' ' |
| 851 | |
| 852 | return s, line |
| 853 | |
| 854 | def _formatArray(a, format_function, line_width, next_line_prefix, |
| 855 | separator, edge_items, summary_insert, legacy): |
no test coverage detected
searching dependent graphs…