Omit part of a string if needed to make it fit in a maximum length.
(text, maxlen)
| 231 | return text |
| 232 | |
| 233 | def cram(text, maxlen): |
| 234 | """Omit part of a string if needed to make it fit in a maximum length.""" |
| 235 | if len(text) > maxlen: |
| 236 | pre = max(0, (maxlen-3)//2) |
| 237 | post = max(0, maxlen-3-pre) |
| 238 | return text[:pre] + '...' + text[len(text)-post:] |
| 239 | return text |
| 240 | |
| 241 | _re_stripid = re.compile(r' at 0x[0-9a-f]{6,16}(>+)$', re.IGNORECASE) |
| 242 | def stripid(text): |
no test coverage detected