216 if (ExtractorBuilder.try_by_mimetype(filename) or |
216 if (ExtractorBuilder.try_by_mimetype(filename) or |
217 ExtractorBuilder.try_by_extension(filename)): |
217 ExtractorBuilder.try_by_extension(filename)): |
218 self.included_archives.append(os.path.join(path, filename)) |
218 self.included_archives.append(os.path.join(path, filename)) |
219 |
219 |
220 def check_contents(self): |
220 def check_contents(self): |
221 self.contents = os.listdir('.') |
|
222 if not self.contents: |
221 if not self.contents: |
223 self.content_type = EMPTY |
222 self.content_type = EMPTY |
224 elif len(self.contents) == 1: |
223 elif len(self.contents) == 1: |
225 if self.basename() == self.contents[0]: |
224 if self.basename() == self.contents[0]: |
226 self.content_type = MATCHING_DIRECTORY |
225 self.content_type = MATCHING_DIRECTORY |
273 old_path = os.path.realpath(os.curdir) |
272 old_path = os.path.realpath(os.curdir) |
274 os.chdir(self.target) |
273 os.chdir(self.target) |
275 try: |
274 try: |
276 self.archive.seek(0, 0) |
275 self.archive.seek(0, 0) |
277 self.extract_archive() |
276 self.extract_archive() |
|
277 self.contents = os.listdir('.') |
278 self.check_contents() |
278 self.check_contents() |
279 self.check_success(self.content_type != EMPTY) |
279 self.check_success(self.content_type != EMPTY) |
280 except EXTRACTION_ERRORS: |
280 except EXTRACTION_ERRORS: |
281 self.archive.close() |
281 self.archive.close() |
282 os.chdir(old_path) |
282 os.chdir(old_path) |