MCPcopy Create free account
hub / github.com/daniel2005d/mapXplore / get_office

Method get_office

lib/file_reader.py:106–123  ·  view source on GitHub ↗
(self, content:bytearray)

Source from the content-addressed store, hash-verified

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:

Callers 1

get_file_typeMethod · 0.95

Calls 4

_get_formatMethod · 0.95
_read_wordMethod · 0.95
_read_excelMethod · 0.95
_read_pptMethod · 0.95

Tested by

no test coverage detected