diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index ed13d235..3793b490 100644 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -74,7 +74,7 @@ class Everleaf(HandHistoryConverter): self.rexx.setPostSbRegex('.*\n(?P.*): posts small blind \[') self.rexx.setPostBbRegex('.*\n(?P.*): posts big blind \[') self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P.*)\s\[ (?P.*) \]') - self.rexx.setActionStepRegex('^(?P.*) (?Pbets|checks|raises|calls|folds)((\s\$([.\d]+))?(\sto\s\$([.\d]+))?)?') + self.rexx.setActionStepRegex('.*\n(?P.*) (?Pbets|checks|raises|calls|folds)(\s\[\$ (?P[.\d]+) USD\])?') self.rexx.compileRegexes() def readSupportedGames(self): @@ -119,18 +119,12 @@ class Everleaf(HandHistoryConverter): hand.players = players - def markStreets(self, hands): + def markStreets(self, hand): # PREFLOP = ** Dealing down cards ** -# m = re.search('(\*\* Dealing down cards \*\*)(?P.*)(\*\* Dealing Flop \*\*)?(?P.*)?(\*\* Dealing Turn \*\*)?(?P.*)', hands.string,re.DOTALL) - m = re.search('(\*\* Dealing down cards \*\*\n)(?P.*?\n\*\*)?( Dealing Flop \*\*)?(?P.*?\*\*)?( Dealing Turn \*\*)?(?P.*?\*\*)?( Dealing River \*\*)?(?P.*)', hands.string,re.DOTALL) - print "DEBUG: Group 1 = %s - %s - %s" %(m.group(1), m.start(1), len(hands.string)) - print "DEBUG: Group 2 = %s - %s - %s" %(m.group(2), m.start(2), len(hands.string)) - print "DEBUG: Group 3 = %s - %s - %s" %(m.group(3), m.start(3), len(hands.string)) - print "DEBUG: Group 4 = %s - %s - %s" %(m.group(4), m.start(4), len(hands.string)) - print "DEBUG: Group 5 = %s - %s - %s" %(m.group(5), m.start(5), len(hands.string)) - print "DEBUG: Group 6 = %s - %s - %s" %(m.group(6), m.start(6), len(hands.string)) - print "DEBUG: Group 7 = %s - %s - %s" %(m.group(7), m.start(7), len(hands.string)) - print "DEBUG: Group 8 = %s - %s - %s" %(m.group(8), m.start(8), len(hands.string)) + m = re.search('(\*\* Dealing down cards \*\*\n)(?P.*?\n\*\*)?( Dealing Flop \*\*)?(?P.*?\*\*)?( Dealing Turn \*\*)?(?P.*?\*\*)?( Dealing River \*\*)?(?P.*)', hand.string,re.DOTALL) +# for street in m.groupdict(): +# print "DEBUG: Street: %s\tspan: %s" %(street, str(m.span(street))) + hand.streets = m def readBlinds(self, hand): try: @@ -159,8 +153,15 @@ class Everleaf(HandHistoryConverter): hand.holecards = hand.holecards.replace('t','T') def readAction(self, hand, street): - m = self.rexx.rexx.action_re.search(hand.obs) - print m.groups() + m = self.rexx.action_re.finditer(hand.streets.group(street)) + hand.actions = {} + hand.actions[street] = [] + for action in m: + if action.group('ATYPE') == 'raises' or action.group('ATYPE') == 'calls': + hand.actions[street] += [[action.group('PNAME'), action.group('ATYPE'), action.group('BET')]] + else: + hand.actions[street] += [[action.group('PNAME'), action.group('ATYPE')]] + print "DEBUG: readAction: %s " %(hand.actions) if __name__ == "__main__": diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 13feef90..27a4a04e 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -67,6 +67,11 @@ class HandHistoryConverter: self.markStreets(hand) self.readBlinds(hand) self.readHeroCards(hand) + + # Read action (Note: no guarantee this is in hand order. + for street in hand.streets.groupdict(): + self.readAction(hand, street) + if(hand.involved == True): self.writeHand("output file", hand) else: @@ -88,7 +93,8 @@ class HandHistoryConverter: # [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]] def readPlayerStacks(self, hand): abstract - def markStreets(hand): abstract + # Needs to return a MatchObject with group names identifying the streets into the Hand object + def markStreets(self, hand): abstract #Needs to return a list in the format # ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb, @@ -198,8 +204,8 @@ class Hand: self.gametype = gametype self.string = string - self.streets = {} # Index into string for where street starts { 'RIVER': 49 } - # Value in characters. + self.streets = None # A MatchObject using a groupnames to identify streets. + self.actions = None self.handid = 0 self.sb = gametype[3]