MCPcopy Create free account
hub / github.com/datapane/datapane / _truncate_strings

Method _truncate_strings

python-client/src/datapane/blocks/base.py:57–64  ·  view source on GitHub ↗
(kwargs: dict, key: str, max_length: int)

Source from the content-addressed store, hash-verified

55
56 @staticmethod
57 def _truncate_strings(kwargs: dict, key: str, max_length: int):
58 if key in kwargs:
59 x: str = kwargs[key]
60 if x and len(x) > max_length:
61 kwargs[key] = f"{x[:max_length-3]}..."
62 log.warning(f"{key} currently '{x}'")
63 log.warning(f"{key} must be less than {max_length} characters, truncating")
64 # raise DPClientError(f"{key} must be less than {max_length} characters, '{x}'")
65
66 def _add_attributes(self, **kwargs):
67 self._attributes.update(mk_attribs(**kwargs))

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected