Skip to content

Commit 017de78

Browse files
committed
add-scripts
1 parent b625041 commit 017de78

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

codeql-script/skip_old_findres.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import json
2+
3+
def read_json(in_path):
4+
# in_list = list()
5+
out_list = list()
6+
with open(in_path, 'r') as f:
7+
tmp_list = f.readlines()
8+
for line in tmp_list:
9+
line = line.strip('\n')
10+
line_json = json.loads(line)
11+
out_list.append(line_json)
12+
return out_list
13+
14+
if __name__ == '__main__':
15+
new_all_findres = '/home/jhliu/data/Detect-data/findres-new'
16+
old findres = '/home/jhliu/data/Detect-data/findres'
17+
out_findres = '/home/jhliu/data/Detect-data/findres-combine'
18+
19+
old_json = read_json(old_findres)
20+
new_json = read_json(new_all_findres)
21+
22+
hit_list = list()
23+
for item in old_json:
24+
hit_str = item['api'] + item['repo']
25+
if hit_str in hit_list:
26+
continue
27+
28+
else:
29+
hit_list.append(hit_str)
30+
31+
for item in new_json:
32+
hit_str = item['api'] + item['repo']
33+
if hit_str in hit_list:
34+
continue
35+
36+
else:
37+
with open(out_findres, 'a') as f:
38+
f.write(json.dumps(item))
39+
f.write('\n')

0 commit comments

Comments
 (0)