MCPcopy Create free account
hub / github.com/Kitware/CMake / __write_json_file

Function __write_json_file

Source/cmConvertMSBuildXMLToJSON.py:443–456  ·  view source on GitHub ↗

Writes a JSON file at the path with the values provided.

(path, values)

Source from the content-addressed store, hash-verified

441
442
443def __write_json_file(path, values):
444 """Writes a JSON file at the path with the values provided."""
445 # Sort the keys to ensure ordering
446 sort_order = ['name', 'switch', 'comment', 'value', 'flags']
447 sorted_values = [
448 OrderedDict(
449 sorted(
450 value.items(), key=lambda value: sort_order.index(value[0])))
451 for value in values
452 ]
453
454 with open(path, 'w') as f:
455 json.dump(sorted_values, f, indent=2, separators=(',', ': '))
456 f.write("\n")
457
458###########################################################################################
459# private list helpers

Callers 1

mainFunction · 0.85

Calls 3

indexMethod · 0.45
dumpMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…