-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprint_statistics.py
72 lines (50 loc) · 1.68 KB
/
print_statistics.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
60
61
62
63
64
65
66
67
68
69
70
71
import os
import csv
num_of_methods = 0
num_ok = 0
manual_methods = 0
num_manual = 0
num_no_info = 0
def process_no_info(dirname):
patches_folder = os.path.join(dirname, 'patches')
log_file = os.path.join(dirname, 'log')
if os.path.isfile(log_file):
global num_no_info
print(dirname.split('/')[-1] + " UNKNOWN")
num_no_info += 1
return
global num_manual
num_manual += 1
global manual_methods
manual_methods += len(os.listdir(patches_folder))
print(dirname.split('/')[-1] + " " + str(len(os.listdir(patches_folder))) + " MANUALLY")
def process_project(dirname):
moved_methods_name = 'moved-methods.csv'
moved_methods_path = os.path.join(dirname, moved_methods_name)
if not os.path.isfile(moved_methods_path):
process_no_info(dirname)
return
result = -1
with open(moved_methods_path) as moved_methods_file:
csv_reader = csv.reader(moved_methods_file, delimiter=',')
for _ in csv_reader:
result += 1
print(dirname.split('/')[-1] + " " + str(result))
global num_of_methods
num_of_methods += result
global num_ok
num_ok += 1
def main():
for filename in os.listdir():
if not os.path.isdir(filename) or filename == '.git':
continue
process_project(filename)
print('Partially processed projects:', num_no_info)
print()
print('Projects with manually moved methods:', num_manual)
print('Manually moved methods:', manual_methods)
print()
print('Automatically processed projects:', num_ok)
print('Automatically moved methods:', num_of_methods)
if __name__ == '__main__':
main()