-
Notifications
You must be signed in to change notification settings - Fork 2
/
utility.py
64 lines (59 loc) · 1.76 KB
/
utility.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
55
56
57
58
59
60
61
62
63
64
import json
def load_games(filenames):
games = list()
for filename in filenames:
print("Reading %s" % (filename,))
with open(filename) as gfile:
games += json.load(gfile)
gids = set()
uniques = list()
for g in games:
if g['gameID'] not in gids:
uniques.append(g)
gids.add(g['gameID'])
games = uniques
games.sort(key=lambda x: int(x['gameID']))
print("%d games loaded." % (len(games),))
return games
def filter_in_players(games, players):
keep_players = set(players)
filtered = list()
for game in games:
game_players = set(game.keys())
if game_players & keep_players:
filtered.append(game)
return filtered
def filter_out_players(games, players):
drop_players = set(players)
filtered = list()
for game in games:
game_players = set(game.keys())
if not (game_players & drop_players):
filtered.append(game)
return filtered
def filter_suspect_games(games):
worker_cutoff = 160
filtered = list()
for game in games:
if game['workerID'] is None or int(game['workerID']) > worker_cutoff:
hadError = False
for user in game['users']:
if user["errorLogName"] is not None:
hadError = True
break
if hadError:
continue
filtered.append(game)
return filtered
def filter_error_games(games):
filtered = list()
for game in games:
hadError = False
for user in game['users']:
if user['errorLogName'] is not None:
hadError = True
break
if hadError:
continue
filtered.append(game)
return filtered