summaryrefslogtreecommitdiff
path: root/cgi-bin/monkey-index.cgi
blob: 371011e327fc1effceec16ade418cd007f4eed14 (plain)
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
30
31
32
33
34
35
#!/usr/bin/python3

import cgi
import cgitb
cgitb.enable()

import os

import yaml

docroot = os.environ["DOCUMENT_ROOT"]

files = {}

testroot = os.path.join(docroot, "monkey-test")

print('Content-Type: text/plain')
print('')

for fname in os.listdir(testroot):
    if not fname.endswith(".yaml"):
        continue
    with open(os.path.join(testroot, fname), "r") as fh:
        files[fname] = yaml.load(fh)

for group in files["index.yaml"]:
    print("---")
    group["kind"] = "group"
    print(yaml.dump(group, default_flow_style=False))
    for f, content in files.items():
        if type(content) == dict and content.get("group") == group["group"]:
            d = {"kind": "test", "filename": f, "content": content}
            print("---")
            print(yaml.dump(d, default_flow_style=False))