MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / _truncate

Function _truncate

bson/json_util.py:1141–1151  ·  view source on GitHub ↗
(obj: Any, remaining: int)

Source from the content-addressed store, hash-verified

1139
1140
1141def _truncate(obj: Any, remaining: int) -> Tuple[Any, int]:
1142 size = get_size(obj, remaining)
1143
1144 if size <= remaining:
1145 return obj, remaining - size
1146 else:
1147 try:
1148 truncated = obj[:remaining]
1149 except TypeError:
1150 truncated = obj
1151 return truncated, remaining - size

Callers 1

_truncate_documentsFunction · 0.85

Calls 1

get_sizeFunction · 0.85

Tested by

no test coverage detected