Skip to content

Commit aa24f99

Browse files
committed
Merge pull request IronLanguages#39 from paweljasinski/scripts
Scripts
2 parents 1d3ccc6 + ccb03e8 commit aa24f99

36 files changed

+7243
-0
lines changed

Src/Scripts/CompareDirs.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#####################################################################################
2+
#
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
#
5+
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6+
# copy of the license can be found in the License.html file at the root of this distribution. If
7+
# you cannot locate the Apache License, Version 2.0, please send an email to
8+
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9+
# by the terms of the Apache License, Version 2.0.
10+
#
11+
# You must not remove this notice, or any other, from this software.
12+
#
13+
#
14+
#####################################################################################
15+
16+
import sys,nt
17+
sys.path.append(nt.environ['IP_ROOT'] + '\\External\\Regress\\Python24\\Lib')
18+
import filecmp
19+
20+
def compare_dirs(dir1, dir2):
21+
"Tests whether two folders, including all their contents and subdirectories are identical or not (True == they're the same, False == they are not the same)"
22+
dc = filecmp.dircmp(dir1,dir2)
23+
if len(dc.funny_files) > 0 or len(dc.left_only) > 0 or len(dc.right_only) > 0 or len(dc.diff_files) > 0:
24+
dc.report()
25+
return False
26+
else:
27+
for subdir in dc.common_dirs:
28+
if not compare_dirs(dir1 + "\\" + subdir, dir2 + "\\" + subdir):
29+
return False
30+
return True
31+
32+
33+
def main():
34+
if len(sys.argv)!=3:
35+
print 'Usage: CompareDirs <dir1> <dir2>'
36+
sys.exit(-1)
37+
38+
if compare_dirs(sys.argv[1],sys.argv[2]):
39+
print "The directories are identical"
40+
sys.exit(0)
41+
else: #the part that differed is explained via dircmp.report() above
42+
print "The directories differ"
43+
sys.exit(1)
44+
45+
if __name__=="__main__":
46+
main()

Src/Scripts/clean.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#####################################################################################
2+
#
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
#
5+
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6+
# copy of the license can be found in the License.html file at the root of this distribution. If
7+
# you cannot locate the Apache License, Version 2.0, please send an email to
8+
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9+
# by the terms of the Apache License, Version 2.0.
10+
#
11+
# You must not remove this notice, or any other, from this software.
12+
#
13+
#
14+
#####################################################################################
15+
16+
17+
import os
18+
19+
def is_binary(filename):
20+
root, ext = os.path.splitext(filename)
21+
return ext in ['.pyc', '.pyo', '.pdb', '.exe', '.dll', '.projdata']
22+
23+
def do_dir(dirname):
24+
if dirname == BIN_DIR: return
25+
26+
for file in os.listdir(dirname):
27+
filename = os.path.join(dirname, file)
28+
if os.path.isdir(filename):
29+
do_dir(filename)
30+
elif is_binary(filename):
31+
print 'deleting', filename
32+
os.remove(filename)
33+
34+
TOP_DIR = "c:\\IronPython-0.7"
35+
BIN_DIR = os.path.join(TOP_DIR, "bin")
36+
37+
do_dir(TOP_DIR)
38+
39+
40+

Src/Scripts/copyrights.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#####################################################################################
2+
#
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
#
5+
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6+
# copy of the license can be found in the License.html file at the root of this distribution. If
7+
# you cannot locate the Apache License, Version 2.0, please send an email to
8+
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9+
# by the terms of the Apache License, Version 2.0.
10+
#
11+
# You must not remove this notice, or any other, from this software.
12+
#
13+
#
14+
#####################################################################################
15+
16+
cs_header = """/* ****************************************************************************
17+
*
18+
* Copyright (c) Microsoft Corporation. All rights reserved.
19+
*
20+
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
21+
* copy of the license can be found in the License.html file at the root of this distribution. If
22+
* you cannot locate the Apache License, Version 2.0, please send an email to
23+
* ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
24+
* by the terms of the Apache License, Version 2.0.
25+
*
26+
* You must not remove this notice, or any other, from this software.
27+
*
28+
*
29+
* ***************************************************************************/
30+
"""
31+
32+
py_header = """#####################################################################################
33+
#
34+
# Copyright (c) Microsoft Corporation. All rights reserved.
35+
#
36+
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
37+
# copy of the license can be found in the License.html file at the root of this distribution. If
38+
# you cannot locate the Apache License, Version 2.0, please send an email to
39+
# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
40+
# by the terms of the Apache License, Version 2.0.
41+
#
42+
# You must not remove this notice, or any other, from this software.
43+
#
44+
#
45+
#####################################################################################
46+
"""
47+
48+
old_cs_header = """/***************************************************************************
49+
50+
Copyright (c) Microsoft Corporation. All rights reserved.
51+
This code is licensed under the Visual Studio SDK license terms.
52+
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
53+
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
54+
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
55+
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
56+
57+
***************************************************************************/
58+
"""
59+
60+
old_py_header = py_header
61+
62+
def add_header(filename, old_header, new_header):
63+
text = open(filename, 'r').read()
64+
if text.startswith(old_header):
65+
print "replacing header", filename
66+
text = new_header + text[len(old_header):]
67+
open(filename, 'w').write(text)
68+
elif not text.startswith(new_header):
69+
print 'no old header', filename
70+
text = new_header + "\n" + text
71+
open(filename, 'w').write(text)
72+
73+
def do_dir(dirname):
74+
import os
75+
for file in os.listdir(dirname):
76+
print "Processing:", file
77+
if file == "ExternalCode": continue
78+
filename = os.path.join(dirname, file)
79+
if os.path.isdir(filename):
80+
do_dir(filename)
81+
elif filename.endswith(".cs"):
82+
add_header(filename, old_cs_header, cs_header)
83+
elif filename.endswith(".py"):
84+
add_header(filename, old_py_header, py_header)
85+
86+
87+
if __name__ == "__main__":
88+
do_dir(".")

0 commit comments

Comments
 (0)