1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#!/usr/bin/env python3
## Copyright 2009-2021 Intel Corporation
## SPDX-License-Identifier: Apache-2.0
import sys
import json
import glob
sys.argv
if len(sys.argv) < 3:
print("usage: merge_json.py common_file_prefix output_filename")
sys.exit(1)
common_file_prefix = sys.argv[1]
output_filename = sys.argv[2]
files = glob.glob(common_file_prefix+"*.json")
files.sort()
if (len(files) < 1):
sys.exit(1)
hero_file = files[0]
with open(hero_file, 'r') as f:
hero_data = json.load(f)
for i in range(1, len(files)):
with open(files[i], 'r') as f:
data = json.load(f)
hero_data['benchmarks'].extend(data['benchmarks'])
with open(output_filename, 'w') as f:
f.write(json.dumps(hero_data, indent=2))
|