diff options
Diffstat (limited to 'lib/archive.py')
| -rw-r--r-- | lib/archive.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/archive.py b/lib/archive.py index 6378cab..c8203c9 100644 --- a/lib/archive.py +++ b/lib/archive.py | |||
| @@ -1,6 +1,33 @@ | |||
| 1 | import tarfile | ||
| 2 | import sys | ||
| 1 | import parser | 3 | import parser |
| 4 | import mat | ||
| 2 | 5 | ||
| 3 | class TarStripper(parser.Generic_parser): | 6 | class TarStripper(parser.Generic_parser): |
| 4 | def remove_all(self): | 7 | def remove_all(self): |
| 5 | for file in self.editor.array("file"): | 8 | if not tarfile.is_tarfile(self.filename): |
| 6 | print file.name | 9 | print('%s is not a valid tar file' % self.filename) |
| 10 | sys.exit(1) | ||
| 11 | |||
| 12 | tarin = tarfile.open(self.filename, 'r') | ||
| 13 | tarout = tarfile.open(self.filename + parser.POSTFIX, 'w') | ||
| 14 | |||
| 15 | for current_file in tarin.getmembers(): | ||
| 16 | tarin.extract(current_file) | ||
| 17 | if current_file.type is '0': #is current_file a regular file ? | ||
| 18 | #no backup file | ||
| 19 | class_file = mat.create_class_file(current_file.name, False) | ||
| 20 | class_file.remove_all() | ||
| 21 | tarout.add(current_file.name) | ||
| 22 | |||
| 23 | #meta from the tar itself | ||
| 24 | tarout.mtime = None | ||
| 25 | |||
| 26 | tarout.close() | ||
| 27 | tarin.close() | ||
| 28 | |||
| 29 | def is_clean(self): | ||
| 30 | return False | ||
| 31 | |||
| 32 | |||
| 33 | |||
