2 from __future__
import print_function
4 stdcl = re.compile(
"^std::(.*)[^>]$")
5 stdptr = re.compile(
"(.*)_ptr$")
6 datacl = re.compile(
"^class ")
7 bfunc = re.compile(
"^function ")
8 mbcl = re.compile(
"(base|data) class")
9 farg = re.compile(
"(.*)\(\w+\)")
10 nsep = re.compile(
"\:\:")
11 topfunc = re.compile(
"::(produce|analyze|filter|beginLuminosityBlock|beginRun|beginStream)\(")
12 baseclass = re.compile(
"edm::(one::|stream::|global::)?ED(Producer|Filter|Analyzer)(Base)?")
13 getfunc = re.compile(
"edm::eventsetup::EventSetupRecord::get<.*>\((.*)&\) const")
14 handle = re.compile(
"(.*),?class edm::ES(.*)Handle<(.*)>")
18 dataclassfuncs = set()
25 flaggedclasses = set()
27 derivedclasses = set()
35 f = open(
'classes.txt.dumperall')
37 if mbcl.search(line) :
38 fields = line.split(
"'")
39 if fields[2] ==
' member data class ':
40 if not stdcl.search(fields[2]) : H.add_edge(fields[1],fields[3],kind=fields[2])
41 if fields[2] ==
' templated member data class ':
42 H.add_edge(fields[1],fields[5],kind=fields[3])
43 if fields[2] ==
' base class ':
44 H.add_edge(fields[1],fields[3],kind=fields[2])
45 I.add_edge(fields[3],fields[1],kind=
' derived class')
48 f = open(
'function-calls-db.txt')
51 if not bfunc.search(line) :
continue
52 fields = line.split(
"'")
53 if fields[2] ==
' calls function ' :
54 G.add_edge(fields[1],fields[3],kind=
' calls function ')
55 if getfunc.search(fields[3]) :
56 dataclassfuncs.add(fields[3])
57 m = getfunc.match(fields[3])
58 n = handle.match(m.group(1))
61 p = re.sub(
"class ",
"",o)
62 dataclass = re.sub(
"struct ",
"",p)
63 dataclasses.add(dataclass)
64 if fields[2] ==
' overrides function ' :
65 if baseclass.search(fields[3]) :
66 G.add_edge(fields[1],fields[3],kind=
' overrides function ')
67 if topfunc.search(fields[3]) : toplevelfuncs.add(fields[1])
68 else : G.add_edge(fields[3],fields[1], kind=
' calls override function ')
69 if fields[2] ==
' static variable ' :
70 G.add_edge(fields[1],fields[3],kind=
' static variable ')
71 statics.add(fields[3])
75 nodes = sorted(dataclasses)
80 if node
in H : stack = [(node,iter(H[node]))]
82 Q=nx.dfs_preorder_nodes(I,node)
84 print(
"class '"+q+
"'")
86 stack.append( ( q, iter( H[q] ) ) )
88 parent,children = stack[-1]
89 print(
"class '"+parent+
"'")
92 if child
not in visited:
94 if not stdcl.search(child):
95 print(
"class '"+child+
"'")
96 stack.append( ( child, iter( H[child] ) ) )
97 kind=H[parent][child][
'kind']
98 print(parent, kind, child)
99 if stdptr.search(kind):
101 Q=nx.dfs_preorder_nodes(I,child)
103 print(
"class '"+q+
"'")
105 stack.append( ( q, iter( H[q] ) ) )
106 except StopIteration: