Skip to content

Encode and decode concatenated objects as streams

License

Notifications You must be signed in to change notification settings

cryptosense/streamcat

Repository files navigation

streamcat

Examples

Encoding a JSON iterator into a stream:

defgen_records(): yieldb'{"foo": "bar"}'yieldb'{"baz": [1, 2, 3]}'stream=streamcat.iterator_to_stream(gen_records()) # `stream` can then be used just like any other `io.RawIOBase`withopen('/tmp/jsoncat', 'wb') asdestination: shutil.copyfileobj(stream, destination)

Decoding a stream into a generator:

decoder=json.JSONDecoder() withopen('/tmp/jsoncat', 'rb') assource: records=streamcat.stream_to_iterator(source, decoder) forrecordinrecords: print(record)

About

Encode and decode concatenated objects as streams

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages