destream: decompress a stream
- Python: 3.6, 3.7, 3.8, 3.9
- OS:
- Linux
- OSX
- Windows is not tested and requires file and libmagic for Windows
pip install destream
OR easy_install --user destream
-
Decompress multiple files of anytype to directory:
destream -o /tmp/output_dir file1.zip file2.rar file3.7z file4.tar.bz2
-
Decompress any stream to the current folder:
wget -O - "https://github.com/cecton/destream/archive/3.1.tar.gz" | destream -o ./
-
Decompress any compressed file to stdout:
destream documentation.gz | less
- Open an archive that holds multiple files (aka: ArchivePack)
archive = destream.open("some_file.tar.gz") assert (isinstance(archive, destream.ArchivePack) and isinstance(archive.tarfile, tarfile.TarFile)) # ==> we can extract members using extract() and extractall() archive.extractall("/tmp")
- Open a compressed file (or stream) and get an uncompressed stream
archive = destream.open("weird_file.bz2.gz") assert isinstance(archive, destream.Archive) # ==> we can read the content but not seek print(archive.read())
- Open an archive that holds only one file,
archive = destream.open("some_file.tar.xz") # ==> we can read the archive like it is a stream if archive.single(): print(archive.read()) else: archive.extractall('/tmp/some/path/')
-
ImportError: failed to find libmagic. Check your installation
-
Mac OS X: follow these installation guide. Or simply:
brew install libmagic
-
Arch Linux:
pacman -S file
-
Ubuntu/Debian:
apt-get install libmagic1
-
-
LZMA does not work
Check your version of file and libmagic. It's working on version 5.22 and greater but not on version 5.14 and lower.
-
Zstd does not work
Check your version of file and libmagic. It's working on version 5.32 and greater but not on version 5.25 and lower.
-
ZIP files fails to extract
If you have
libmagic
version 5.39 (released 2020-06-16), this version does not identify ZIP file v2.0 correctly. This bug inlibmagic
has been reported. Install the previous version 5.38 if you can.