File: merge_json.py

package info (click to toggle)
embree 4.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 100,656 kB
  • sloc: cpp: 228,918; xml: 40,944; ansic: 2,685; python: 812; sh: 635; makefile: 228; csh: 42
file content (34 lines) | stat: -rwxr-xr-x 721 bytes parent folder | download
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))