Python tarfile

From wikinotes

read

import tarfile

with tarfile.open( '/home/will/file.tar', 'r' ) as archive:
	contents = archive.getnames()

append

import tarfile

with tarfile.open( '/home/will/file.tar', 'a' ) as archive:
	for filepath in newfiles:
		archive.add( filepath, arcname=os.path.basename(filepath) )