Commit Graph

4 Commits

Author SHA1 Message Date
Brant Watson 0f9581cd85 Implment __len__ magic method 2016-10-24 07:19:32 -05:00
Brant Watson 4d95ea1031 Update tests to be python2.6 compatible 2016-10-21 17:03:30 -05:00
Brant Watson 774ce34bd7 Remove six dependenct in ioutils 2016-10-21 16:35:22 -05:00
Brant Watson 580142da3b Add ioutils module
Spooled Temporary Files are file-like objects
that start out mapped to in-memory objects, but
automatically roll over to a temporary file once
they reach a certain (configurable) threshhold.
Unfortunately the built-in SpooledTemporaryFile
class in Python does not implement the exact API
that some common classes like StringIO do.
SpooledTemporaryFile also spools all of it's in-memory
files as cStringIO instances. cStringIO instances cannot
be deep-copied, and they don't work with the zip
library either. This along with the incompatible api makes
it useless for several use-cases.

To combat this but still gain the memory savings and
usefulness of a true spooled file-like-object, two custom
classes have been implemented which have a compatible API.

SpooledBytesIO is a spooled file-like-object that only
accepts bytes. On Python 2.x this means the 'str' type; on
Python 3.x this means the 'bytes' type. Bytes are written
in and retrieved exactly as given, but it will raise TypeErrors
if something other than bytes are written.

SpooledStringIO is a spooled file-like-object that only accepts
unicode values. On Python 2.x this means the 'unicode' type and
on Python 3.x this means the 'str' type. Values are accepted as
unicode and then coerced into utf-8 encoded bytes for storage. On
retrieval, the values are returned as unicode.
2016-10-21 16:13:44 -05:00