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

Method parse

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

Source from the content-addressed store, hash-verified

218
219class PythonReader(Reader):
220 def parse(self, file_path: Path) -> str:
221 logger.info(f"Executing and reading Python file from {file_path}.")
222 execution_result = ""
223 error = ""
224 file_content = ""
225 try:
226 completed_process = subprocess.run(["python", file_path], capture_output=True, text=True, check=True)
227 execution_result = "Output:\n" + completed_process.stdout
228 except subprocess.CalledProcessError as e:
229 error = "Error:\n" + e.stderr
230 except Exception as e:
231 logger.info(f"Error executing Python file: {e}")
232
233 try:
234 with open(file_path, "r") as file:
235 file_content = "\nFile Content:\n" + file.read()
236 except Exception as e:
237 logger.info(f"Error reading Python file: {e}")
238 return file_content, execution_result, error
239
240
241class IMGReader(Reader):

Callers

nothing calls this directly

Calls 2

readMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected