MCPcopy Create free account
hub / github.com/celery/celery / _format_binary_bytes

Function _format_binary_bytes

celery/utils/saferepr.py:119–125  ·  view source on GitHub ↗
(val, maxlen, ellipsis='...')

Source from the content-addressed store, hash-verified

117
118
119def _format_binary_bytes(val, maxlen, ellipsis='...'):
120 # type: (bytes, int, str) -> str
121 if maxlen and len(val) > maxlen:
122 # we don't want to copy all the data, just take what we need.
123 chunk = memoryview(val)[:maxlen].tobytes()
124 return _bytes_prefix(f"'{_repr_binary_bytes(chunk)}{ellipsis}'")
125 return _bytes_prefix(f"'{_repr_binary_bytes(val)}'")
126
127
128def _bytes_prefix(s):

Callers 1

_format_charsFunction · 0.85

Calls 2

_bytes_prefixFunction · 0.85
_repr_binary_bytesFunction · 0.85

Tested by

no test coverage detected