Skip to content

destream-py/destream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test destream codecov PyPI PyPI - Python Version

destream

destream: decompress a stream

Compatibility

  • Python: 3.6, 3.7, 3.8, 3.9
  • OS:
    • Linux
    • OSX
    • Windows is not tested and requires file and libmagic for Windows

Installation

pip install destream OR easy_install --user destream

Usage

  1. Decompress multiple files of anytype to directory:

    destream -o /tmp/output_dir file1.zip file2.rar file3.7z file4.tar.bz2
  2. Decompress any stream to the current folder:

    wget -O - "https://github.com/cecton/destream/archive/3.1.tar.gz" | destream -o ./
  3. Decompress any compressed file to stdout:

    destream documentation.gz | less

Lib Usage

  1. 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")
  2. 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())
  3. 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/')

Troubleshooting

  • 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 in libmagic has been reported. Install the previous version 5.38 if you can.