Skip to content
Snippets Groups Projects
Commit ec784ff1 authored by smagnin's avatar smagnin
Browse files

Correct self method

parent acff1ca6
No related branches found
No related tags found
No related merge requests found
Pipeline #19497 failed
...@@ -49,7 +49,6 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): ...@@ -49,7 +49,6 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
zipinfo.date_time = (1980, 1, 1, 0, 0, 0) # this is as early as a zipfile can be zipinfo.date_time = (1980, 1, 1, 0, 0, 0) # this is as early as a zipfile can be
return zipinfo return zipinfo
@staticmethod
def _get_zipinfo_meta(self, zipinfo: zipfile.ZipInfo) -> Dict[str, str]: def _get_zipinfo_meta(self, zipinfo: zipfile.ZipInfo) -> Dict[str, str]:
metadata = {} metadata = {}
if zipinfo.create_system == 3: # this is Linux if zipinfo.create_system == 3: # this is Linux
...@@ -146,7 +145,7 @@ class ZIPParser(ArchiveBasedAbstractParser): ...@@ -146,7 +145,7 @@ class ZIPParser(ArchiveBasedAbstractParser):
metadata = {} metadata = {}
zipin = zipfile.ZipFile(self.filename) zipin = zipfile.ZipFile(self.filename)
for item in zipin.infolist(): for item in zipin.infolist():
for key, value in self._get_zipinfo_meta(self, item).items(): for key, value in self._get_zipinfo_meta(item).items():
metadata[key] = value metadata[key] = value
zipin.close() zipin.close()
return metadata return metadata
...@@ -312,7 +312,7 @@ class MSOfficeParser(ArchiveBasedAbstractParser): ...@@ -312,7 +312,7 @@ class MSOfficeParser(ArchiveBasedAbstractParser):
metadata[key] = value metadata[key] = value
except (TypeError, UnicodeDecodeError): # We didn't manage to parse the xml file except (TypeError, UnicodeDecodeError): # We didn't manage to parse the xml file
metadata[item.filename] = 'harmful content' metadata[item.filename] = 'harmful content'
for key, value in self._get_zipinfo_meta(self, item).items(): for key, value in self._get_zipinfo_meta(item).items():
metadata[key] = value metadata[key] = value
zipin.close() zipin.close()
return metadata return metadata
...@@ -397,7 +397,7 @@ class LibreOfficeParser(ArchiveBasedAbstractParser): ...@@ -397,7 +397,7 @@ class LibreOfficeParser(ArchiveBasedAbstractParser):
metadata[key] = value metadata[key] = value
except (TypeError, UnicodeDecodeError): # We didn't manage to parse the xml file except (TypeError, UnicodeDecodeError): # We didn't manage to parse the xml file
metadata[item.filename] = 'harmful content' metadata[item.filename] = 'harmful content'
for key, value in self._get_zipinfo_meta(self, item).items(): for key, value in self._get_zipinfo_meta(item).items():
metadata[key] = value metadata[key] = value
zipin.close() zipin.close()
return metadata return metadata
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment