-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodifyIncludesAfterMovingFiles.py
34 lines (26 loc) · 1.08 KB
/
modifyIncludesAfterMovingFiles.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
import applyRegexToFolder as Apply
Apply.setExtensionFilter(['cpp', 'hpp', 'h', 'c'])
outputFolder = r'C:\Work\Source\composer3'
inputFile = r'C:\Work\Source\rename.log'
file = open(inputFile, 'r')
renameLog = file.readlines()
file.close()
renameLog = [x.strip() for x in renameLog]
hasReadInitialFileName = False
renameFromString = 'rename from '
renameToString = 'rename to '
for line in renameLog:
if line.startswith(renameFromString):
initialFileName = line.replace(renameFromString, '')
if initialFileName[-3:] == 'hpp':
hasReadInitialFileName = True
initialFileName = initialFileName.replace('src/', '')
elif line.startswith(renameToString) and hasReadInitialFileName:
hasReadInitialFileName = False
newFileName = line.replace(renameToString, '')
newFileName = newFileName.replace('src/', '')
regex = r'#include\s+<' + initialFileName + '>'
replacement = r'#include <' + newFileName + '>'
print('replace ' + regex + ' with ' + replacement)
Apply.setParameters(outputFolder, outputFolder, regex, replacement, _isDotMatchingAll=True, _silentMode=True)
Apply.run()