updated to modern VTK
[engrid-github.git] / src / scripts / new_class.py
blob43fd1c9c3a63359999ce75c7026c761383156f11
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
23 import sys
25 def get_path(command):
26 parts = command.split("/")
27 path = ""
28 for i in range(len(parts) - 1):
29 path = path + parts[i] + "/"
30 return path
32 def get_lic():
33 file_name = get_path(sys.argv[0]) + "../licence_header.txt"
34 read_buf = open(file_name, "r").read()
35 lines = read_buf.split("\n")
36 lic = ""
37 for line in lines:
38 lic = lic + "// " + line + "\n"
39 return lic
41 def write_h(class_name):
42 f = open(class_name.lower() + ".h", "w")
43 f.write(get_lic())
44 f.write("#ifndef " + class_name.upper() + "_H\n")
45 f.write("#define " + class_name.upper() + "_H\n")
46 f.write("\n")
47 f.write("#include \"operation.h\"\n")
48 f.write("\n")
49 f.write("class " + class_name + ";\n")
50 f.write("\n")
51 f.write("\n")
52 f.write("class " + class_name + "\n")
53 f.write("{\n")
54 f.write("};\n")
55 f.write("\n")
56 f.write("#endif // " + class_name.upper() + "_H\n")
58 def write_cpp(class_name):
59 f = open(class_name.lower() + ".cpp", "w")
60 f.write(get_lic())
61 f.write("#include \"" + class_name.lower() + ".h\"\n")
62 f.write("\n")
65 class_name = sys.argv[1]
66 write_h(class_name)
67 write_cpp(class_name)