|
| 1 | +#!/bin/python |
| 2 | +import os |
| 3 | +import re |
| 4 | + |
| 5 | +yamlpath = "src/python_interface_to_workflows/templates/" |
| 6 | +yamllist: list[str] = [] |
| 7 | +for x in os.listdir(yamlpath): |
| 8 | + if x.endswith(".yaml"): |
| 9 | + yamllist.append(x) |
| 10 | + |
| 11 | +for file in yamllist: |
| 12 | + x = 0 |
| 13 | + y = 0 |
| 14 | + z = 0 |
| 15 | + with open(yamlpath + file) as s: |
| 16 | + filelist = s.readlines() |
| 17 | + cleanfilenames: list[str] = [] |
| 18 | + for line in filelist: |
| 19 | + line = line.rstrip() |
| 20 | + cleanfilenames.append(line) |
| 21 | + required_labels: list[str] = [ |
| 22 | + r"apiVersion:\sargoproj\.io\/v1alpha", |
| 23 | + r"kind:\sClusterWorkflowTemplate", |
| 24 | + r"metadata:", |
| 25 | + r"\s\sannotations:", |
| 26 | + r"\s\s\s\sworkflows.argoproj.io/title:\s.+", |
| 27 | + r"\s\s\s\sworkflows.diamond.ac.uk/repository:\s.+", |
| 28 | + r"\s\slabels:", |
| 29 | + r"\s\s\s\sworkflows.diamond.ac.uk/science-group-.+:\s.+", |
| 30 | + ] |
| 31 | + for x in range(0, len(required_labels)): |
| 32 | + for y in range(0, len(cleanfilenames)): |
| 33 | + if re.match(required_labels[x], cleanfilenames[y]): |
| 34 | + print(required_labels[x]) |
| 35 | + z += 1 |
| 36 | + |
| 37 | + gen_name = any(re.search(r"\s\sgenerateName:\s.+", line) for line in cleanfilenames) |
| 38 | + normal_name = any(re.search(r"^\s\sname:\s.+", line) for line in cleanfilenames) |
| 39 | + if gen_name and not normal_name: |
| 40 | + z += 1 |
| 41 | + elif normal_name and not gen_name: |
| 42 | + z += 1 |
| 43 | + else: |
| 44 | + z -= 1 |
| 45 | + |
| 46 | + if z == 9: |
| 47 | + exit(0) |
| 48 | + else: |
| 49 | + print("Error! missing a label or name!") |
| 50 | + exit(1) |
0 commit comments