-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddOverride.py
36 lines (34 loc) · 1.32 KB
/
addOverride.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
import re
file = open('override.txt', 'r')
contents = file.read()
file.close()
regex = r"(Vue/Source/.*?):([0-9]+):([0-9]+): warning: '(.*?)' overrides"
result = re.findall(regex, contents)
for elem in result:
filename = elem[0]
lineInFile = int(elem[1])
characterInFile = elem[2]
functionName = elem[3]
file = open(filename, 'r')
contents = file.read()
file.close()
currentLine = 1
indexNewline = contents.find('\n')
while(indexNewline > -1 and currentLine < lineInFile - 1):
currentLine = currentLine + 1
indexNewline = contents.find('\n', indexNewline + 1)
startReplace = indexNewline + 1
match = re.match(r'^[^;{]*?'+functionName+'\([^;{]*?\)\s*(const)?\s*EON_OVERRIDE\s*(const)?(;|{)', contents[startReplace:], re.DOTALL)
if match == None:
replacement = re.sub(r'^(\s*)(virtual\s*)?(([a-zA-Z_]+\s+)*?'+functionName+'\(.*?\)\s*?(const)?)(\s*(;|{))', r'\1\3 EON_OVERRIDE\6', contents[startReplace:], 1, re.DOTALL)
contents = contents[:startReplace] + replacement
file = open(filename, 'w')
file.write(contents)
file.close()
else:
print "function: " + functionName
print "file: " + filename
print "line: " + elem[1]
print "Match:"
print match.group(0)
#raw_input('Press any key...')