Make one string from sequence of strings, with whitespace in between. The whitespace is chosen to form lines of at most *linelen* characters, if possible.
(strings, linelen=75)
| 92 | |
| 93 | |
| 94 | def _fill(strings, linelen=75): |
| 95 | """ |
| 96 | Make one string from sequence of strings, with whitespace in between. |
| 97 | |
| 98 | The whitespace is chosen to form lines of at most *linelen* characters, |
| 99 | if possible. |
| 100 | """ |
| 101 | currpos = 0 |
| 102 | lasti = 0 |
| 103 | result = [] |
| 104 | for i, s in enumerate(strings): |
| 105 | length = len(s) |
| 106 | if currpos + length < linelen: |
| 107 | currpos += length + 1 |
| 108 | else: |
| 109 | result.append(b' '.join(strings[lasti:i])) |
| 110 | lasti = i |
| 111 | currpos = length |
| 112 | result.append(b' '.join(strings[lasti:])) |
| 113 | return b'\n'.join(result) |
| 114 | |
| 115 | |
| 116 | def _create_pdf_info_dict(backend, metadata): |