-
Notifications
You must be signed in to change notification settings - Fork 0
/
onegame_fromfile.py
39 lines (29 loc) · 1.01 KB
/
onegame_fromfile.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
#!/usr/bin/env python
import sys
import json
from lib.gamestats import GameStats
import traceback
game_path = ''
stats_path = ''
if len(sys.argv) > 1:
game_id = sys.argv[1]
game_path = f'samples/{game_id}.json'
stats_path = f'samples/{game_id}.boxscore.json'
else:
print('game id is needed')
exit(1)
print(f'Check game {game_path} hotness')
try:
with open(game_path) as game_file, open(stats_path) as stats_file:
game_contents = game_file.read()
stats_contents = stats_file.read()
if game_contents is not None and stats_contents is not None:
analyzer = GameStats(json.loads(game_contents), json.loads(stats_contents))
analyzer.think()
gamePoints = sum([x['points'] for x in analyzer.getPoints()])
print(str(gamePoints))
print(analyzer.getPoints())
except Exception as exc:
traceback_info = sys.exc_info()
print('Exception occured', type(exc).__name__, traceback_info)
traceback.print_tb(exc.__traceback__)