-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stats.py
54 lines (48 loc) · 2.04 KB
/
Stats.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
import ContributorTools
stats = {
'client': {
'methods': {'total': 0, 'renamed': 0, 'unnamed': 0},
'fields': {'total': 0, 'renamed': 0, 'unnamed': 0},
'both': {'total': 0, 'renamed': 0, 'unnamed': 0}
},
'server': {
'methods': {'total': 0, 'renamed': 0, 'unnamed': 0},
'fields': {'total': 0, 'renamed': 0, 'unnamed': 0},
'both': {'total': 0, 'renamed': 0, 'unnamed': 0}
},
'both': {
'methods': {'total': 0, 'renamed': 0, 'unnamed': 0},
'fields': {'total': 0, 'renamed': 0, 'unnamed': 0},
'both': {'total': 0, 'renamed': 0, 'unnamed': 0}
}
}
def recordStat(side, memberType, stat):
stats[side][memberType][stat] += 1
stats[side]['both'][stat] += 1
stats['both'][memberType][stat] += 1
stats['both']['both'][stat] += 1
for side, sideMembers in ContributorTools.getAllMembers().items():
sideName = {'0': 'client', '1': 'server'}[side]
for name, info in sideMembers.items():
memberType = {'func_': 'methods', 'field': 'fields'}[info['searge'][:5]]
recordStat(sideName, memberType, 'total')
if info['searge'] == info['name'] and info['desc'] == '':
recordStat(sideName, memberType, 'unnamed')
else:
recordStat(sideName, memberType, 'renamed')
def output(side, memberType):
data = stats[side][memberType]
total = ' ' * (5 - len(str(data['total']))) + str(data['total'])
renamed = ' ' * (5 - len(str(data['renamed']))) + str(data['total'])
unnamed = ' ' * (5 - len(str(data['unnamed']))) + str(data['unnamed'])
percent = str(round(float(data['renamed']) / float(data['total']) * 100, 2)).ljust(5, '0')
return '[' + side[0].upper() + '][' + memberType.upper().rjust(7) + '] : T' + total + ' | R' + renamed + ' | U' + unnamed + ' | ' + percent + '%'
print output('client', 'methods')
print output('client', 'fields')
print output('client', 'both')
print output('server', 'methods')
print output('server', 'fields')
print output('server', 'both')
print output('both', 'methods')
print output('both', 'fields')
print output('both', 'both')