# -*- coding: utf-8 -*- """ download data from Google App Engine """ import urllib import cPickle import saichugenlib as lib if not"LOCAL": URL_TEMPLATE = "http://localhost:8080/pickle_day/%d/" else: URL_TEMPLATE = "http://saichugen-online.appspot.com/pickle_day/%d/" def get_value(i): filename = "gae_logs/%d.pickle" % i url = URL_TEMPLATE % i print "getting", url #urllib.urlretrieve(url, filename) print "got", url data = file(filename).read() games = cPickle.loads(data) return games games = [] for i in range(16): games += get_value(i) print len(games) count = [0] * 14 for g in games: if not(g["players"][0] in [u"そえだ", u"にしお"]): continue for p in [lib.get_mid(v[1]) for a,b,typ,v in g['time_log'] if typ == 'END_ROUND']: count[p] += 1 break print count for p in count: print "*" * (p / 2) print sum(x * y for x, y in zip(count, range(14))) / float(sum(count))