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

Method read

KVCOMM/tools/reader/readers.py:334–354  ·  view source on GitHub ↗
(self, task, file)

Source from the content-addressed store, hash-verified

332 """
333
334 def read(self, task, file):
335
336 files_content = ""
337 file_content = self.file_reader.read_file(file, task)
338 suffix = file.split(".")[-1]
339
340 if suffix in ['py', 'java', 'cpp', 'c', 'js', 'css', 'html', 'htm', 'xml']:
341 files_content += f'\nThe {suffix} file contains:\n---\n{file_content[0]}'
342 if file_content[1] != '':
343 files_content += f'\nExecution result:\n{file_content[1]}'
344 if file_content[2] != '':
345 files_content += f'\nExecution error message:\n{file_content[2]}'
346 files_content += '\n---'
347
348 elif suffix in ['txt', 'jsonl', 'csv', 'json', 'jsonld', 'jsonl', 'yaml', 'yml',
349 'xlsx', 'xls', 'jpg', 'png', 'jpeg', 'gif', 'bmp', 'mp3', 'wav',
350 'ogg', 'mp4', 'avi', 'mkv', 'mov', 'pdf', 'doc', 'docx', 'ppt',
351 'pptx', 'md', 'markdown', 'tex', 'zip', 'tar', 'gz', '7z', 'rar']:
352 files_content += f'\nThe {suffix} file contains:\n---\n{file_content}\n---'
353
354 return files_content
355

Callers 3

parseMethod · 0.80
parseMethod · 0.80
parseMethod · 0.80

Calls 2

read_fileMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected