forked from coconut-svsm/svsm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlines.py
59 lines (52 loc) · 1.84 KB
/
lines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import sys
import pandas as pd
l = []
for line in sys.stdin:
l.append(line)
cargopath = "/home/patrick/.cargo/registry/src/index.crates.io-6f17d22bba15001f"
deps = os.listdir(cargopath)
#print(deps)
lines = []
#fix names:
ll = []
for line in l:
if "label" in line:
t = line.split("\"")
t = t[0] + " " + "\"" + ("-".join(t[1].split(" "))) + "\" "+ " ".join(t[2:len(t)])
ll.append(t)
else:
ll.append(line)
l = ll
local = ["svsm","svsm-fuzz","packit","test","bootlib", "elf","syscall","libmstpm","cpuarch","igvmbuilder","igvmmeasure"]
local_path = ["kernel","fuzz","../../../../home/patrick/.cargo/git/checkouts/packit-b3e2ba428e3d4383/f31283d/src"] + local[3:len(local)]
for line in l:
if "label" in line:
if not any(n in line for n in local):
s = line.split("\"")
dep = s[1]
dep_org = dep
if not dep in deps:
for d in deps:
if dep in d:
dep = d
#print(dep)
infostream = os.popen(f"cloc --csv {cargopath}/{dep}")
#info = infostream.read()
info = pd.read_csv(infostream)
loc = info[info["language"].isin(["Rust", "C"])]["code"].sum()
r = s[0] + "\"" + (dep+" "+str(loc))+"\"" + "".join(s[2:len(s)])
print(r)
else:
s = line.split("\"")
dep = s[1]
infostream = os.popen(f"cloc --csv ./{local_path[local.index(dep)]}")
#info = infostream.read()
info = pd.read_csv(infostream)
loc = info[info["language"].isin(["Rust", "C"])]["code"].sum()
r = s[0] + "\"" + (dep+" "+str(loc))+"\"" + "".join(s[2:len(s)])
print(r)
else:
print(line)
pass
#--exclude igvmmeasure,igvmbuilder,svsm-fuzz