updated to modern VTK
[engrid-github.git] / src / scripts / update_licence.py
blob3d579bf640c520e8a6d063f343852a24c38d2ff2
1 #!/usr/bin/env python
2 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 # + +
4 # + This file is part of enGrid. +
5 # + +
6 # + Copyright 2008-2014 enGits GmbH +
7 # + +
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. +
12 # + +
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. +
17 # + +
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/>. +
20 # + +
21 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 import os
24 def update_file(file_name, header, comment, num_preserve):
25 #print file_name
26 f = open(file_name, "r")
27 old_lines = f.readlines()
28 f.close()
29 new_lines = []
30 in_header = True
31 for i in range(num_preserve):
32 new_lines.append(old_lines[i])
33 for i in range(num_preserve, len(old_lines)):
34 line = old_lines[i]
35 if in_header:
36 if not line.startswith(comment):
37 in_header = False
38 if not in_header:
39 new_lines.append(line)
40 f = open(file_name, "w")
41 for i in range(num_preserve):
42 f.write(new_lines[i])
43 for line in header:
44 f.write(comment + " " + line)
45 for i in range(num_preserve, len(new_lines)):
46 f.write(new_lines[i])
49 def recursive_traversal(dir, header):
50 fns = os.listdir(dir)
51 for fn in fns:
52 if fn != "tetgen":
53 file_name = os.path.join(dir,fn)
54 if os.path.isdir(file_name):
55 recursive_traversal(file_name, header)
56 else:
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()
83 f.close
85 recursive_traversal(".", header)