MCPcopy Index your code
hub / github.com/bugy/script-server / read_file

Function read_file

src/utils/file_utils.py:53–71  ·  view source on GitHub ↗
(filename, byte_content=False, keep_newlines=False)

Source from the content-addressed store, hash-verified

51
52
53def read_file(filename, byte_content=False, keep_newlines=False):
54 path = normalize_path(filename)
55
56 mode = 'r'
57 if byte_content:
58 with open(path, mode + 'b') as f:
59 return f.read()
60
61 try:
62 newline = '' if keep_newlines else None
63 with open(path, mode, newline=newline) as f:
64 return f.read()
65
66 except UnicodeDecodeError as e:
67 encoded_result = try_encoded_read(path)
68 if encoded_result is not None:
69 return encoded_result
70 else:
71 raise e
72
73
74def try_encoded_read(path):

Callers

nothing calls this directly

Calls 3

normalize_pathFunction · 0.85
try_encoded_readFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected