|
1 | 1 | import os
|
| 2 | +import datetime |
2 | 3 |
|
3 | 4 | header_test = 'Released under a MIT (SEI)-style license'
|
4 |
| -header = 'Copyright 2021 Carnegie Mellon University. All Rights Reserved. \n Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.' |
| 5 | +header = 'Copyright ' + str(datetime.date.today().year) + ' Carnegie Mellon University. All Rights Reserved. \n Released under a MIT (SEI)-style license. See LICENSE.md in the project root for license information.' |
5 | 6 |
|
6 | 7 | print('header not in:')
|
7 |
| -# iterate over all files in directory |
| 8 | +# iterate over all files in directory |
8 | 9 | for root, dirs, files in os.walk("."):
|
9 | 10 | for file in files:
|
10 | 11 | # only care about files with extensions considered to be source code
|
|
17 | 18 | # add header to file
|
18 | 19 | if file.endswith(('.cs', '.ts', '.js', '.css', '.go', '.scss', '.php')):
|
19 | 20 | # comment type ' /* __ */
|
20 |
| - with open(os.path.join(root,file), 'w') as modified: modified.write('/*\n' + header + '\n*/\n\n' + data) |
| 21 | + with open(os.path.join(root,file), 'w') as modified: modified.write('/*\n ' + header + '\n*/\n\n' + data) |
21 | 22 | elif file.endswith(('.xml', '.html')):
|
22 | 23 | # comment type ' <!-- __ --> '
|
23 |
| - with open(os.path.join(root,file), 'w') as modified: modified.write('<!--\n' + header + '\n-->\n\n' + data) |
| 24 | + with open(os.path.join(root,file), 'w') as modified: modified.write('<!--\n ' + header + '\n-->\n\n' + data) |
24 | 25 | elif file.endswith('py'):
|
25 | 26 | # comment type ' """ ___ """ '
|
26 |
| - with open(os.path.join(root,file), 'w') as modified: modified.write('"""\n' + header + '\n"""\n\n' + data) |
| 27 | + with open(os.path.join(root,file), 'w') as modified: modified.write('"""\n ' + header + '\n"""\n\n' + data) |
0 commit comments