(self, content:bytearray)
| 104 | |
| 105 | |
| 106 | def get_office(self, content:bytearray): |
| 107 | file_type:str = self._get_format(content) |
| 108 | document_type:str = None |
| 109 | text = "" |
| 110 | if file_type is not None: |
| 111 | if file_type == 'zip': |
| 112 | with zipfile.ZipFile(io.BytesIO(content), 'r') as zip_file: |
| 113 | if 'word/document.xml' in zip_file.namelist(): |
| 114 | document_type = 'docx' |
| 115 | text = self._read_word(zip_file, 'word/document.xml') |
| 116 | elif 'xl/workbook.xml' in zip_file.namelist(): |
| 117 | document_type = 'xlsx' |
| 118 | text = self._read_excel(content) |
| 119 | elif 'ppt/presentation.xml' in zip_file.namelist(): |
| 120 | document_type = 'pptx' |
| 121 | text = self._read_ppt(content) |
| 122 | |
| 123 | return document_type, text |
| 124 | |
| 125 | |
| 126 | def _is_base64_valid(self, text:str)->bool: |
no test coverage detected