MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / get_local_file_content

Function get_local_file_content

etc/scripts/utils_thirdparty.py:1889–1899  ·  view source on GitHub ↗

Return the content at `url` as text. Return the content as bytes is `as_text` is False.

(path, as_text=True)

Source from the content-addressed store, hash-verified

1887
1888
1889def get_local_file_content(path, as_text=True):
1890 """
1891 Return the content at `url` as text. Return the content as bytes is
1892 `as_text` is False.
1893 """
1894 if path.startswith("file://"):
1895 path = path[7:]
1896
1897 mode = "r" if as_text else "rb"
1898 with open(path, mode) as fo:
1899 return fo.read()
1900
1901
1902class RemoteNotFetchedException(Exception):

Callers 2

getMethod · 0.85
get_file_contentFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected