views:

39

answers:

2

I'm looking for a package that will automatically detect the type of and extract an archive (zip, tar.gz, etc). In Perl, this is easy - in Python, I can't find any simple package/class to do it...

+1  A: 

In Python you can use:

I'm not aware of any wrapper that can choose the right format automatically. If it exists it doesn't seem to be mentioned in the documentation for any of the above modules.

Mark Byers
+1  A: 

Riding off of Mark Byers' response, perhaps you can tie all of these together with mimetypes (also from the standard library). You could identify the type of file, and process it accordingly. The world needs a Python version of Archive::Extract, and we want you to write it!

jathanism
Don't use `mimetypes`. Use `magic` instead, although it's not part of the stdlib.
Ignacio Vazquez-Abrams
I looked at using magic, but was hoping there was something already out there...May have to write it!
Lokkju
What's wrong with `mimetypes`?
jathanism