]> SALOME platform Git repositories - modules/paravis.git/blob - getwrapclasses.py
Salome HOME
do not configure SalomeApp.xml so that we can relocate the generated module.
[modules/paravis.git] / getwrapclasses.py
1 import paraview, os, sys
2 import string
3 import re
4
5 classeslistsm = []
6 classeslistvtk = []
7
8 if os.name == "posix":
9     from libvtkPVServerCommonPython import *
10     from libvtkPVServerManagerPython import *
11 else:
12     from vtkPVServerCommonPython import *
13     from vtkPVServerManagerPython import *
14
15 l1 = dir()
16 for a in l1:
17     if a.startswith("vtk") and (len(a) > 3):
18         classeslistsm.append(a)
19         
20 from paraview.vtk import *
21 l2 = dir()
22
23 for a in l2:
24     if (a not in l1) and a.startswith("vtk"):
25         classeslistvtk.append(a)
26
27 dic=dict();
28 pv_classes_new=classeslistsm
29 while len(pv_classes_new):
30     pv_classes_cur=pv_classes_new
31     pv_classes_new=[]
32     for c in pv_classes_cur:
33         filename=sys.argv[1]+"/"+c+".h"
34         if os.path.isfile(filename):
35             c_new=[]
36             f=open(filename)
37             for line in f:
38                 if re.match('\s*/',line) is None:
39                     if re.match('\s*public\s*:',line):
40                         continue
41
42                     m=re.match('\s*class\s+(vtk\w+)\s*;',line)
43                     if m is not None:
44                         cn=m.group(1)
45                         if cn not in dic.keys() and cn not in pv_classes_new and cn in classeslistvtk:
46                             pv_classes_new.append(cn)
47                             continue
48
49                     m=re.match('\s*struct\s+(vtk\w+)\s*;',line)
50                     if m is not None:
51                         cn=m.group(1)
52                         if cn not in dic.keys() and cn not in pv_classes_new and cn in classeslistvtk:
53                             pv_classes_new.append(cn)
54                             continue
55
56                     m=re.match('\s*#include\s+"(vtk\w+)\.h"',line)
57                     if m is not None:
58                         cn=m.group(1)
59                         if cn not in dic.keys() and cn not in pv_classes_new and cn in classeslistvtk:
60                             pv_classes_new.append(cn)
61                             continue
62
63                     cm=re.findall('public\s+(vtk\w+)',line)
64                     if len(cm) == 0:
65                         continue
66                     for cn in cm:
67                         if cn not in dic.keys() and cn not in pv_classes_new:
68                             pv_classes_new.append(cn)
69                         if cn not in c_new:
70                             c_new.append(cn)
71             f.close()
72             dic[c]=[0, c_new]
73
74 pv_classes_sort=[]
75
76 def collect_dic(cc):
77     ret=[]
78     for c in cc:
79         if len(dic[c][1]) and dic[c][0] == 0:
80              ret+=collect_dic(dic[c][1])
81         if dic[c][0] == 0:
82             ret.append(c)
83             dic[c][0]=1
84     return ret
85
86 pv_classes_sort=collect_dic(dic.keys())
87
88 wf_str=""
89 if(os.path.exists('wrapfiles.txt')):
90     wf_txt=open('wrapfiles.txt','r')
91     strs=wf_txt.readlines()
92     wf_txt.close()
93     for s in strs:
94         wf_str+=s
95 str=""
96
97 for c in pv_classes_sort:
98     str+=c
99     for cc in dic[c][1]:
100         str+=' '+cc
101     str+='\n'
102
103 if(str!=wf_str):
104     wf_txt=open('wrapfiles.txt','w')
105     wf_txt.write(str)
106     wf_txt.close()