File size: 1,004 Bytes
3b83fd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
from re import search

phases = ["iFAT", "(i)SAT"]

inputPhases = {**{i: k for i, k in enumerate(phases)}, **{len(phases): "All"}}

exitinput = {"no", "n", "0"}


def printOptions():
    print("\nchoose one of the following options;\n")
    for key in inputPhases:
        print("[%d] %s" % (key, inputPhases[key]))
    print()


def getObjectsPerPhase(phase: str = "All"):
    f = open("./objecten.txt", "r")
    t = f.read().split("\n\n")
    f.close()

    objs = {p: [] for p in phases}
    if phase in phases:
        objs = {phase:[]}

    regObject = r"\d{4}[a-zA-Z]{2}"
    for g in t:
        ls = g.split("\n")
        k = ls[0]
        if k in objs:
            objs[k] = ls[1::]
        else:
            print("key [%s] is not recognized" % k)

    objs = {k: objs[k] for k in objs if objs[k]}

    for k in objs:
        for i, o in enumerate(objs[k]):
            m = search(regObject, o)
            if not m:
                continue
            objs[k][i] = m.group(0)

    return objs