forked from Antar1011/Smogon-Usage-Stats
-
Notifications
You must be signed in to change notification settings - Fork 3
/
MegaCounter.py
37 lines (32 loc) · 882 Bytes
/
MegaCounter.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
#!/usr/bin/python
import sys
import json
from TA import megas
from common import keyify
stats=json.load(open(sys.argv[1]))
megastats=[]
total=0
for species in stats['data'].keys():
total += sum(stats['data'][species]['Abilities'].values())
if keyify(species) == 'rayquaza':
name = species
try:
megastats.append([name,stats['data'][species]['Moves']['dragonascent']])
except KeyError:
pass
else:
for mega in megas:
if keyify(species) == mega[0]:
try:
name = species
if mega[1][-1] in ['x','y']:
name+=' '+mega[1][-1].upper()
megastats.append([name,stats['data'][species]['Items'][mega[1]]])
if mega[1][-1] != 'x':
break
except KeyError:
if mega[1][-1] != 'x':
break
megastats=sorted(megastats, key=lambda megastats:-megastats[1])
for mega in megastats:
print "%-18s%8.5f%%" % (mega[0],600.0*mega[1]/total)