3

Python supports a lot of archive formats. I personally know of tar (which supports gzip and bz2), zlib, rar, zip, lzma and 7z.

I find it a bit tedious and error-prone to do auto-detection of these formats by hand, than select the right package and deal with its respective API which is always slightly different from the others'.

Is there a unified API package that works with all these formats? It should need a minimum of additional packages to be installed and should be able to read archived file from the stream (without the need for real temporary files). I've seen pyunpack. The problem I see with it is that it only unpacks and relies on external, non-Python tools. Is there a good alternative?

1

Not quite the answer you are looking for but worth mentioning I think.

The python File System library can open a number of different file systems with a unified interface and includes an Opener, fs.opener(), which takes a URI like specifier. This should open the file system appropriately if it is any of the supported types. Current file system types include, with some platform dependency:

  • MemoryFS
  • OS
  • RPCFS
  • FTP
  • SFTP
  • S3
  • Zip

This library is extensible for other file systems e.g.: there a couple of Dropbox integrations, dropboxfs & fs-dropbox available, and others so it might be worth looking at seeing if anybody else is interested in extending this to add the missing ones once and for all.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.