2 from __future__
import print_function
6 topfunc = re.compile(
r"::(accumulate|acquire|startingNewLoop|duringLoop|endOfLoop|beginOfJob|endOfJob|produce|analyze|filter|beginLuminosityBlock|beginRun|beginStream|streamBeginRun|streamBeginLuminosityBlock|streamEndRun|streamEndLuminosityBlock|globalBeginRun|globalEndRun|globalBeginLuminosityBlock|globalEndLuminosityBlock|endRun|endLuminosityBlock)\(")
8 baseclass = re.compile(
r"edm::(one::|stream::|global::)?(ED(Producer|Filter|Analyzer|(IterateNTimes|NavigateEvents)?Looper)(Base)?|impl::(ExternalWork|Accumulator))")
9 farg = re.compile(
r"\(.*?\)")
10 tmpl = re.compile(
r'<.*?>')
12 epfuncre = re.compile(
r"edm::eventsetup::EventSetupRecord::get<.*>\(.*\)")
13 skipfunc = re.compile(
r"TGraph::IsA\(.*\)")
31 h = open(
'module_to_package.yaml',
'r')
32 module2package=yaml.load(h, Loader=yaml.FullLoader)
34 with open(
'function-calls-db.txt')
as f:
36 fields = line.split(
"'")
39 if fields[2] ==
' calls function ' :
40 if not skipfunc.search(line) :
41 G.add_edge(fields[1],fields[3],kind=fields[2])
42 if epfuncre.search(fields[3]) :
43 epfuncs.add(fields[3])
44 if fields[2] ==
' overrides function ' :
45 if baseclass.search(fields[3]) :
46 if topfunc.search(fields[3]) :
47 toplevelfuncs.add(fields[1])
48 G.add_edge(fields[1],fields[3],kind=
' overrides function ')
50 if not skipfunc.search(line) :
51 G.add_edge(fields[3],fields[1],kind=
' calls override function ')
52 if epfuncre.search(fields[1]) : epfuncs.add(fields[1])
57 for tfunc
in toplevelfuncs:
58 for epfunc
in epfuncs:
59 if G.has_node(tfunc)
and G.has_node(epfunc)
and nx.has_path(G,tfunc,epfunc) :
60 path = nx.shortest_path(G,tfunc,epfunc)
64 if epfuncre.search(p):
break
65 stripped=re.sub(farg,
"()",p)
66 if previous != stripped:
74 for key
in sorted(module2package.keys()):
75 for value
in sorted(module2package[key]):
76 vre=re.compile(
' %s::.*();' % value)
77 for cs
in sorted(callstacks):
79 report.setdefault(key, {}).setdefault(value, []).
append(cs)
80 r=open(
'eventsetuprecord-get.yaml',
'w')