-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem.py
48 lines (38 loc) · 1.3 KB
/
system.py
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
46
47
48
import json
def getData(answerArray):
stringArray = answerArray
print(stringArray)
dict = {
"worldle": '',
"countryle": '',
"tradle": '',
"globle": '',
"flagle": ''
}
for line in stringArray:
if '#Worldle' in line:
if 'X' in line:
dict["worldle"] = (6)
else:
dict["worldle"] = (int(line[line.index('/6')-1]))
elif 'Guessed' in line:
string = line.replace('Guessed in ', '')
string = string.replace(' tries.', '')
dict["countryle"] = (int(string))
elif 'Gave up after' in line:
string = line.replace('Gave up after ', '')
string = string.replace(' tries.', '')
dict["countryle"] = (int(string))
elif '#Tradle' in line:
if 'X' in line:
dict["tradle"] = (6)
else:
dict["tradle"] = (int(line[line.index('/6')-1]))
elif '=' in line:
string = line.split('= ')[1]
dict["globle"] = (int(string))
elif '#Flagle' in line:
dict["flagle"] = (int(line[line.index('/6')-1]))
if any(s == '' for s in dict.values()):
raise Exception(f"No valid data")
return json.dumps(dict)