2 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 # + This file is part of enGrid. +
6 # + Copyright 2008-2014 enGits GmbH +
8 # + enGrid is free software: you can redistribute it and/or modify +
9 # + it under the terms of the GNU General Public License as published by +
10 # + the Free Software Foundation, either version 3 of the License, or +
11 # + (at your option) any later version. +
13 # + enGrid is distributed in the hope that it will be useful, +
14 # + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 # + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 # + GNU General Public License for more details. +
18 # + You should have received a copy of the GNU General Public License +
19 # + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 def update_file(file_name
, header
, comment
, num_preserve
):
26 f
= open(file_name
, "r")
27 old_lines
= f
.readlines()
31 for i
in range(num_preserve
):
32 new_lines
.append(old_lines
[i
])
33 for i
in range(num_preserve
, len(old_lines
)):
36 if not line
.startswith(comment
):
39 new_lines
.append(line
)
40 f
= open(file_name
, "w")
41 for i
in range(num_preserve
):
44 f
.write(comment
+ " " + line
)
45 for i
in range(num_preserve
, len(new_lines
)):
49 def recursive_traversal(dir, header
):
53 file_name
= os
.path
.join(dir,fn
)
54 if os
.path
.isdir(file_name
):
55 recursive_traversal(file_name
, header
)
57 if (file_name
.endswith(".h")):
58 update_file(file_name
, header
, "//", 0)
59 if (file_name
.endswith(".cpp")):
60 update_file(file_name
, header
, "//", 0)
61 if (file_name
.endswith(".cxx")):
62 update_file(file_name
, header
, "//", 0)
63 if (file_name
.endswith(".cu")):
64 update_file(file_name
, header
, "//", 0)
65 if (file_name
.endswith(".pro")):
66 update_file(file_name
, header
, "#", 0)
67 if (file_name
.endswith(".pri")):
68 update_file(file_name
, header
, "#", 0)
69 if (file_name
.endswith(".sh")):
70 update_file(file_name
, header
, "#", 1)
71 if (file_name
.endswith(".bash")):
72 update_file(file_name
, header
, "#", 1)
73 if (file_name
.endswith(".py")):
74 update_file(file_name
, header
, "#", 1)
75 if (file_name
.endswith(".f")):
76 update_file(file_name
, header
, "c ", 0)
77 if (file_name
.endswith("CMakeLists.txt")):
78 update_file(file_name
, header
, "#", 0)
81 f
= open("licence_header.txt")
82 header
= f
.readlines()
85 recursive_traversal(".", header
)