Mercurial > repos > davidvanzessen > argalaxy_tools
annotate create_container_hash.py @ 58:4c6df851e262 draft default tip
"planemo upload commit 1a7731bb4fe2e80fb1fdc88121783068af3edb08"
author | rhpvorderman |
---|---|
date | Fri, 21 Apr 2023 10:04:39 +0000 |
parents | 33412e85e669 |
children |
rev | line source |
---|---|
57
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
2 |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
3 import sys |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
4 |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
5 from xml.etree import ElementTree |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
6 from xml.etree.ElementTree import Element |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
7 |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
8 DEFAULT_BASE_IMAGE = "bgruening/busybox-bash:latest" |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
9 def main(): |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
10 try: |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
11 base_image = sys.argv[1] |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
12 except IndexError: |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
13 base_image = DEFAULT_BASE_IMAGE |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
14 tool = ElementTree.parse("complete_immunerepertoire.xml").getroot() |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
15 requirements: Element = tool.find("requirements") |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
16 packages = [] |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
17 for req in requirements.findall("requirement"): |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
18 if req.get("type") == "package": |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
19 name = req.text |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
20 version = req.get("version") |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
21 package_string = f"{name}={version}" |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
22 packages.append(package_string) |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
23 with open("container_hash.tsv", mode="wt") as container_hash_file: |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
24 container_hash_file.write("#targets\tbase_image\timage_build\n") |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
25 container_hash_file.write(",".join(packages) + f"\t{base_image}\t0\n") |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
26 |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
27 |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
28 if __name__ == "__main__": |
33412e85e669
"planemo upload commit 2a9ed3adf321f18047c3746735a5e79a4586798d"
rhpvorderman
parents:
diff
changeset
|
29 main() |