From 7c05c4edef20cc7438a8a90f2e9f1b507e82c132 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 27 Jun 2011 16:52:11 +0200 Subject: Add support for tar.bz2 and tar.gz archives --- lib/archive.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/archive.py') diff --git a/lib/archive.py b/lib/archive.py index f7649d5..89425cf 100644 --- a/lib/archive.py +++ b/lib/archive.py @@ -5,13 +5,18 @@ import mat import shutil class TarStripper(parser.Generic_parser): + def compression_type(self): + self.compression = '' + def remove_all(self): + self.compression_type() if not tarfile.is_tarfile(self.filename): print('%s is not a valid tar file' % self.filename) sys.exit(1) - tarin = tarfile.open(self.filename, 'r') - tarout = tarfile.open(self.filename + parser.POSTFIX, 'w') + tarin = tarfile.open(self.filename, 'r' + self.compression) + tarout = tarfile.open(self.filename + parser.POSTFIX, + 'w' + self.compression) folder_list = [] for current_file in tarin.getmembers(): @@ -36,3 +41,11 @@ class TarStripper(parser.Generic_parser): def is_clean(self): return False + +class GzipStripper(TarStripper): + def compression_type(self): + self.compression = ':gz' + +class Bzip2Stripper(TarStripper): + def compression_type(self): + self.compression = ':bz2' -- cgit v1.3