MCPcopy Index your code
hub / github.com/python/cpython / cram

Function cram

Lib/pydoc.py:205–211  ·  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

203 return text
204
205def 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)
214def 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

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…