1
0
mirror of synced 2024-11-25 10:44:23 +01:00

Minor simplification of the office-related code

This commit is contained in:
jvoisin 2018-06-21 21:24:53 +02:00
parent c1f4426612
commit a89dae054a

View File

@ -47,6 +47,8 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
full_path = os.path.join(temp_folder, item.filename) full_path = os.path.join(temp_folder, item.filename)
tmp_parser, mtype = parser_factory.get_parser(full_path) # type: ignore tmp_parser, mtype = parser_factory.get_parser(full_path) # type: ignore
if not tmp_parser: if not tmp_parser:
zout.close()
os.remove(self.output_filename)
print("%s's format (%s) isn't supported" % (item.filename, mtype)) print("%s's format (%s) isn't supported" % (item.filename, mtype))
return False return False
tmp_parser.remove_all() tmp_parser.remove_all()
@ -109,8 +111,6 @@ class MSOfficeParser(ArchiveBasedAbstractParser):
continue continue
if self._clean_internal_file(item, temp_folder, zin, zout) is False: if self._clean_internal_file(item, temp_folder, zin, zout) is False:
zout.close()
os.remove(self.output_filename)
return False return False
shutil.rmtree(temp_folder) shutil.rmtree(temp_folder)
@ -168,7 +168,6 @@ class LibreOfficeParser(ArchiveBasedAbstractParser):
continue # don't keep metadata files continue # don't keep metadata files
if self._clean_internal_file(item, temp_folder, zin, zout) is False: if self._clean_internal_file(item, temp_folder, zin, zout) is False:
os.remove(self.output_filename)
return False return False
shutil.rmtree(temp_folder) shutil.rmtree(temp_folder)