diff --git a/pyre/README.md b/pyre/README.md index e45cc2f..5506ecf 100644 --- a/pyre/README.md +++ b/pyre/README.md @@ -58,3 +58,10 @@ published in webpage: https://jmikedupont2.github.io/ai-ticket/pyre/ this is not working yet `pyre-check query "types_in_file('tests.py')"` + + +# calls3 +produces a report with module and called function + +# calls_generic.py +like call2.py but takes a name diff --git a/pyre/calls3.py b/pyre/calls3.py new file mode 100644 index 0000000..3a44f7a --- /dev/null +++ b/pyre/calls3.py @@ -0,0 +1,28 @@ +from collections import Counter +import pandas as pd +data=[] +import glob, json +names = "./report/*/report/pyre_callgraph.json" +#pyre_callgraph.json" + +files = {} +calls=[] +for name in glob.glob(names): + print(name) + name2 = name.replace("/report/pyre_callgraph.json","").replace("./report/","") + with open(name) as fi : + for x in fi: + d = json.loads(x) + data = d["response"] + for x in list(data.keys()): # each function + if (len(data[x])): + for y in data[x]: + if "direct_target" in y: + calls.append( name2 +"|"+ y["direct_target"]) +df= Counter(calls) +df2=pd.DataFrame(df.most_common(), columns=["name","count"]) + +df2[['name','func']] = df2['name'].str.split('|',expand=True) +#df[[]] = df['fun'].str.split('.',expand=True) + +df2.to_csv("function_calls3.csv") diff --git a/pyre/calls_generic.py b/pyre/calls_generic.py new file mode 100644 index 0000000..a5472af --- /dev/null +++ b/pyre/calls_generic.py @@ -0,0 +1,31 @@ +import click +from collections import Counter +import pandas as pd +data=[] +import glob, json + +@click.command() +@click.argument('name') +def main(name): + names = f"./report/{name}/report/pyre_callgraph.json" + files = {} + calls=[] + for name in glob.glob(names): + print(name) + with open(name) as fi : + for x in fi: + d = json.loads(x) + data = d["response"] + for x in list(data.keys()): # each function + if (len(data[x])): + for y in data[x]: + if "direct_target" in y: + calls.append( x +"|"+ y["direct_target"]) + df= Counter(calls) + df2=pd.DataFrame(df.most_common(), columns=["name","count"]) + ofile = name + "function_calls2.csv" + print(ofile) + df2.to_csv(ofile) + +if __name__ == "__main__": + main() diff --git a/pyre/function_calls.csv.html b/pyre/function_calls.csv.html new file mode 100644 index 0000000..e61be31 --- /dev/null +++ b/pyre/function_calls.csv.html @@ -0,0 +1,468 @@ + + +
+