Hello everyone, I need some tar functionality for my program. Currently the following code properly displays tar archives, and tar.gz archives. However, it chokes on tar.bz2 archives with the following error:
File "mail_filter.py", line 262, in extract_archive tar_archive = tarfile.open('', 'r', fileobj) File "/usr/lib/python2.3/tarfile.py", line 900, in open return func(name, "r", fileobj) File "/usr/lib/python2.3/tarfile.py", line 980, in bz2open raise ValueError, "no support for external file objects" ValueError: no support for external file objects The code snippet is: fileobj = StringIO(attach) if attach_type == 'application/x-tgz' or attach_type == 'application/x-tbz' or attach_type == 'application/x-tar': print '%s file detected, attempting to decompress' % (attach_type) tar_archive = tarfile.open('', 'r', fileobj) print tar_archive.getnames() for archive_file in tar_archive.getmembers(): print archive_file print tar_archive.extractfile(archive_file).read() #except: # print 'Error while extracting %s.' % (attach_type) # return '' I'm at my wits end with this error, it doesn't make any sense that it would treat bzip2'd tar archives very differently than gz'd tar archives. Justin -- http://mail.python.org/mailman/listinfo/python-list