utils.shorten_string()
Shorten a string to length n with an ellipsis in the middle if needed.
Usage
utils.shorten_string(
string,
n,
)Parameters
string: str-
The string to shorten.
n: int- Maximum length of the returned string, including the ellipsis. Values below zero are treated as zero.
Returns
str-
The original string if its length is <=
n, otherwise a shortened version with...inserted in the middle. The result never exceedsncharacters. Whennis too small to hold the...marker, the string is hard-truncated toncharacters without a marker.