forked from ErasmusMC-Bioinformatics/shm_csr
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_container_hash.py
More file actions
29 lines (24 loc) · 924 Bytes
/
create_container_hash.py
File metadata and controls
29 lines (24 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
import sys
from xml.etree import ElementTree
from xml.etree.ElementTree import Element
DEFAULT_BASE_IMAGE = "bgruening/busybox-bash:0.1"
def main():
try:
base_image = sys.argv[1]
except IndexError:
base_image = DEFAULT_BASE_IMAGE
tool = ElementTree.parse("shm_csr.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()