def json(self, key, **k): if key=='gamedata': if 'replay_id' in k: return json.dumps(next( r.gamedata for r in util.get_replays() if r.replay_id==k['replay_id'])) else: return json.dumps(dict((r.replay_id, r.gamedata) for r in util.get_replays())) elif key=='metadata': return json.dumps( dict((r.replay_id, r.metadata) for r in util.get_replays())) elif key=='players': return json.dumps(dict((p_name, p_data) for p_name, p_data in util.get_players().items())) else: return '{}'
def index(self, debug=False): return loader.load('listview.tpl.html').generate( replays=util.get_replays(), debug=debug).render('html')
def game(self, replay_id, debug=False): replay = next(r for r in util.get_replays() if r.replay_id==replay_id) return loader.load("gamedetails.tpl.html").generate( replay=replay, debug=debug).render("html")