MCPcopy
hub / github.com/httpie/cli / load_text_file

Function load_text_file

httpie/cli/requestitems.py:212–223  ·  view source on GitHub ↗
(item: KeyValueArg)

Source from the content-addressed store, hash-verified

210
211
212def load_text_file(item: KeyValueArg) -> str:
213 path = item.value
214 try:
215 with open(os.path.expanduser(path), 'rb') as f:
216 return f.read().decode()
217 except OSError as e:
218 raise ParseError(f'{item.orig!r}: {e}')
219 except UnicodeDecodeError:
220 raise ParseError(
221 f'{item.orig!r}: cannot embed the content of {item.value!r},'
222 ' not a UTF-8 or ASCII-encoded text file'
223 )
224
225
226def load_json(arg: KeyValueArg, contents: str) -> JSONType:

Calls 2

ParseErrorClass · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected