|
| 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