import sqlite3
import subprocess
-from common import decompress_stream, yield_lines
-
-def yield_chunks(filelike, chunksize=65536):
- while True:
- data = filelike.read(chunksize)
- if not data:
- break
- yield data
+from common import decompress_stream, yield_lines, yield_chunks
def scan_log_status(filelike):
it = yield_chunks(filelike)
yield data
if hasattr(decompressor, "flush"):
yield decompressor.flush()
+
+def yield_chunks(filelike, chunksize=65536):
+ """Read the given file in chunks of the given size. Returns an itrable
+ of contents. If the file is binary, it yields bytes, otherwise str."""
+ while True:
+ data = filelike.read(chunksize)
+ if not data:
+ break
+ yield data