comparison replace_id_field_with_element_id.py @ 0:82d71ed440f6 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/tb-profiler commit 7dba70c70c9fe33353a0fd21803b11cfddc42c32
author iuc
date Tue, 21 Oct 2025 10:24:35 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:82d71ed440f6
1 import json
2 import os
3 import re
4 import sys
5
6
7 input_file = sys.argv[1]
8 output_file = sys.argv[2]
9
10 safe_file_name = re.sub(r'[^\w\-_\.]', '_', os.path.basename(output_file))
11
12 if not safe_file_name.endswith(".results.json"):
13 safe_file_name += ".results.json"
14
15 file_id = os.path.splitext(safe_file_name)[0]
16
17 with open(input_file, "r") as f:
18 data = json.load(f)
19
20 if data.get("id") == "tbprofiler":
21 data["id"] = file_id
22
23 with open(safe_file_name, "w") as f:
24 json.dump(data, f, indent=4)
25
26 print(f"Copied {input_file} -> {safe_file_name}, updated id = {file_id}")