Mercurial > repos > iuc > tb_profiler_collate
diff replace_id_field_with_element_id.py @ 0:9fae5576604a draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/blob/master/tools/tb-profiler commit a6f87bb33981b0fc0c9b7a9dd822259d9a29a3a1
| author | iuc |
|---|---|
| date | Fri, 05 Sep 2025 12:50:05 +0000 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/replace_id_field_with_element_id.py Fri Sep 05 12:50:05 2025 +0000 @@ -0,0 +1,26 @@ +import json +import os +import re +import sys + + +input_file = sys.argv[1] +output_file = sys.argv[2] + +safe_file_name = re.sub(r'[^\w\-_\.]', '_', os.path.basename(output_file)) + +if not safe_file_name.endswith(".results.json"): + safe_file_name += ".results.json" + +file_id = os.path.splitext(safe_file_name)[0] + +with open(input_file, "r") as f: + data = json.load(f) + +if data.get("id") == "tbprofiler": + data["id"] = file_id + +with open(safe_file_name, "w") as f: + json.dump(data, f, indent=4) + +print(f"Copied {input_file} -> {safe_file_name}, updated id = {file_id}")
