Omit part of a string if needed to make it fit in a maximum length.
(text, maxlen)
| 203 | return text |
| 204 | |
| 205 | def cram(text, maxlen): |
| 206 | """Omit part of a string if needed to make it fit in a maximum length.""" |
| 207 | if len(text) > maxlen: |
| 208 | pre = max(0, (maxlen-3)//2) |
| 209 | post = max(0, maxlen-3-pre) |
| 210 | return text[:pre] + '...' + text[len(text)-post:] |
| 211 | return text |
| 212 | |
| 213 | _re_stripid = re.compile(r' at 0x[0-9a-f]{6,16}(>+)$', re.IGNORECASE) |
| 214 | def stripid(text): |
no outgoing calls
no test coverage detected
searching dependent graphs…