MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / parse

Method parse

KVCOMM/tools/reader/readers.py:199–216  ·  view source on GitHub ↗
(self, file_path: Path)

Source from the content-addressed store, hash-verified

197
198class ZipReader(Reader):
199 def parse(self, file_path: Path) -> str:
200
201 logger.info(f"Reading ZIP file from {file_path}.")
202 try:
203 file_content = ""
204 with zipfile.ZipFile(file_path, 'r') as zip_ref:
205 extract_dir = file_path[:-4] + '/'
206 zip_ref.extractall(extract_dir)
207 reader = FileReader()
208 for file_name in zip_ref.namelist():
209 file_content += f'File {file_name}:\n"{reader.read_file(extract_dir + file_name)}"\n'
210 return file_content
211
212 except zipfile.BadZipFile:
213 logger.info("Invalid ZIP file.")
214
215 except Exception as e:
216 logger.info(f"Error reading ZIP file: {e}")
217
218
219class PythonReader(Reader):

Callers

nothing calls this directly

Calls 2

read_fileMethod · 0.95
FileReaderClass · 0.85

Tested by

no test coverage detected