summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/archive.py17
-rw-r--r--lib/mat.py4
2 files changed, 18 insertions, 3 deletions
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
5import shutil 5import shutil
6 6
7class TarStripper(parser.Generic_parser): 7class TarStripper(parser.Generic_parser):
8 def compression_type(self):
9 self.compression = ''
10
8 def remove_all(self): 11 def remove_all(self):
12 self.compression_type()
9 if not tarfile.is_tarfile(self.filename): 13 if not tarfile.is_tarfile(self.filename):
10 print('%s is not a valid tar file' % self.filename) 14 print('%s is not a valid tar file' % self.filename)
11 sys.exit(1) 15 sys.exit(1)
12 16
13 tarin = tarfile.open(self.filename, 'r') 17 tarin = tarfile.open(self.filename, 'r' + self.compression)
14 tarout = tarfile.open(self.filename + parser.POSTFIX, 'w') 18 tarout = tarfile.open(self.filename + parser.POSTFIX,
19 'w' + self.compression)
15 folder_list = [] 20 folder_list = []
16 21
17 for current_file in tarin.getmembers(): 22 for current_file in tarin.getmembers():
@@ -36,3 +41,11 @@ class TarStripper(parser.Generic_parser):
36 41
37 def is_clean(self): 42 def is_clean(self):
38 return False 43 return False
44
45class GzipStripper(TarStripper):
46 def compression_type(self):
47 self.compression = ':gz'
48
49class Bzip2Stripper(TarStripper):
50 def compression_type(self):
51 self.compression = ':bz2'
diff --git a/lib/mat.py b/lib/mat.py
index 732dc25..9624511 100644
--- a/lib/mat.py
+++ b/lib/mat.py
@@ -25,6 +25,8 @@ strippers = {
25 hachoir_parser.audio.MpegAudioFile: audio.MpegAudioStripper, 25 hachoir_parser.audio.MpegAudioFile: audio.MpegAudioStripper,
26 hachoir_parser.misc.PDFDocument: misc.PdfStripper, 26 hachoir_parser.misc.PDFDocument: misc.PdfStripper,
27 hachoir_parser.archive.TarFile: archive.TarStripper, 27 hachoir_parser.archive.TarFile: archive.TarStripper,
28 hachoir_parser.archive.gzip_parser.GzipParser: archive.GzipStripper,
29 hachoir_parser.archive.bzip2_parser.Bzip2Parser: archive.Bzip2Stripper,
28} 30}
29 31
30def is_secure(filename): 32def is_secure(filename):
@@ -33,7 +35,7 @@ def is_secure(filename):
33 ''' 35 '''
34 36
35 if not(os.path.isfile(filename)): #check if the file exist 37 if not(os.path.isfile(filename)): #check if the file exist
36 print("Error: %s is not a valid file" % name) 38 print("Error: %s is not a valid file" % filename)
37 sys.exit(1) 39 sys.exit(1)
38 40
39def create_class_file(name, backup): 41def create_class_file(name, backup):