Simplified utils.text.StreamingBuffer.

This commit is contained in:
Sergey Fedoseev 2018-10-04 17:28:03 +05:00 committed by Tim Graham
parent d093e01ec0
commit 277017aea4
1 changed files with 4 additions and 17 deletions

View File

@ -280,26 +280,13 @@ def compress_string(s):
return zbuf.getvalue()
class StreamingBuffer:
def __init__(self):
self.vals = []
def write(self, val):
self.vals.append(val)
class StreamingBuffer(BytesIO):
def read(self):
if not self.vals:
return b''
ret = b''.join(self.vals)
self.vals = []
ret = self.getvalue()
self.seek(0)
self.truncate()
return ret
def flush(self):
return
def close(self):
return
# Like compress_string, but for iterators of strings.
def compress_sequence(sequence):