Skip to main content

Python implementation of stream library

Project description

Python implementation of stream library parsing all files encoded by stream and writing protobuf message instances into the file by the same encoding.

Here’s a sample code using the Stream class to read from a file containing a set of alignments. It yields the protobuf objects stored in the file:

alns_list = []
with Stream.open("test.gam", "rb") as stream:
    for aln_data in stream:
        aln = Alignment()
        aln.ParseFromString(aln_data)
        alns_list.append(aln)

Or

alns_list = []
stream = Stream.open("test.gam", "rb")
for aln_data in stream:
    aln = Alignment()
    aln.ParseFromString(aln_data)
    alns_list.append(aln)
stream.close()

And here is a sample code for writing multiple protobuf objects into a file:

with Stream.open("test.gam", "wb") as stream:
    stream.write(*objects_list)
    stream.write(*another_objects_list)

Or

stream = Stream.open("test.gam", "wb")
stream.write(*objects_list)
stream.write(*another_objects_list)
stream.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystream-protobuf-0.9.1.tar.gz (9.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page