Bit more Everleaf
This commit is contained in:
parent
7053b7f748
commit
0bbf801d89
|
@ -59,15 +59,21 @@ class Everleaf(HandHistoryConverter):
|
|||
HandHistoryConverter.__init__(self, config, file, "Everleaf") # Call super class init.
|
||||
self.sitename = "Everleaf"
|
||||
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()
|
||||
|
||||
def readSupportedGames(self):
|
||||
pass
|
||||
|
||||
def determineGameType(self):
|
||||
# Cheating with this regex, only support nlhe at the moment
|
||||
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
|
||||
|
||||
def readPlayerStacks(self):
|
||||
|
@ -83,5 +89,5 @@ if __name__ == "__main__":
|
|||
c = Configuration.Config()
|
||||
e = Everleaf(c, "regression-test-files/everleaf/Speed_Kuala.txt")
|
||||
e.processFile()
|
||||
# print str(e)
|
||||
print str(e)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import re
|
|||
|
||||
class FpdbRegex:
|
||||
def __init__(self):
|
||||
self.__GAME_INFO_REGEX=''
|
||||
self.__SPLIT_HAND_REGEX='\n\n\n'
|
||||
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+)\)?'
|
||||
|
@ -55,6 +56,7 @@ class FpdbRegex:
|
|||
|
||||
def compileRegexes(self):
|
||||
### Compile the regexes
|
||||
self.game_info_re = re.compile(self.__GAME_INFO_REGEX)
|
||||
self.split_hand_re = re.compile(self.__SPLIT_HAND_REGEX)
|
||||
self.hand_start_re = re.compile(self.__NEW_HAND_REGEX)
|
||||
self.hand_info_re = re.compile(self.__HAND_INFO_REGEX)
|
||||
|
@ -82,6 +84,9 @@ class FpdbRegex:
|
|||
|
||||
# Set methods for plugins to override
|
||||
|
||||
def setGameInfoRegex(self, string):
|
||||
self.__GAME_INFO_REGEX = string
|
||||
|
||||
def setSplitHandRegex(self, string):
|
||||
self.__SPLIT_HAND_REGEX = string
|
||||
|
||||
|
|
|
@ -54,6 +54,14 @@ class HandHistoryConverter:
|
|||
tmp = tmp + "\tsb/bb: '%s/%s'\n" % (self.gametype[3], self.gametype[4])
|
||||
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
|
||||
def readSupportedGames(self): abstract
|
||||
|
||||
|
@ -91,19 +99,12 @@ class HandHistoryConverter:
|
|||
def setFileType(self, filetype = "text"):
|
||||
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):
|
||||
hands = []
|
||||
list = self.rexx.split_hand_re.split(self.obs)
|
||||
for l in list:
|
||||
hands = hands + [Hand(l)]
|
||||
hands = hands + [Hand(self.sitename, self.gametype, l)]
|
||||
return hands
|
||||
|
||||
def readFile(self, filename):
|
||||
"""Read file"""
|
||||
|
@ -160,13 +161,10 @@ class HandHistoryConverter:
|
|||
|
||||
class Hand:
|
||||
# def __init__(self, sitename, gametype, sb, bb, string):
|
||||
def __init__(self, string):
|
||||
# self.sitename = sitename
|
||||
# self.gametype = gametype
|
||||
# self.sb = sb
|
||||
# self.bb = bb
|
||||
def __init__(self, sitename, gametype, string):
|
||||
self.sitename = sitename
|
||||
self.gametype = gametype
|
||||
self.string = string
|
||||
print string
|
||||
|
||||
self.handid = None
|
||||
self.tablename = "Slartibartfast"
|
||||
|
|
Loading…
Reference in New Issue
Block a user