Writes a JSON file at the path with the values provided.
(path, values)
| 441 | |
| 442 | |
| 443 | def __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 |