-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graph Renaming.py
95 lines (78 loc) · 2 KB
/
Graph Renaming.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
import sys, os, shutil
droppedPath = sys.argv[1].rsplit("\\", 1)[0] + "\\"
droppedGPU = droppedPath.split("OCAT Data")[1].split("\\")[1]
droppedOCAT = droppedPath.split("OCAT Data")[0] + "OCAT Data\\"
os.chdir(droppedPath)
Z = 1
# zero-padding width
if "Locations.txt" in os.listdir(droppedOCAT):
LOCs = open(droppedOCAT + "Locations.txt", 'r').readlines()
LOCs = [line.rstrip('\n') for line in LOCs]
if "APIs.txt" in os.listdir(droppedOCAT):
APIs = open(droppedOCAT + "APIs.txt", 'r').readlines()
APIs = [line.rstrip('\n') for line in APIs]
APIs = [API + " -" for API in APIs]
# this last bit makes it check for the hyphen that separates the parts of the filename
else:
APIs = [""]
if "Qualities.txt" in os.listdir(droppedOCAT):
QUAs = open(droppedOCAT + "Qualities.txt", 'r').readlines()
QUAs = [line.rstrip('\n') for line in QUAs]
else:
QUAs = [\
"Minimum Acceptable",\
"High",\
"Max"]
GPUs = [\
'RX 580',\
'RX Vega 64',\
'GTX 770',\
'GTX 980',\
'GTX 1070',\
'GTX 1080',\
'RTX 2060',\
'RTX 2080']
DATAs = [\
'Frame',\
'Display',\
'Render',\
'Driver']
TYPEs = [\
'Summary',\
'Course',\
'Freq',\
'QQ',\
'Diff',\
'Diff EXT',\
'Summary Labeled']
def numFind (filename, list):
if list == [""]:
return(0)
for i in reversed(range(len(list))):
if list[i] in filename:
return(i+1)
return(0)
def numGen (filename, GPU = droppedGPU):
if GPU not in GPUs:
gpu = ""
else:
gpu = numFind(droppedGPU, GPUs)
if APIs == [""]:
api = ""
else:
api = numFind(filename, APIs)
loc = numFind(filename, LOCs)
qua = numFind(filename, QUAs)
data = numFind(filename, DATAs)
type = numFind(filename, TYPEs)
code = ""
for x in [gpu, api, qua, loc, data, type]:
if x != "":
code = code + str(x).zfill(Z)
return(code)
if not os.path.exists("@Graphs"):
os.mkdir("@Graphs")
for file in os.listdir(droppedPath):
if file.endswith(".png"):
shutil.copyfile(file, "@Graphs\\" + numGen(file) + ".png")
# os.system("pause")