MCPcopy Index your code
hub / github.com/RustPython/RustPython / cram

Function cram

Lib/pydoc.py:270–276  ·  view source on GitHub ↗

Omit part of a string if needed to make it fit in a maximum length.

(text, maxlen)

Source from the content-addressed store, hash-verified

268 return text
269
270def 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)
279def stripid(text):

Callers 6

repr1Method · 0.85
repr_stringMethod · 0.85
repr_instanceMethod · 0.85
repr1Method · 0.85
repr_stringMethod · 0.85
repr_instanceMethod · 0.85

Calls 2

lenFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected