MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / cram

Function cram

tools/python-3.11.9-amd64/Lib/pydoc.py:233–239  ·  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

231 return text
232
233def 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)
242def 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 1

maxFunction · 0.85

Tested by

no test coverage detected