MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / _transform_file

Function _transform_file

src/opencode_ai/_files.py:63–74  ·  view source on GitHub ↗
(file: FileTypes)

Source from the content-addressed store, hash-verified

61
62
63def _transform_file(file: FileTypes) -> HttpxFileTypes:
64 if is_file_content(file):
65 if isinstance(file, os.PathLike):
66 path = pathlib.Path(file)
67 return (path.name, path.read_bytes())
68
69 return file
70
71 if is_tuple_t(file):
72 return (file[0], read_file_content(file[1]), *file[2:])
73
74 raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
75
76
77def read_file_content(file: FileContent) -> HttpxFileContent:

Callers 1

to_httpx_filesFunction · 0.85

Calls 3

is_file_contentFunction · 0.85
is_tuple_tFunction · 0.85
read_file_contentFunction · 0.85

Tested by

no test coverage detected