json_handler_1.py 350 B

1234567
  1. def initialize(input_file, out_stream, compressed):
  2. if compressed:
  3. bytestream = BytesIO(input_file.read())
  4. input_file = GzipFile(None, "rb", fileobj=bytestream)
  5. gzip_stream = CompressedOutputStream(out_stream, "gzip") if compressed else None
  6. writer = gzip_stream if compressed else out_stream
  7. return input_file, writer