ยปCore Development>Code coverage>PCbuild/vs9to10.py

Python code coverage for PCbuild/vs9to10.py

#countcontent
1n/a#Run this file after automatic convertsion of the VisualStudio 2008 solution by VisualStudio 2010.
2n/a#This can be done whenever the 2008 solution changes.
3n/a#It will make the necessary cleanup and updates to the vcxproj files
4n/a#the .props files need to be maintained by hand if the .vsprops files change
5n/a
6n/afrom __future__ import with_statement
7n/aimport sys
8n/aimport os
9n/aimport os.path
10n/a
11n/adef vs9to10(src, dest):
12n/a for name in os.listdir(src):
13n/a path, ext = os.path.splitext(name)
14n/a if ext.lower() not in ('.vcxproj',):
15n/a continue
16n/a
17n/a filename = os.path.normpath(os.path.join(src, name))
18n/a destname = os.path.normpath(os.path.join(dest, name))
19n/a print("%s -> %s" % (filename, destname))
20n/a
21n/a lines = []
22n/a lastline = b""
23n/a importgroup = False
24n/a with open(filename, 'rb') as fin:
25n/a for line in fin:
26n/a #remove redundant linker output info
27n/a if b"<OutputLine>" in line:
28n/a continue
29n/a if b"<ProgramDatabaseFile>" in line:
30n/a continue
31n/a if b"<ImportLibrary>" in line and b"</ImportLibrary>" in line:
32n/a continue
33n/a
34n/a #add new property sheet to the pythoncore
35n/a if importgroup and "pythoncore" in name.lower():
36n/a if b"</ImportGroup>" in line:
37n/a if b"debug.props" in lastline:
38n/a lines.append(b' <Import Project="pythoncore_d.props" />\r\n')
39n/a elif b"pythoncore" not in lastline:
40n/a lines.append(b' <Import Project="pythoncore.props" />\r\n')
41n/a if b"<ImportGroup Condition" in line:
42n/a importgroup = True
43n/a elif b"</ImportGroup>" in line:
44n/a importgroup = False
45n/a lines.append(line)
46n/a lastline = line
47n/a with open(destname, 'wb') as fout:
48n/a for line in lines:
49n/a fout.write(line)
50n/a
51n/aif __name__ == "__main__":
52n/a src = "." if len(sys.argv) < 2 else sys.argv[1]
53n/a name = os.path.basename(os.path.abspath(src))
54n/a dest = os.path.abspath(os.path.join(src, "..", name + "Upd"))
55n/a os.makedirs(dest)
56n/a vs9to10(src, dest)