-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFixAllMpc.py
More file actions
41 lines (34 loc) · 1.37 KB
/
FixAllMpc.py
File metadata and controls
41 lines (34 loc) · 1.37 KB
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
import fileinput
import sys
import os
#------------------------------------------
def addVc14ToMpb(filename):
#print("called addVc14ToMpb:", filename)
returnValue = "fail"
for line in fileinput.input(filename, inplace=True):
if line.__contains__("vc13") and not line.__contains__("vc14"):
line = line.replace("vc13", "vc13, vc14", 1) # replace once
returnValue = "success"
sys.stdout.write(line) # prints without additional newline (on windows)
return returnValue
# ------------------------------------------
# find all mpb/mpc files
def fixAllFilesRecursively(path, suffix):
for dirname, dirnames, filenames in os.walk(path):
for filename in filenames:
full_path = os.path.join(dirname, filename)
if full_path.endswith(suffix):
print(full_path)
wasSuccessful = addVc14ToMpb(full_path)
if wasSuccessful == "success":
print(" modified :)")
# prevent recursion into those subdirs with meta-data
if '.svn' in dirnames:
dirnames.remove('.svn')
if '.git' in dirnames:
dirnames.remove('.git')
#------------------------------------------
#------------------------------------------
path = "D:\Dependencies_VS2013_Win32\synapsis\E03.14fake"
suffix = "mpb"
fixAllFilesRecursively(path, suffix)