(self, file_path: Path)
| 197 | |
| 198 | class 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 | |
| 219 | class PythonReader(Reader): |
nothing calls this directly
no test coverage detected