Newer
Older
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
import os.path
text = """
/**
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/\n
"""
excludeDirs = ["ThirdParty", "git"]
excludeFiles = ['PhysicalConstants.h']
extensions = [".cc", ".h", ".test"]
def checkNote(filename):
startNote = -1
endNote = -1
isCopyright = False
lines = []
with open(filename, "r") as file:
for line in file.readlines():
lines.append(line)
file.close()
for iLine in range(len(lines)):
line = lines[iLine]
if "/**" in line and startNote == -1:
startNote = iLine
if "copyright" in line.lower() and startNote>=0 and endNote==-1:
isCopyright = True
if "*/" in line and startNote>=0 and endNote==-1:
endNote = iLine
iLine += 1
#if startNote>=0 and endNote>=0 and isCopyright:
#print filename
#for iLine in range(startNote, endNote+1):
# print lines[iLine]
os.rename(filename, filename+".bak")
with open(filename, "w") as file:
file.write(text)
firstLine = 0
if startNote>=0 and endNote>=0 and isCopyright:
firstLine = endNote + 2
for iLine in range(firstLine, len(lines)):
file.write(lines[iLine])
file.close()
def next_file(x, dir_name, files):
for check in excludeDirs :
if check in dir_name:
return
for check in files :
filename, file_extension = os.path.splitext(check)
for check2 in excludeFiles :
if check2 in check:
return
if file_extension in extensions:
checkNote(dir_name + "/" + check)
os.path.walk("./", next_file, 0)