Omit part of a string if needed to make it fit in a maximum length.
(text, maxlen)
| 268 | return text |
| 269 | |
| 270 | def cram(text, maxlen): |
| 271 | """Omit part of a string if needed to make it fit in a maximum length.""" |
| 272 | if len(text) > maxlen: |
| 273 | pre = max(0, (maxlen-3)//2) |
| 274 | post = max(0, maxlen-3-pre) |
| 275 | return text[:pre] + '...' + text[len(text)-post:] |
| 276 | return text |
| 277 | |
| 278 | _re_stripid = re.compile(r' at 0x[0-9a-f]{6,16}(>+)$', re.IGNORECASE) |
| 279 | def stripid(text): |
no test coverage detected