-
Notifications
You must be signed in to change notification settings - Fork 0
/
OCAT - Search - PA.py
101 lines (77 loc) · 2.73 KB
/
OCAT - Search - PA.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import sys, os, shutil
droppedPath = sys.argv[1].rsplit("\\", 1)[0] + "\\"
scriptPath = sys.argv[0].rsplit("\\", 1)[0] + "\\"
if "Review" in droppedPath.rsplit("OCAT Data")[0].rsplit("\\", 2)[1]:
TYPE = "SINGLE"
elif "OCAT Data" in droppedPath.rsplit("\\", 4)[2:4]:
TYPE = "MULTI"
else:
TYPE = "SINGLE"
mQUA = "High"
RelPath = droppedPath.split("OCAT Data")[0] + "OCAT Data\\"
listfile = []
for paths, folders, files in os.walk(droppedPath):
for file in files:
if file.startswith("OCAT-") and file.endswith(".csv"):
listfile.append((str(paths).replace(RelPath, "") + "\\" + str(file)).replace("\\\\", "\\"))
# produces a list of all OCAT CSVs with the directory information
listsplit = [file.split("\\") for file in listfile]
listmap = []
for line in listsplit:
listmapL = [line[0], "", "", ""]
for i in range(1, len(line)):
listmapL[len(listmapL) - i] = line[len(line) - i]
listmap.append(listmapL)
# this will map the values I need to the appropriate locations in a list
# [GPU, API, Quality, File]
# if no API change is made, the element will be blank
GPUs, QUAs = [], []
for item in listmap:
GPUs.append(item[0])
QUAs.append(item[2])
GPUs = list(set(GPUs))
if TYPE == "MULTI":
QUAs = [mQUA]
elif TYPE == "SINGLE":
QUAs = list(set(QUAs))
SUBS = "NULL"
droppedGame = RelPath.rsplit("\\", 3)[1] \
.replace(" Performance Analysis", "") \
.replace(" Review", "")
if TYPE == "MULTI" and len(GPUs) != 1:
cGPU = "NULL"
elif TYPE == "SINGLE" or len(GPUs) == 1:
cGPU = "\"" + str(GPUs[0]) + "\""
SUBS = "\"Quality\""
scriptFull = scriptPath + "OCAT - Search - PA.r"
outputName = "Search - PA - " + droppedGame + ".r"
outputFull = droppedPath + "@" + outputName
RPath = droppedPath.replace("\\", "/")
if not os.path.exists(outputFull):
with open(scriptFull, 'r') as fref, open(outputFull, 'w') as fout:
for line in fref:
fout.write(line \
.replace("!PATH!", RPath) \
.replace("!GAME!", droppedGame) \
.replace("!QUA!", QUAs[0]) \
.replace("!SUBS!", SUBS)
)
fout.close()
scriptFull = scriptPath + "OCAT - Combined - Input.r"
outputName = "Combined - Input - " + droppedGame + ".r"
# scriptFull = scriptPath + "OCAT - Search - Input.r"
# outputName = "Search - Input - " + droppedGame + ".r"
outputFull = droppedPath + "@" + outputName
if not os.path.exists(outputFull):
with open(scriptFull, 'r') as fref, open(outputFull, 'w') as fout:
for line in fref:
fout.write(line
.replace("!PATH!", RPath) \
.replace("!GAME!", droppedGame) \
.replace("!QUA!", QUAs[0]) \
.replace("!GPU!", cGPU)
)
fout.close()
if not os.path.exists(droppedPath + "@Combined - Output.r"):
shutil.copyfile(scriptPath + "OCAT - Combined - Output.r", droppedPath + "@Combined - Output.r")
# os.system("pause")