MCPcopy Create free account
hub / github.com/docker/docker-py / stream_as_text

Function stream_as_text

docker/utils/json_stream.py:9–19  ·  view source on GitHub ↗

Given a stream of bytes or text, if any of the items in the stream are bytes convert them to text. This function can be removed once we return text streams instead of byte streams.

(stream)

Source from the content-addressed store, hash-verified

7
8
9def stream_as_text(stream):
10 """
11 Given a stream of bytes or text, if any of the items in the stream
12 are bytes convert them to text.
13 This function can be removed once we return text streams
14 instead of byte streams.
15 """
16 for data in stream:
17 if not isinstance(data, str):
18 data = data.decode('utf-8', 'replace')
19 yield data
20
21
22def json_splitter(buffer):

Calls

no outgoing calls