9 output_file: click.File, json_files: list, console: Console
11 """Collate the json information into an output file."""
13 "Reading specified JSON files and outputting collated value traces to %s",
18 jd = json.JSONDecoder()
20 console.log(f
"Reading info JSON file {jf.name}")
23 while idx < len(text):
24 res = jd.raw_decode(text, idx)
27 while idx < len(text)
and text[idx] !=
'{':
32 session = jsonobj[
"origin"][
"session"]
33 application = jsonobj[
"origin"][
"application"]
35 if session
not in data:
38 if application
not in data[session]:
39 data[session][application] = {}
41 objref = data[session][application]
42 if "substructure" in jsonobj[
"origin"]:
43 for sub
in jsonobj[
"origin"][
"substructure"]:
49 jsonobj[
"measurement"].replace(
"dunedaq.",
"").replace(
"opmon.",
"")
51 if measurement
not in objref:
52 objref[measurement] = {}
53 objref = objref[measurement]
56 if "custom_origin" in jsonobj:
58 for k, v
in jsonobj[
"custom_origin"].items():
61 custom_origin += f
"{k}:{v}"
64 if custom_origin !=
"":
65 if custom_origin
not in objref:
66 objref[custom_origin] = {}
67 objref = objref[custom_origin]
69 for datapoint
in jsonobj[
"data"]:
70 if datapoint
not in objref:
71 objref[datapoint] = {}
73 for value
in jsonobj[
"data"][datapoint]:
74 objref[datapoint][jsonobj[
"time"]] = jsonobj[
"data"][datapoint][value]
76 json.dump(data, output_file, indent=4, sort_keys=
True)
77 console.log(
"Operation complete")