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

Function load_json_result

src/scancode/cli_test_utils.py:256–268  ·  view source on GitHub ↗

Load the JSON scan results file at `location` location as UTF-8 JSON. To help with test resilience against small changes some attributes are removed or streamlined such as the "tool_version" and scan "errors". To optionally also remove date attributes from "files" and "headers"

(location, remove_file_date=False)

Source from the content-addressed store, hash-verified

254
255
256def load_json_result(location, remove_file_date=False):
257 """
258 Load the JSON scan results file at `location` location as UTF-8 JSON.
259
260 To help with test resilience against small changes some attributes are
261 removed or streamlined such as the "tool_version" and scan "errors".
262
263 To optionally also remove date attributes from "files" and "headers"
264 entries, set the `remove_file_date` argument to True.
265 """
266 with io.open(location, encoding='utf-8') as res:
267 scan_results = res.read()
268 return load_json_result_from_string(scan_results, remove_file_date)
269
270
271def load_json_result_from_string(string, remove_file_date=False):

Calls 3

openMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected