-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlogParse.py
61 lines (51 loc) · 1.66 KB
/
logParse.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
import sys
import re
reNewGame = re.compile('Starting Game')
reNewTurn = re.compile('Turn ([0-9]+)')
reRevealed = re.compile("adds '(.+)' to the staging area")
reDrawn = re.compile("draws '(.+)'")
rePlayed = re.compile("moves '(.+)' to Table")
reDiscarded= re.compile("discards '(.+)'")
allRevealed=[]
allDrawn=[]
allPlayed=[]
allDiscarded=[]
turnRevealed=[]
turnDrawn=[]
turnPlayed=[]
turnDiscarded=[]
def parse(logFile):
with open(logFile) as f:
for line in f:
if reNewGame.search(line):
print "Starting game"
allRevealed=[]
allDrawn=[]
allPlayed=[]
allDiscarded=[]
turnRevealed=[]
turnDrawn=[]
turnPlayed=[]
turnDiscarded=[]
match = reNewTurn.search(line)
if match is not None:
print "Drawn: "+', '.join(turnDrawn)
print "Revealed: "+', '.join(turnRevealed)
print "Turn "+match.group(1)
turnRevealed=[]
turnDrawn=[]
turnPlayed=[]
turnDiscarded=[]
match = reRevealed.search(line)
if match is not None:
card = match.group(1)
allRevealed.append(card)
turnRevealed.append(card)
match = reDrawn.search(line)
if match is not None:
card = match.group(1)
if card!='Card':
allDrawn.append(card)
turnDrawn.append(card)
# First argument is a text file of the Octgn quest log
parse(sys.argv[1])