diff options
| author | jvoisin | 2018-05-16 22:36:59 +0200 |
|---|---|---|
| committer | jvoisin | 2018-05-16 22:36:59 +0200 |
| commit | fa7d18784ca18c5c70bbb36cde9d5915843456c3 (patch) | |
| tree | 3c7b36ea63ecf05ba6fc777c4f3a3a74fa60a450 /src/office.py | |
| parent | 0354c3b7e3a455cce130b6226926436a21128641 (diff) | |
Do a pylint pass
Diffstat (limited to 'src/office.py')
| -rw-r--r-- | src/office.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/office.py b/src/office.py index da6168e..749fc7d 100644 --- a/src/office.py +++ b/src/office.py | |||
| @@ -9,14 +9,14 @@ from . import abstract, parser_factory | |||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | class ArchiveBasedAbstractParser(abstract.AbstractParser): | 11 | class ArchiveBasedAbstractParser(abstract.AbstractParser): |
| 12 | def _clean_zipinfo(self, zipinfo:zipfile.ZipInfo) -> zipfile.ZipInfo: | 12 | def _clean_zipinfo(self, zipinfo: zipfile.ZipInfo) -> zipfile.ZipInfo: |
| 13 | zipinfo.compress_type = zipfile.ZIP_DEFLATED | 13 | zipinfo.compress_type = zipfile.ZIP_DEFLATED |
| 14 | zipinfo.create_system = 3 # Linux | 14 | zipinfo.create_system = 3 # Linux |
| 15 | zipinfo.comment = b'' | 15 | zipinfo.comment = b'' |
| 16 | zipinfo.date_time = (1980, 1, 1, 0, 0, 0) | 16 | zipinfo.date_time = (1980, 1, 1, 0, 0, 0) |
| 17 | return zipinfo | 17 | return zipinfo |
| 18 | 18 | ||
| 19 | def _get_zipinfo_meta(self, zipinfo:zipfile.ZipInfo) -> dict: | 19 | def _get_zipinfo_meta(self, zipinfo: zipfile.ZipInfo) -> dict: |
| 20 | metadata = {} | 20 | metadata = {} |
| 21 | if zipinfo.create_system == 3: | 21 | if zipinfo.create_system == 3: |
| 22 | #metadata['create_system'] = 'Linux' | 22 | #metadata['create_system'] = 'Linux' |
| @@ -35,7 +35,8 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): | |||
| 35 | return metadata | 35 | return metadata |
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | def _clean_internal_file(self, item:zipfile.ZipInfo, temp_folder:str, zin:zipfile.ZipFile, zout:zipfile.ZipFile): | 38 | def _clean_internal_file(self, item: zipfile.ZipInfo, temp_folder: str, |
| 39 | zin: zipfile.ZipFile, zout: zipfile.ZipFile): | ||
| 39 | zin.extract(member=item, path=temp_folder) | 40 | zin.extract(member=item, path=temp_folder) |
| 40 | tmp_parser, mtype = parser_factory.get_parser(os.path.join(temp_folder, item.filename)) | 41 | tmp_parser, mtype = parser_factory.get_parser(os.path.join(temp_folder, item.filename)) |
| 41 | if not tmp_parser: | 42 | if not tmp_parser: |
| @@ -50,9 +51,9 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): | |||
| 50 | 51 | ||
| 51 | class MSOfficeParser(ArchiveBasedAbstractParser): | 52 | class MSOfficeParser(ArchiveBasedAbstractParser): |
| 52 | mimetypes = { | 53 | mimetypes = { |
| 53 | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', | 54 | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
| 54 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | 55 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
| 55 | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 56 | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' |
| 56 | } | 57 | } |
| 57 | files_to_keep = {'_rels/.rels', 'word/_rels/document.xml.rels'} | 58 | files_to_keep = {'_rels/.rels', 'word/_rels/document.xml.rels'} |
| 58 | 59 | ||
| @@ -103,13 +104,13 @@ class MSOfficeParser(ArchiveBasedAbstractParser): | |||
| 103 | 104 | ||
| 104 | class LibreOfficeParser(ArchiveBasedAbstractParser): | 105 | class LibreOfficeParser(ArchiveBasedAbstractParser): |
| 105 | mimetypes = { | 106 | mimetypes = { |
| 106 | 'application/vnd.oasis.opendocument.text', | 107 | 'application/vnd.oasis.opendocument.text', |
| 107 | 'application/vnd.oasis.opendocument.spreadsheet', | 108 | 'application/vnd.oasis.opendocument.spreadsheet', |
| 108 | 'application/vnd.oasis.opendocument.presentation', | 109 | 'application/vnd.oasis.opendocument.presentation', |
| 109 | 'application/vnd.oasis.opendocument.graphics', | 110 | 'application/vnd.oasis.opendocument.graphics', |
| 110 | 'application/vnd.oasis.opendocument.chart', | 111 | 'application/vnd.oasis.opendocument.chart', |
| 111 | 'application/vnd.oasis.opendocument.formula', | 112 | 'application/vnd.oasis.opendocument.formula', |
| 112 | 'application/vnd.oasis.opendocument.image', | 113 | 'application/vnd.oasis.opendocument.image', |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | def get_meta(self): | 116 | def get_meta(self): |
