comparison create_container_hash.py @ 90:6809c63d9161 draft

"planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
author rhpvorderman
date Tue, 25 Jan 2022 11:28:29 +0000
parents
children
comparison
equal deleted inserted replaced
89:3c9d4d976c47 90:6809c63d9161
1 #!/usr/bin/env python3
2
3 import sys
4
5 from xml.etree import ElementTree
6 from xml.etree.ElementTree import Element
7
8 DEFAULT_BASE_IMAGE = "bgruening/busybox-bash:0.1"
9 def main():
10 try:
11 base_image = sys.argv[1]
12 except IndexError:
13 base_image = DEFAULT_BASE_IMAGE
14 tool = ElementTree.parse("shm_csr.xml").getroot()
15 requirements: Element = tool.find("requirements")
16 packages = []
17 for req in requirements.findall("requirement"):
18 if req.get("type") == "package":
19 name = req.text
20 version = req.get("version")
21 package_string = f"{name}={version}"
22 packages.append(package_string)
23 with open("container_hash.tsv", mode="wt") as container_hash_file:
24 container_hash_file.write("#targets\tbase_image\timage_build\n")
25 container_hash_file.write(",".join(packages) + f"\t{base_image}\t0\n")
26
27
28 if __name__ == "__main__":
29 main()