diff create_container_hash.py @ 57:33412e85e669 draft

"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
author rhpvorderman
date Wed, 02 Feb 2022 10:50:01 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/create_container_hash.py	Wed Feb 02 10:50:01 2022 +0000
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+import sys
+
+from xml.etree import ElementTree
+from xml.etree.ElementTree import Element
+
+DEFAULT_BASE_IMAGE = "bgruening/busybox-bash:latest"
+def main():
+    try:
+        base_image = sys.argv[1]
+    except IndexError:
+        base_image = DEFAULT_BASE_IMAGE
+    tool = ElementTree.parse("complete_immunerepertoire.xml").getroot()
+    requirements: Element = tool.find("requirements")
+    packages = []
+    for req in requirements.findall("requirement"):
+        if req.get("type") == "package":
+            name = req.text
+            version = req.get("version")
+            package_string = f"{name}={version}"
+            packages.append(package_string)
+    with open("container_hash.tsv", mode="wt") as container_hash_file:
+        container_hash_file.write("#targets\tbase_image\timage_build\n")
+        container_hash_file.write(",".join(packages) + f"\t{base_image}\t0\n")
+
+
+if __name__ == "__main__":
+    main()