classification
Title: bz2.BZ2File doesn't support multiple streams
Type: feature request Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: niemeyer Nosy List: akuchling, niemeyer, therve, thomas.lee (4)
Priority: normal Keywords:

Created on 2007-12-14 09:20 by therve, last changed 2008-03-18 16:55 by jafo.

Messages (4)
msg58619 - (view) Author: Thomas Herve (therve) Date: 2007-12-14 09:20
The BZ2File class only supports one stream per file. It possible to have
multiple streams concatenated in one file, it the resulting data should
be the concatenation of all the streams. It's what the bunzip2 program
produces, for example. It's also supported by the gzip module.

Once this done, this would add the ability to open a file for appending,
by adding another stream to the file.

I'll probably try to do this, but the fact it's done in C (unlike gzip)
makes it harder, so if someone beats me to it, etc.
msg59897 - (view) Author: Thomas Lee (thomas.lee) Date: 2008-01-14 13:31
If you're referring to an 'append' mode for bz2file objects, it may be a
limitation of the underlying library: my version of bzlib.h only
provides BZ2_bzWriteOpen and BZ2_bzReadOpen - it's not immediately clear
how you would open a BZ2File in append mode looking at this API.

It may be possible to implement r/w/a using the lower-level
bzCompress/bzDecompress functions, but I doubt that's going to happen
unless somebody (such as yourself? :)) cares deeply about this.
msg60236 - (view) Author: A.M. Kuchling (akuchling) Date: 2008-01-19 22:00
Like gzip, you can concatenate two bzip2 files:

bzip2 -c /etc/passwd >/tmp/pass.bz2

bzip2 -c /etc/passwd >>/tmp/pass.bz2

bunzip2 will output both parts, generating two copies of the file.

So nothing needs to be done on compression, but uncompression needs to
look for another chunk of compressed data after finishing one chunk.
msg60268 - (view) Author: Thomas Herve (therve) Date: 2008-01-20 09:12
The gzip module supports reopening an existing file to add another
stream. I think the bz2 module should not the same.
History
Date User Action Args
2008-03-18 16:55:02jafosetpriority: normal
assignee: niemeyer
nosy: + niemeyer
2008-01-20 09:12:38thervesetmessages: + msg60268
2008-01-19 22:00:08akuchlingsetnosy: + akuchling
messages: + msg60236
2008-01-14 13:31:59thomas.leesetnosy: + thomas.lee
messages: + msg59897
2007-12-14 09:20:30thervecreate