Skip to content

Supporting other compression methods (BZip2) #66

@andormarkus

Description

@andormarkus

Is your feature request related to a problem? Please describe.
7z has open architecture, so it can support any new compression methods: LZMA, LZMA2, PPMD, BCJ, BCJ2, BZip2. (source: https://www.7-zip.org/7z.html)

I have a file which was compressed with BZip2 compression method and has the following properties:

Path = FILE_WITH_BZip2.7z
Type = 7z
Physical Size = 716637328
Headers Size = 146
Method = BZip2
Solid = -
Blocks = 1

I tried to decompress this file with the latest v0.6a1 release and I got the following error:

Traceback (most recent call last):
File "test.py", line 17, in
print(archive.test())
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/site-packages/py7zr/py7zr.py", line 688, in test
return self._test_digests()
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/site-packages/py7zr/py7zr.py", line 528, in _test_digests
if self._test_unpack_digest():
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/site-packages/py7zr/py7zr.py", line 520, in _test_unpack_digest
self.worker.extract(self.fp) # TODO: print progress
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/site-packages/py7zr/compression.py", line 277, in extract
self.src_start + positions[i + 1])
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/site-packages/py7zr/compression.py", line 307, in extract_single
self.decompress(fp, f.folder, fileish, f.uncompressed[-1], f.compressed, src_end)
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/site-packages/py7zr/compression.py", line 335, in decompress
raise DecompressionError
py7zr.exceptions.DecompressionError

Describe the solution you'd like
It would be great if py7zr package would support BZip2 compression method for file decompression.

Describe alternatives you've considered
I have tried to decompress this file in python with bz2 package but it failed. Im open to any other suggestion.

import bz2

filepath = '/home/amarkus/Downloads/FILE_WITH_BZip2.7z'
zipfile = bz2.BZ2File(filepath) # open the file
data = zipfile.read() # get the decompressed data

I got the following error:

Traceback (most recent call last):
File "test.py", line 5, in
data = zipfile.read() # get the decompressed data
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/bz2.py", line 178, in read
return self._buffer.read(size)
File "/home/amarkus/.pyenv/versions/3.7.3/lib/python3.7/_compression.py", line 103, in read
data = self._decompressor.decompress(rawblock, size)
OSError: Invalid data stream

Additional context
I dont have any

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfor extractionIssue on extraction, decompression or decryption

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions