MCPcopy
hub / github.com/celery/celery / truncate

Function truncate

celery/utils/text.py:89–93  ·  view source on GitHub ↗

Truncate text to a maximum number of characters.

(s: str, maxlen: int = 128, suffix: str = '...')

Source from the content-addressed store, hash-verified

87
88
89def truncate(s: str, maxlen: int = 128, suffix: str = '...') -> str:
90 """Truncate text to a maximum number of characters."""
91 if maxlen and len(s) >= maxlen:
92 return s[:maxlen].rsplit(' ', 1)[0] + suffix
93 return s
94
95
96def pluralize(n: float, text: str, suffix: str = 's') -> str:

Callers 8

test_truncate_textFunction · 0.90
__repr__Method · 0.90
__repr__Method · 0.90
joinMethod · 0.90
dump_bodyFunction · 0.90
apply_asyncMethod · 0.90
_format_charsFunction · 0.85
_safereprFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_truncate_textFunction · 0.72