MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / truncate

Function truncate

api/util/util.py:86–95  ·  view source on GitHub ↗

Truncate a string by keeping the first `ends_len` and last `ends_len` characters, separated by a delimiter.

(
    value: str,
    delimiter: str = "...",
    ends_len: int = 5,
)

Source from the content-addressed store, hash-verified

84
85
86def truncate(
87 value: str,
88 delimiter: str = "...",
89 ends_len: int = 5,
90) -> str:
91 """
92 Truncate a string by keeping the first `ends_len` and last `ends_len` characters,
93 separated by a delimiter.
94 """
95 return delimiter.join([value[:ends_len], value[-ends_len:]])
96
97
98def batched(iterable: Iterable[T], size: int) -> Generator[list[T], None, None]:

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…