[ANN] filelike 0.1.1
Ryan Kelly
ryan at rfk.id.au
Wed Feb 1 13:17:37 CET 2006
Hi Everyone,
I've just uploaded the first version of my module for building,
wrapping and transforming file-like objects: filelike-0.1.1
More details at: http://www.rfk.id.au/software/projects/filelike/
At the Cheese Shop: http://cheeseshop.python.org/pypi/filelike/
Cheers,
Ryan
Description:
------------
The filelike module takes care of the groundwork for implementing and
handling file-like objects that implement a rich file-like interface,
including reading, writing, and iteration. It also provides a number
of useful classes built on top of this functionality.
The main class is FileLikeBase, which implements the entire file-like
interface (currently minus seek() and tell()) on top of primitive
_read() and _write() methods. Subclasses may implement either or
both of these methods to obtain all the higher-level file behaviors.
Two methods are provided for when code expects to deal with file-like
objects:
* is_filelike(obj): checks that an object is file-like
* to_filelike(obj): wraps a variety of objects in a file-like
interface
On top of this framework are built a collection of useful classes,
including:
* TransFile: pass file contents through an arbitrary translation
function (e.g. compression, encryption, ...)
* FixedBlockSizeFile: ensure all read/write requests are aligned
with a given blocksize
* DecryptFile: on-the-fly reading and writing to an encrypted
file (using PEP272 cipher API)
As an example of the type of thing this module is designed to achieve,
here's how to use the DecryptFile class to transparently access an
encrypted file:
# Create the decryption key
from Crypto.Cipher import DES
cipher = DES.new('abcdefgh',DES.MODE_ECB)
# Open the encrypted file
f = DecryptFile(file("some_encrypted_file.bin","r"),cipher)
The object in <f> now behaves as a file-like object, transparently
decrypting the file on-the-fly as it is read.
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
ryan at rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-announce-list/attachments/20060201/5b6c3064/attachment.pgp
More information about the Python-announce-list
mailing list