in darabonba/utils/stream.py [0:0]
def read_as_bytes(stream) -> bytes:
"""
Read data from a readable stream, and compose it to a bytes
@param stream: the readable stream
@return: the bytes result
"""
if isinstance(stream, READABLE):
b = b''
for part in Stream.__read_part(stream, 1024):
b += part
return b
elif isinstance(stream, bytes):
return stream
else:
return bytes(stream, encoding='utf-8')