Classes for creating and wrapping file-like objects
Project 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.
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 an example of using 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file filelike-0.1.0.tar.gz
.
File metadata
- Download URL: filelike-0.1.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b18ed57829c03812931b9c4073e3d7415510edef7b1fa3e3a2206e6cb9b4e91 |
|
MD5 | ba6b11d38f02e2740a0a81b6fdc790a5 |
|
BLAKE2b-256 | 10382e43a67c44af9a67e039a5ec35d8ce3227df37f4737ad93681f282471b45 |
File details
Details for the file filelike-0.1.0-py2.4.egg
.
File metadata
- Download URL: filelike-0.1.0-py2.4.egg
- Upload date:
- Size: 1.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1fca49848bfcdaaf793ecab019de52a507373c35431fed108b33950a17b7b85 |
|
MD5 | b47dcdfa384d7b3ed995cb9e84203c22 |
|
BLAKE2b-256 | 1cb9d2e56c57525e00fa9f97830dd6757d6d34f5c8de09bcd18264aad75bdbb5 |