3603: PySDK Collection objects support file-like APIs.
authorBrett Smith <brett@curoverse.com>
Wed, 12 Nov 2014 14:42:17 +0000 (09:42 -0500)
committerBrett Smith <brett@curoverse.com>
Wed, 12 Nov 2014 14:42:19 +0000 (09:42 -0500)
commit7bf8f6c701e28e574c137b0c942522e8f8ee4d8c
tree02f060975c484819fc39c0b418bd917936cdf85e
parent7924077e3db2898de26c86599d9f311e02d6db46
3603: PySDK Collection objects support file-like APIs.

This commit adds an open() method to CollectionReader and
CollectionWriter.  They mimic the built-in open(), returning objects
that implement as much as the Python file API as I can reasonably
manage.

There are a couple of backwards-incompatible changes to
StreamFileReader here:

* seek() now defaults to SEEK_CUR rather than SEEK_SET behavior.
* readlines() returns a list, and no longer supports decompression.

These changes bring the object closer to a file-like object.  We
reviewed our existing Python code, including known Crunch scripts from
users.  Nobody was using seek(), and nobody was obviously relying on
the decompression behavior of readlines().  So we believe this is
reasonably safe.

(Contrast name(), which lots of things are using, so we provide a
backward compatibility shim for it.)
sdk/python/arvados/arvfile.py [new file with mode: 0644]
sdk/python/arvados/collection.py
sdk/python/arvados/stream.py
sdk/python/tests/arvados_testutil.py
sdk/python/tests/test_collections.py
sdk/python/tests/test_stream.py