-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMM8RelayFix.py
47 lines (43 loc) · 1.69 KB
/
MM8RelayFix.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
import os
def get_file(): # inputs: pulls './quantum.slx'; outputs: list "lines" of file split by line into list.
if os.path.isfile('./quantum.slx') == False:
input("file \"quantum.slx\" does not exist! please ensure that this executable \
is in the same folder as the start list file.\npress <Enter> to close this window.")
sys.exit()
check = os.stat('./quantum.slx').st_size
if check < 10:
input("file \"quantum.slx\" exists but is empty or has invalid data! please regenerate the file, then try again. \npress <Enter> to close this window.")
sys.exit()
with open('./quantum.slx', 'r') as f:
lines = f.read().splitlines()
f.close()
print("opening \"./quantum.slx\"...")
return lines
def edit_relay_lines(l):
print("processing...")
isrelay = False
teamname = ""
for i in range(len(l)):
if l[i][0].isnumeric():
if "relay" in (l[i]).lower():
isrelay = True
else:
isrelay = False
else:
if isrelay == True:
current_line = l[i].split(";")
if str(current_line[3]) == "0":
teamname = str(current_line[6])
print("team name: ", teamname)
else:
if str(current_line[4]) != "":
current_line[6] = teamname
l[i] = ";".join(current_line)
return l
def write_file(l):
with open('./quantum.slx', 'w') as f:
f.writelines("\n".join(l))
lines = get_file()
new_lines = edit_relay_lines(lines)
write_file(new_lines)
input("done. press <Enter> to exit.")