diff options
| author | jvoisin | 2014-01-06 23:30:28 +0000 |
|---|---|---|
| committer | jvoisin | 2014-01-06 23:30:28 +0000 |
| commit | 68e490c9efd0885deca76e5eed5247f87aa8f733 (patch) | |
| tree | adcb4d8ebbd55294f52aa32cc26e84f24e6b66a0 /MAT | |
| parent | 9c44ef035133d928afa4cbc41e40883b7460d210 (diff) | |
GUI-archive-unsupported-handling, 2nd iteration
Diffstat (limited to 'MAT')
| -rw-r--r-- | MAT/archive.py | 21 | ||||
| -rw-r--r-- | MAT/office.py | 2 |
2 files changed, 10 insertions, 13 deletions
diff --git a/MAT/archive.py b/MAT/archive.py index e6f9e14..9179e48 100644 --- a/MAT/archive.py +++ b/MAT/archive.py | |||
| @@ -172,8 +172,8 @@ class TarStripper(GenericArchiveStripper): | |||
| 172 | tarout = tarfile.open(self.output, 'w' + self.compression, encoding='utf-8') | 172 | tarout = tarfile.open(self.output, 'w' + self.compression, encoding='utf-8') |
| 173 | for item in tarin.getmembers(): | 173 | for item in tarin.getmembers(): |
| 174 | tarin.extract(item, self.tempdir) | 174 | tarin.extract(item, self.tempdir) |
| 175 | complete_name = os.path.join(self.tempdir, item.name) | ||
| 176 | if item.isfile(): | 175 | if item.isfile(): |
| 176 | complete_name = os.path.join(self.tempdir, item.name) | ||
| 177 | cfile = mat.create_class_file(complete_name, False, add2archive=self.add2archive) | 177 | cfile = mat.create_class_file(complete_name, False, add2archive=self.add2archive) |
| 178 | if cfile: | 178 | if cfile: |
| 179 | cfile.remove_all() | 179 | cfile.remove_all() |
| @@ -209,7 +209,7 @@ class TarStripper(GenericArchiveStripper): | |||
| 209 | ''' | 209 | ''' |
| 210 | if list_unsupported: | 210 | if list_unsupported: |
| 211 | ret_list = [] | 211 | ret_list = [] |
| 212 | tmp_len = len(self.tempdir) + 1 # trim the tempfile path | 212 | tempdir_len = len(self.tempdir) + 1 # trim the tempfile path |
| 213 | tarin = tarfile.open(self.filename, 'r' + self.compression) | 213 | tarin = tarfile.open(self.filename, 'r' + self.compression) |
| 214 | for item in tarin.getmembers(): | 214 | for item in tarin.getmembers(): |
| 215 | if not self.is_file_clean(item) and not list_unsupported: | 215 | if not self.is_file_clean(item) and not list_unsupported: |
| @@ -219,21 +219,18 @@ class TarStripper(GenericArchiveStripper): | |||
| 219 | if item.isfile(): | 219 | if item.isfile(): |
| 220 | class_file = mat.create_class_file(complete_name, False, add2archive=self.add2archive) | 220 | class_file = mat.create_class_file(complete_name, False, add2archive=self.add2archive) |
| 221 | if class_file: | 221 | if class_file: |
| 222 | # We don't support nested archives | ||
| 222 | if not class_file.is_clean(): | 223 | if not class_file.is_clean(): |
| 223 | # We don't support nested archives | 224 | if not list_unsupported: |
| 224 | if list_unsupported: | ||
| 225 | if isinstance(class_file, GenericArchiveStripper): | ||
| 226 | ret_list.append(complete_name[tmp_len:]) | ||
| 227 | else: | ||
| 228 | return False | 225 | return False |
| 226 | elif isinstance(class_file, GenericArchiveStripper): | ||
| 227 | ret_list.append(complete_name[tempdir_len:]) | ||
| 229 | else: | 228 | else: |
| 230 | logging.error('%s\'s format is not supported or harmless' % item.name) | 229 | logging.error('%s\'s format is not supported or harmless' % item.name) |
| 231 | basename, ext = os.path.splitext(complete_name) | 230 | if os.path.splitext(complete_name)[1] not in parser.NOMETA: |
| 232 | if ext not in parser.NOMETA: | 231 | if not list_unsupported: |
| 233 | if list_unsupported: | ||
| 234 | ret_list.append(complete_name[tmp_len:]) | ||
| 235 | else: | ||
| 236 | return False | 232 | return False |
| 233 | ret_list.append(complete_name[tempdir_len:]) | ||
| 237 | tarin.close() | 234 | tarin.close() |
| 238 | if list_unsupported: | 235 | if list_unsupported: |
| 239 | return ret_list | 236 | return ret_list |
diff --git a/MAT/office.py b/MAT/office.py index 91e49be..f60fc64 100644 --- a/MAT/office.py +++ b/MAT/office.py | |||
| @@ -21,7 +21,7 @@ import parser | |||
| 21 | import archive | 21 | import archive |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | class OpenDocumentStripper(archive.GenericArchiveStripper): | 24 | class OpenDocumentStripper(archive.ZipStripper): |
| 25 | ''' An open document file is a zip, with xml file into. | 25 | ''' An open document file is a zip, with xml file into. |
| 26 | The one that interest us is meta.xml | 26 | The one that interest us is meta.xml |
| 27 | ''' | 27 | ''' |
