Bit more Everleaf

This commit is contained in:
Worros 2008-11-10 16:41:04 +10:00
parent 7053b7f748
commit 0bbf801d89
3 changed files with 26 additions and 17 deletions

View File

@ -59,14 +59,20 @@ class Everleaf(HandHistoryConverter):
HandHistoryConverter.__init__(self, config, file, "Everleaf") # Call super class init. HandHistoryConverter.__init__(self, config, file, "Everleaf") # Call super class init.
self.sitename = "Everleaf" self.sitename = "Everleaf"
self.setFileType("text") self.setFileType("text")
self.rexx.setSplitHandRegex("\n\n\n") self.rexx.setGameInfoRegex('.*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)')
self.rexx.setSplitHandRegex('\n\n\n')
self.rexx.compileRegexes() self.rexx.compileRegexes()
def readSupportedGames(self): def readSupportedGames(self):
pass pass
def determineGameType(self): def determineGameType(self):
# Cheating with this regex, only support nlhe at the moment
gametype = ["ring", "hold", "nl"] gametype = ["ring", "hold", "nl"]
m = self.rexx.game_info_re.search(self.obs)
gametype = gametype + [self.float2int(m.group('SB'))]
gametype = gametype + [self.float2int(m.group('BB'))]
return gametype return gametype
@ -83,5 +89,5 @@ if __name__ == "__main__":
c = Configuration.Config() c = Configuration.Config()
e = Everleaf(c, "regression-test-files/everleaf/Speed_Kuala.txt") e = Everleaf(c, "regression-test-files/everleaf/Speed_Kuala.txt")
e.processFile() e.processFile()
# print str(e) print str(e)

View File

@ -27,6 +27,7 @@ import re
class FpdbRegex: class FpdbRegex:
def __init__(self): def __init__(self):
self.__GAME_INFO_REGEX=''
self.__SPLIT_HAND_REGEX='\n\n\n' self.__SPLIT_HAND_REGEX='\n\n\n'
self.__NEW_HAND_REGEX='^.?PokerStars Game #\d+:\s+Hold\'em' self.__NEW_HAND_REGEX='^.?PokerStars Game #\d+:\s+Hold\'em'
self.__HAND_INFO_REGEX='^.*#(\d+):\s+(\S+)\s([\s\S]+)\s\(\$?([.0-9]+)/\$?([.0-9]+)\)\s-\s(\S+)\s-?\s?(\S+)\s\(?(\w+)\)?' self.__HAND_INFO_REGEX='^.*#(\d+):\s+(\S+)\s([\s\S]+)\s\(\$?([.0-9]+)/\$?([.0-9]+)\)\s-\s(\S+)\s-?\s?(\S+)\s\(?(\w+)\)?'
@ -55,6 +56,7 @@ class FpdbRegex:
def compileRegexes(self): def compileRegexes(self):
### Compile the regexes ### Compile the regexes
self.game_info_re = re.compile(self.__GAME_INFO_REGEX)
self.split_hand_re = re.compile(self.__SPLIT_HAND_REGEX) self.split_hand_re = re.compile(self.__SPLIT_HAND_REGEX)
self.hand_start_re = re.compile(self.__NEW_HAND_REGEX) self.hand_start_re = re.compile(self.__NEW_HAND_REGEX)
self.hand_info_re = re.compile(self.__HAND_INFO_REGEX) self.hand_info_re = re.compile(self.__HAND_INFO_REGEX)
@ -82,6 +84,9 @@ class FpdbRegex:
# Set methods for plugins to override # Set methods for plugins to override
def setGameInfoRegex(self, string):
self.__GAME_INFO_REGEX = string
def setSplitHandRegex(self, string): def setSplitHandRegex(self, string):
self.__SPLIT_HAND_REGEX = string self.__SPLIT_HAND_REGEX = string

View File

@ -54,6 +54,14 @@ class HandHistoryConverter:
tmp = tmp + "\tsb/bb: '%s/%s'\n" % (self.gametype[3], self.gametype[4]) tmp = tmp + "\tsb/bb: '%s/%s'\n" % (self.gametype[3], self.gametype[4])
return tmp return tmp
def processFile(self):
if not self.sanityCheck():
print "Cowardly refusing to continue after failed sanity check"
return
self.readFile(self.file)
self.gametype = self.determineGameType()
self.hands = self.splitFileIntoHands()
# Functions to be implemented in the inheriting class # Functions to be implemented in the inheriting class
def readSupportedGames(self): abstract def readSupportedGames(self): abstract
@ -91,19 +99,12 @@ class HandHistoryConverter:
def setFileType(self, filetype = "text"): def setFileType(self, filetype = "text"):
self.filetype = filetype self.filetype = filetype
def processFile(self):
if not self.sanityCheck():
print "Cowardly refusing to continue after failed sanity check"
return
self.readFile(self.file)
self.gametype = self.determineGameType()
self.splitFileIntoHands()
def splitFileIntoHands(self): def splitFileIntoHands(self):
hands = [] hands = []
list = self.rexx.split_hand_re.split(self.obs) list = self.rexx.split_hand_re.split(self.obs)
for l in list: for l in list:
hands = hands + [Hand(l)] hands = hands + [Hand(self.sitename, self.gametype, l)]
return hands
def readFile(self, filename): def readFile(self, filename):
"""Read file""" """Read file"""
@ -160,13 +161,10 @@ class HandHistoryConverter:
class Hand: class Hand:
# def __init__(self, sitename, gametype, sb, bb, string): # def __init__(self, sitename, gametype, sb, bb, string):
def __init__(self, string): def __init__(self, sitename, gametype, string):
# self.sitename = sitename self.sitename = sitename
# self.gametype = gametype self.gametype = gametype
# self.sb = sb
# self.bb = bb
self.string = string self.string = string
print string
self.handid = None self.handid = None
self.tablename = "Slartibartfast" self.tablename = "Slartibartfast"